SonarLint On-the-Fly analysis of C++ only works with SOME projects

Using VS 2019 and the latest version of SonarLint.

We were putting your analysis tool to the test and built a project just to test out the tools functionality - so we have a library with functions that will cause various common runtime errors called RuntimeCrashing.

RuntimeCrashing - OnTheFly analysis of C++ code:

RuntimeCrashing - Analysis Results:

SonarLint is working as expected in our RuntimeCrashing project. Which is great. However, we tried it out with our existing project and we aren’t seeing any of the functionality that we saw in the other project.

We have no flags while we write ‘bad’ code and the analysis isn’t showing anything that the compiler doesn’t already show us. What settings/properties might we have to play with to get this functioning properly in our actual project? (Unfortunately I cannot share company code, so I cant add in screenshots of it)

@Ty-Guy welcome to the community, and thank you for trying out SonarLint.

Have a look in the SonarLint pane of the Output Window. The output should give some indication of why the files are not being analysed. You can increased the verbosity of the output from the ToolsOptionsSonarLint page (and if you need really verbose output you can set the environment variable SONARLINT_INTERNAL_LOG_DEBUG=true then restart VS).

Also, have a look at the wiki for more information about which C++ project types are supported.

1 Like

Hey there Duncan,

So, it seems that SonarLint does not want to play nicely with our project - perhaps, because of our SDK.

We are getting output as such:

Loading notifications settings…
[CFamily Analysis] Error retrieving VCX configuration. File: C:\Users\twright\Documents\Projects\WhiteKing\Feature\Mocking\Source\Motion\Servo\CopleyServo.cpp, Error: System.ArgumentException: Unsupported PlatformToolset: CE800
Parameter name: platformToolset
at SonarLint.VisualStudio.Integration.Vsix.CFamily.VcxProject.FileConfig.GetCompilerVersion(String platformToolset, String vcToolsVersion)
at SonarLint.VisualStudio.Integration.Vsix.CFamily.VcxProject.FileConfig.TryGet(ILogger logger, ProjectItem dteProjectItem, String absoluteFilePath)
at SonarLint.VisualStudio.Integration.Vsix.CFamily.VcxProject.FileConfigProvider.Get(ProjectItem projectItem, String analyzedFilePath, CFamilyAnalyzerOptions analyzerOptions)
Unable to retrieve the configuration for file ‘C:\Users\twright\Documents\Projects\WhiteKing\Feature\Mocking\Source\Motion\Servo\CopleyServo.cpp’.
Check the file is part of a supported project type in the current solution.
Saving notifications settings…

from the SonarLint output window. Our target platform is Windows Embedded 8. Is there a known workaround for getting SonarLint to play nice with embedded?

Hello @Ty-Guy,

Unfortunately, in SonarLint for Visual Studio, the only toolset that we support is the Visual Studio toolset with the MSVC compiler.
Can you provide more information about this toolset? What compiler are you using to compile for that platform?

Thanks,

Hey there Abbas. So we are making use of the standard MSVC compiler, the toolkit provided by Toradex mostly includes a project builder to get developers started on their projects without having to build and link the header files required to build an application that runs on their hardware. It lets us build applications with libraries for GPIO, WIN32, etc. header files linked to the projects upon creation. It is my understanding that the Toradex_CE800 toolkit is not doing anything different from the standard VS toolkit in terms of building, or compiling of the project (if we were to add the windows embedded libraries and Toradex libraries ourselves).