SonarLint variable compile_commands.json location

Hi,

I want to use the SonarLint plug-in for VS Code. In the settings.json file I need to set the path of the compile_commands.json file via the sonarlint.pathToCompileCommands option.

The thing is that this path is not fixed. It can happen that I have more than one cmake project in my repo or the name of the cmake build directory may depend on something like the build type (debug, release etc.).

According to VS Code’s variables reference I should be able to do this either via config: or command: variables. The cmake extension seems to support commands as well.

  "cmake.sourceDirectory": "/path/to/cmake/project",
  "cmake.buildDirectory": "${sourceDirectory}/build-${buildType}",

  // config variable
  "sonarlint.pathToCompileCommands": "${config::cmake.buildDirectory}/compile_commands.json",

  // command variable
  "sonarlint.pathToCompileCommands": "${command::cmake.buildDirectory}/compile_commands.json"

But none of them works.

Hi,

Could you confirm that you’re using the latest version of SonarLint for VSCode?

 
Thx,
Ann

Hello Ann,

I am using version 3.19.2.

Regards
Jan

1 Like

I have kind of the same problem with the sonarlint.connectedMode.project.projectKey setting once I want to set up connected mode. This also applies to other languages.
Why doesn’t SonarLint just read the sonar-project.properties files I already created for sonar-scanner. I would abandon Sonarlint completely and just run sonar-scanner via some generic linter extension, if it wasn’t that slow compared to SonarLint.

Hi Jan,

I’ve flagged this for the team.

 
Ann

Hello @jan.schatz ,

Thank you for raising the request to support variable substitutions.

At the moment, SonarLint doesn’t support this functionality and it has been recorded as an opportunity on our side. Supporting variable substitutions for Sonarlin may come in the future but is not a short-term priority for now.

Best,

Vojtech from :sonarlint:

1 Like

Hello @vojtech.suchy ,

thank you for your feedback.
What about SonarLint using the sonar-project.properties files?

Best regards
Jan

Hi @jan.schatz ,

If a folder contains sonar-project.properties file then Sonarlint will automatically try to configure binding with a remote project. Please see the project binding documentation for details.

Best,

Vojtech from :sonarlint:

1 Like