SonarLint for Visual Studio: v4.38 - Support CMake projects

Hello Visual Studio users,

I am excited to announce this new version of SonarLint :sonarlint: for Visual Studio, that is loaded with great new features for both C, C++ and .NET developers!

If you are a C or C++ developer using Visual Studio to develop cross-platform applications, or if your projects use open-source libraries, or if for any other reason you prefer CMake to the native Visual Studio projects for C++, then you will appreciate that we are launching the support for CMake projects :partying_face:
In order to benefit from it you need to update your SonarLint to the latest version, and also ensure that:

  • you are using Visual Studio 2017 or 2019
  • you are using MSVC to compile your project
  • you configured CMake to export the compilation commands; in facts those commands are needed by our analyzers to correctly report issues in your code. To do that, you just need to ensure that the variable CMAKE_EXPORT_COMPILE_COMMANDS is set to ON (you can refer to: CMAKE_EXPORT_COMPILE_COMMANDS — CMake 3.21.3 Documentation).

And even if you don’t use CMake, this new SonarLint version will greatly improve the detection of issues in your code:

  • We improved the symbolic execution engine to drastically reduce issues found in infeasible execution paths
  • We added 4 new bugs and code smells rules for C++ 20

If you are a C# developer, you will benefit of many new rules covering several C# 9 features:

  • native sized integers
  • module initializers
  • partial methods
  • target typed conditional expressions
  • Lambda discard parameters
  • Attributes on local functions
  • Static lambdas
  • Function pointers.

You can read more in our release notes if you wish. Once you get a chance to try the latest version, don’t hesitate to leave us your feedback.

1 Like