On a SonarQube Developper v2026.1 solution deployed through the official helm chart, I’m getting a false positive on C++ rule Scoped enumerations should be used in .h code wrapped into extern "C" block.
I understand the code is analyzed as C++ code because this header is also imported in tests written in C++. But I would expect a block of C code wrapped in an extern "C" block to not be analyzed through C++ rules.
I tried to fix the C/C++/Objective-C file extensions through Administration / General Settings / Languages configuration but it did not help, .h is already assigned to C. I did the same with environment variables added to sonar-scanner:
-Dsonar.lang.patterns.c=**/*.h,**/*.c \
-Dsonar.lang.patterns.cpp=**/*.hpp,**/*.cpp
-Dsonar.c.file.suffixes=.c,.h \
-Dsonar.cpp.file.suffixes=.cpp,.hpp
But it did not help either.
...
#ifdef __cplusplus
extern "C" {
#endif
typedef enum _COOK_RecpPowerDCBiasState_E
{
COOK_DC_BIAS_STATE_WAIT_FOR_FILTER_STABLE = 0,
COOK_DC_BIAS_STATE_INIT_OUTPUT = 1,
COOK_DC_BIAS_STATE_CONFIGURE_REGULATOR = 2,
COOK_DC_BIAS_STATE_REGULATOR_RUNNIONG = 3,
}COOK_RecpPowerDCBiasState_E;
...
#ifdef __cplusplus
} // extern "C"
#endif
