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
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
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:
In the popup tooltip that you saw when hovering over the squiggly, the cpp rule is a link which will take you to rules.sonarsource.com and display a detailed rule description.
In the error list, clicking on rule link will also take you there.
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 rules.sonarsource.com, 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.
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