I am having a lot of false positives when using SonarLint on my local Eclipse based IDE. It looks like this only happens in header (.h) files.
For instance the following C++ rule is detected as a critical code smell: ‘#Macros should not be used to define constants’
This false positive is shown on each define. So for instance on:
#define ADDRESS_END 0xF0041FFFU
But also C++ rules like ‘Non-const global variables should not be used (cpp:S5421)’ on a prototype of a C function and ‘C-style array should not be used (cpp:S5945)’ on an array definition in a function prototype.
This is strange since this project is a pure C code project and this rule is not enabled for this project on the SonarQube server. SonarLint is bind to this SonarQube project and this issue is not shown in SonarQube itself. It is also not possible to disable this rule locally but this is as expected since the rules are obtained from SonarQube.
We are using the latest build_wrapper to analyze our code.
First we were running SonarQube 8.4 and after updating to 8.6 this issue is still there. On 8.4 we had the SonarCFamily installed but with the current installation we don’t.
First, as far as I can tell, SonarQube 8.6 comes with the CFamily analyzer pre-installed, in version 6.15.0.25047 - you don’t have to install it manually.
Which “Project Natures” does your project have? (Right click on the project Properties Project Natures).
I tried to reproduce on the latest Eclipse + SonarQube 8.6 DE and I observe a behavior similar to what you report when the project has the “C++” nature - which I would expect. If the project has the “C” nature instead, the rules specific to C++ are not triggered.
See the difference in the screenshots below, first one was created as a “C” project, does not trigger the C++ rules:
Here also C++ header and source files are configured. But also after removing those two the issues are still in (also after reboot and re-analyzing all files).
The last thing I tried are the preferences and this does include the Project Natures properties but not the options as your Eclipse screenshots show.
I downloaded the latest CCS from the TI website and created a MSP430 project, and indeed a simple .h file is analyzed as a C++ header file by SonarLint, even though it is considered as a C header file type in the project explorer.
I tried to debug the code where SonarLint detects the file type, and it seems that the underlying CDT infrastructure is classifying it as org.eclipse.cdt.core.cxxHeader, which is the value associated to C++ header files.
However, using the project’s “Advanced settings”, I was able to override this behavior and force .h files to be viewed as "C Header File"s - see screenshot below: