Allow extension integration in VS Code

Please provide

  • Operating system: any
  • SonarLint plugin version: 3.18.0
  • Programming language you’re coding in: C/C++
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version):

And a thorough description of the problem / question:

My team is working on an extension that manages a development environment in VS Code where several (C/C++) application with multiple build configurations coexists at the same time, all of which have it’s own compile_commands.json file. This means that IntelliSense and linting configurations are dynamically changing within a VS Code workspace and our extension is aware of which build configuration is active at all times.

We would like to integrate with the SonarLint extension in way that does not require user interaction in case there are multiple compile_commands.json file is found in the workspace, so we could call the command automatically upon the active configuration changes.

For this change I already created a PR: Add optional argument to configure command by bencefr · Pull Request #423 · SonarSource/sonarlint-vscode · GitHub

Br,
Bence

Hello @bencefr and welcome to the community.

Thank you for your PR and explanation.
We will review the PR and discuss internally how it aligned with our plans. I can’t promise a fast decision, unfortunately. But I’ll keep you posted about progress here in this topic.

Thank you very much!

Hello @bencefr.

We don’t think there is a need to merge this PR.
You can achieve the dynamic change of the compilation database configuration using two approaches:

  1. If you are sure you need to create/use another file(s) and you want to switch SonarLint C/C++ analyzer to a new config file:
    There is a property for the file projectPath/.vscode/settings.json. The property’s name is sonarlint.pathToCompileCommands. The value should be an absolute path to the compilation database. Once you set/changed it, the new configuration will be picked up by the analyzer on the next analysis.
  2. If you just need to provide a new configuration and don’t really need to use other files - you can directly change the content of configured compile_commands.json file. And changes also will be picked up by the analyzer on the next analysis.

I hope it helps. Have a good day!

1 Like

Thank you for your answer, I’ll proceed with integration this way.

1 Like