Hello,
Are there plans to add C/C++ language support the SonarLint plugin in VSCode ?
Thanks
Hello,
Are there plans to add C/C++ language support the SonarLint plugin in VSCode ?
Thanks
Hello,
We don’t plan to add C/C++ support in VSCode this year. Can’t tell yet about the next one.
Hello,
Is there any update?
Thanks
(I moved the thread to feature suggestion category so that interested people can vote for it)
Just to make everybody aware, the difficulty on our side is that our C/C++ analyzer needs to collect compilation properties (compiler flags/arguments/includes locations) to work properly.
When analyzing a project using the SonarQube scanner, we ask users to collect those informations using a build wrapper command line tool. This is not practical in SonarLint.
In SonarLint for Visual Studio, we are dynamically getting those information using Visual Studio APIs.
We haven’t started any investigation for now, but to achieve the same in VSCode, it is likely we will need to hook into the C/C++ VSCode extension. We might even depends on a collaboration with the C/C++ VSCode extension maintainers, so that they expose the informations to our extension.
I see. I think you may look into the Intellisense support (specifically the C/C++ intellisense extension), that’s the location of “semantic” data of your program.
The intellisense is populated by various extensions that provide support for code editing. For example, if you use the CMake extension, it will tell Intellisense about various compilation flags (after the code has been built) so code navigation/completion is correct. You can reuse this information in SonarLint.
How about the C++ Eclipse integration? That has no Visual Studio APIs either. So could that not be a starting point?
Personally I do not mind adding them manually in a special setting/property. I have multiple tasks each having different build options.
This could be a good start, and at a later stage this could be automated (optionally). In my opinion and experience automated systems always make the wrong decision ;-).
Hi @Juno,
what do you mean with this question? FYI, C++ for SonarLint on Eclipse CDT is already available.
In Eclipse, we are relying on Eclipse CDT APIs to collect the information we need:
I gave a quick look at the vscode-cpp extension, and I couldn’t find an API to read the effective project configuration. There is an API but only to provide the configuration:
I initiated a feature request on VSCode Cpptools side to have an API usable by our C/C++ analyzer. If you are waiting for SonarLint C/C++ support in VSCode, feel free to vote for it:
Sorry for my late reply.
Personally it is fine if I have to enter the values using a project setting/configuration. A colleague does for Eclipse.
Or rely on the “C/C++ IntelliSense, debugging, and code browsing.” extension. It also analyses the source files for coloring and jumping to definitions.
But probably this is already considered…
Thanx.
Hi,
Does it mean that Sonarlint for C/C++ will rely on cpptools extension? What about developers using clangd or other language servers instead of cpptools? Will SonarLint work for them?
Thanks
Hello, thank you for raising this point.
Our assumption here is that most C and C++ developers in VSCode use the cpptools extension, which looks like a kind of “standard”.
In a perfect world, we would have infinite bandwidth and we would strive to support all possible use cases - and in this reality, we have to choose which use cases to support first especially when the landscape is fragmented.
In this case and according to marketplace numbers, cpptools has 12 million downloads, to the 72k of clangd; so from an adoption point of view, it looks fairly straightforward to target the cpptools user base first, and to eventually address other demographics.
Any update on when this might be available?
Hi,
Instead of waiting for a new feature in the VSCode Cpptools extension, what about using the compilation database available in file compile_commands.json ?
It’s a single file, and its format is specified in the Clang documentation.
But Clang is NOT required, as it can be generated by many build systems :
Nowadays, the compile_commands.json compilation database is supported by most C++ IDEs.
Even Microsoft Visual Studio Code C/C++ extension tries to detect the file compile_commands.json, then uses it to improve search performance.
If SonarLite relies on the compile_commands.json compilation database to collect the compilation properties (compiler flags/arguments/includes locations), then it will be able to run indepently in many environments.
Not only VSCode.
The work should be small, as the compile_commands.json is a single JSON file.
Here is a related request, but for sonar scanner :
CPP-1428 : Add support for JSON compilation database
C++ and cmake: Running sonar scanner on compile_commands.json
Hello @cyril.og, welcome to the SonarSource community, and thanks for the suggestion!
Using the compile_commands.json looks indeed an interesting alternative, although there a few points to be sorted out (e.g. the user will need specific tools to generate the compilation database file, especially for non-CMake projects). We are currently starting to re-adjust our priorities for 2021, and C/C++ support for VSCode is something we want to have a look at, but I cannot guarantee that we will manage to include it in our 2021 roadmap. In case, we will definitely have a closer look to compilation database as an alternative way to gather necessary compilation properties.
Hi @Marco_Comi,
I hope you’ll manage to include C/C++ support through the compilation database (i.e. file compile_commands.json) in your 2021 roadmap.
In my non-expert eyes, the effort may be small (since it only implies parsing a single JSON file), and it may be shared to offer the same support to other products than SonarLint.
For example, @Geoffray confirmed me here that sonar scanner can already use the compile_commands.json compilation database, through this not officially supported python script attached to CPP-1428 : Add support for JSON compilation database.
But that’s only my naive point of view : you are the experts, not me !
Cheers,
Cyril.
I am looking forward to progress on this. Thanks Cyril for this input.
Hi @Marco_Comi, please tell me if you re-adjusted your priorities for 2021 to include C/C++ support for VSCode.
Depending on the answer, we may postpone a switch from SonarQube to Coverity at company level.
Hello @cyril.og, reaching out to more C++ developers is one of our 2021 priorities for SonarLint, and we believe that adding support for VSCode will greatly contribute (we have already quite a few users demanding for it); nevertheless I cannot guarantee that VSCode will be supported by the end of the year, as we are evaluating plenty of other features (for example supporting JetBrains CLion, improving support in Visual Studio). You can expect this thread to be updated by us when there will be some concrete advancement on the topic; in the meantime, you are welcome to discuss your request more in details by reaching out to contact@sonarsource.com (make sure you mention your company name there so that we can involve your account manager).