SonarLint no effect

Greetings and Kind Regards I installed SonarLint for Visual Studio 2019 Preview but saw no effect even when typing in the following C++ code:

if(false) int x = 0;

After clicking on the [Edit rules settings] button, the file “settings.json” presented in VS/19 displayed only the following text:

“sonarlint.rules”: {}

Kindly advise Thank You

Hello @BernardIE5317 and welcome to the community.

C++ analysis is triggered when a file is saved or opened. It is not run on the fly. See this wiki page for more information.

Not all rules are enabled by default. If the settings.json file doesn’t contain an entry for rule then the default enabled/disabled state for the rule is used. See here for details on how to customize the set of rules that are run.

Thank you for your reply. I saved a “cpp” file from a solution and repeated the test above with the same null result and again the “settings.json” file is as it was prior i.e. merely the brief entry shown in my original post. Also I can find no mention as to how to affect the default enabled/disabled state. Kindly advise. Cheerios

@BernardIE5317 what do you mean by “saw no effect”? Can you clarify please what were you expecting to see and where?

I assume that you refer to the rule S2583. This rule is enabled by default and you should be seeing warnings in the error list on this code.

If that is not the case, can you please open the Output Window -> SonarLint pane and provide the logs that appear when you save the file?

Greetings Kind Regards. I now noticed green squiggles under improper code and a pop-up box upon hovering apparently from SonarLint as it has a “cpp” number and a helpful message. I see no “Output Window -> SonarLint” pane or any such named controls or any logs generated upon saving the file. The “settings.json” file still only has the brief entry described earlier which concerns me. I would like to see a discussion on the SonarLint web site of each rule violation but do not know how to locate any such indexed by “cpp” rule number as I can not find any means to do so on the SonarLint web site. Cheerios

Hi Bernard,

Thanks for the UX feedback regarding your first impressions, it’s very valuable to us.

Regarding the output window: it is the built-in VS tool window, available under View -> Output. It contains a dropdown “show output from”, and SonarLint is one of the options. You can see the SonarLint logs there, with information about analysis and additional features. I’ve noted your feedback regarding the visibility of this.

Regarding the rule descriptions:

In Visual Studio, you can see the rule descriptions in 2 places:

  1. In the popup tooltip that you saw when hovering over the squiggly, the cpp rule is a link which will take you to and display a detailed rule description.
  2. In the error list, clicking on rule link will also take you there.

Alternatively, you can also visit and filter by C++ rules.

If you wish to enable a certain rule, you need to input that rule’s ID in the settings.json. To know what the id is, you need to open the rule in, and view the browser URL: it will end with RSPEC-XXX, and the XXX is the match to cpp:SXXX (note the S at the start).
I’ve passed on notes regarding this UX.

An additional way to configure the rules is by syncing your project to SonarQube or SonarCloud. This will allow you to enable/disable rules on the server and have them synchronized in your IDE. You can read about it here.

If you have any questions / suggestions, please feel free to continue this discussion. As I’ve mentioned, your feedback is valuable to us.


Output-SonarLint.txt (52.2 KB)

Greetings Thank you for your helpful advice. I found the SonarList output pane per your instruction but the output which I have uploaded here after compiling the C++ code below is not helpful to me.

int main()
	if (false) int x = 0;

The only link in the hovering pop-up is a web search for the C++ code and none for the SonarLink rule. I was successful however in finding the rule by searching the SonarLink C++ rules page for “RSPEC-XXX” per your suggestion. Thank You Cheerios

Hello again,

I apologize, the help link in the tooltip is not enabled for C++ issues. I’ve opened a github issue to handle that.

However, you can still see the link in the Error List: