C project parsed with C++ rules

I have a C project made only of .c and .h files.

I’m running SonarLint under VS2019 and it gives me a lot of issues that are not found by SonarQube when I use the scanner.

In the VS error window I can see that these issues are related to CPP (i.e cpp:S5028) quality profile.

I’m using
SonarQube Enterprise Edition 7.9.3 (Build 33349)
and I’m working in connected mode.

How can I force SonarLint to use only a specific ruleset?

Thank you

Hi @Massimo_Pozzi. Welcome to the community.

I’m not quite clear what your problem is; it sounds like there might several.

Are you saying that your code is in C, but that C++ rules are incorrectly being run against it? SLVS should be apply the appropriate rules based on the file extension. Or are the C++ rules reporting issues against the header files?

If you are using connected mode then SonarLint will be using a specific ruleset already. However, if you have file exclusions defined on the server they aren’t currently taken in to account by SonarLint (we have a ticket in the backlog for this). Could that account for the difference?

Hello @Massimo_Pozzi,

In addition to what @duncanp mentioned, If you see Cpp rules triggering on C header. Make sure your project setting is set to C explicitly. We detect the language based on that option since C and C++ headers have the same extension.


Thank you, what I meant is that I see issues from cpp dictionary in my header files. i l take into account your suggestion about exclusion, but at the moment I don’t have them.

Thank you a lot, it works! I will check it better tomorrow.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.