SonarLint static analysis for C for VS2019

I am working with VS2019 and SonarLint extension 7.2.0.76209, Windows 10.
When I run on a project “Analyze and Code cleanup” - only VS2019 static analysis is executed. But SonarLint - no. Also settings.json is empty.
If I run the same on a file - only SonarLint performs the analysis. It can be seen in Tool column of Error List view.
What shall I do to have both to run on project and file?
How can I populate file settings.json ?

Hi,

Welcome to the community!

Could you upgrade to the current version, 7.5.0.82292, and see if this is still replicable?

 
Thx,
Ann

Dear Ann!
Thank you for your reply and we are on the way to install and check newest version. I will inform once done.
Meanwhile tell me please if SonarLint installation is self-contained (default rules are inside) or it has to have Internet to access the rules.

Dear Ann!
As recommended we tested it with the latest version 7.5.0.82292 and the result is the same.
Appreciate your advice,
Best,
Yuri

Hi,

Sorry for the delay; we were at our annual company off-site.

Yes, SonarLint is self-contained. If you’re not in connected mode you should get the default rule set applied automatically. Thanks for trying the upgrade. Since it didn’t work, I’m going to refer this internally.

 
Ann

Ann - thank you for your reply.
We shall wait for your instructions how to resolve the issue.
Best regards,
Yuri

1 Like

Hello @yurip !

Could you please provide the language(s) you’re analyzing? In general, we don’t support the integration with the “Analyze and Code cleanup”. SonarLint should work according to your Roslyn settings (Tools > Options > Text Editor > C# > Advanced > Background Analysis Scope) for C# and VB.NET and on File Save + File Open for other languages we support (CFamily, JS, etc.).

settings.json file is used to override settings in standalone mode. You can find more information here https://docs.sonarsource.com/sonarlint/visual-studio/using-sonarlint/rules/#languagespecific-configuration

Hello Georgii!
We are using language C. “Analyze and Code cleanup” is the main option to run static analysis in Visual Studio. Alternatively, it is possible to run static analysis like this: Analyze ->Run Code Analysis->Run Code Analysis on Project/Solution. But both options produce the same result.
Regarding settings.json file - ok,clear.

@yurip In the case of C language, SonarLint for VS analyses files on Open and on Save. Do you not see that happening? If so, there might be an issue that prevents our analysis from running. To investigate that we would need logs from you.

To enable verbose logging: Extensions > SonarLint > Options > Logging level
To open logs: Extensions > SonarLint > Help > Show Logs