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).

Hi @Ty-Guy,

Thanks for the explanation! Feel free to create a post to suggest a new feature category. Currently, we have no plan to support it.

Thanks,

Hello SonarSource community, We are just bumping this thread because:

Our team has resolved the issues we were having(described above). We needed to create a solution configuration (using the configuration manager) that targeted a x64 platform. For us this meant creating a ‘Mixed’ ‘Active solution platform’. For which the projects in our solution that we want SonarLint to analyze on the fly, have to have a ‘new’ x64 platform set that does not copy settings from other platforms. Once this configuration has been set up, we get no issues using SonarLint’s features. :slight_smile:

Hey abbas! Sorry to re-open the discussion, I just wanted to bump this thread because I wanted to make sure that our solution to our problem is made public - We managed to get SonarLint working with our projects, only configuring VS. I replied to myself in this thread – the steps we took to get there.

Just wanted to make sure the info is out there and that anybody looking for it is able to find it :slight_smile:

@Ty-Guy, glad it worked, and thanks for sharing the workaround!

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