Whether the vscode sonarlint plugin is adapted to analyze C/C++ code in Ubuntu

Please provide

  • Operating system: Ubuntu
  • IDE name and flavor/env: vscode
  • SonarLint plugin version: 3.4.1
  • Is connected mode used: no
    • Connected to SonarCloud or SonarQube (and which version):

And a thorough description of the problem / question:
Whether the vscode sonarlint plugin is adapted to analyze C/C++ code in Ubuntu?

Hello, thanks for your question.

Yes, recent versions of SonarLint for VSCode (3.4+) support analysis of C and C++ code. Please check the documentation on the wiki to get started with analysis of C and C++ code.

My question is whether using Vscode to write C/C++ code under the Ubuntu operating system can use the sonarlint plugin to analyze the C/C++ code written.
Also, I automatically generated compile_ commands.json file before I asked the question. However, the code cannot be parsed under the Ubuntu operating system. C/C++ code can be analyzed on windows operating systems.

My question is whether using Vscode to write C/C++ code under the Ubuntu operating system can use the sonarlint plugin to analyze the C/C++ code written.
Also, I automatically generated compile_ commands.json file before I asked the question. However, the code cannot be parsed under the Ubuntu operating system. C/C++ code can be analyzed on windows operating systems

I’m not sure I fully understand your question, sorry.

In your other thread, it seems that you were using VSCode on Windows to connect to a Linux remote. If it is still the case, I suggest that we continue the discussion on the other thread to try to understand what is going on.

Otherwise, I don’t see any a priori issue with analyzing C and C++ code with SonarLint for VSCode on Ubuntu, except maybe if you are running Ubuntu on an architecture not supported by the C/C++ analyzer (e.g, ARM).

Would it be possible for you to share your compile_commands.json, as well as the contents of the SonarLint Output in VSCode?

Thanks!

[
 {
  "directory": "/home/hsm/src",
  "arguments": [
   "gcc",
   "hello.c",
   "-o",
   "hello"
  ],
  "file": "hello.c"
 }
]
[Info  - 01:16:34.495] Started security hotspot handler on port 64120
Initializing file:///home/hsm on branch undefined
[Info  - 01:16:34.684] Analyzing file 'file:///home/hsm/.vscode/launch.json'...
[Warn  - 01:16:35.004] Plugin 'secrets' embeds dependencies. This will be deprecated soon. Plugin should be updated.
[Info  - 01:16:37.600] Index files
[Info  - 01:16:37.609] 1 file indexed
[Info  - 01:16:37.951] Found 0 issues
[Info  - 01:16:38.007] Analyzing file 'file:///home/hsm/.vscode/c_cpp_properties.json'...
[Info  - 01:16:38.027] Index files
[Info  - 01:16:38.027] 1 file indexed
[Info  - 01:16:38.049] Found 0 issues
[Info  - 01:16:41.763] Analyzing file 'file:///home/hsm/src/Makefile'...
[Info  - 01:16:41.773] Index files
[Info  - 01:16:41.774] 1 file indexed
[Info  - 01:16:41.790] Found 0 issues
[Info  - 01:16:44.002] Analyzing file 'file:///home/hsm/.vscode/settings.json'...
[Info  - 01:16:44.015] Index files
[Info  - 01:16:44.015] 1 file indexed
[Info  - 01:16:44.035] Found 0 issues
[Info  - 01:16:48.813] Analyzing file 'file:///home/hsm/.vscode/compile_commands.json'...
[Info  - 01:16:48.824] Index files
[Info  - 01:16:48.825] 1 file indexed
[Info  - 01:16:48.842] Found 0 issues
[Info  - 01:17:35.146] Analyzing file 'file:///home/hsm/src/hello.c'...
[Info  - 01:17:35.155] Index files
[Info  - 01:17:35.155] 1 file indexed
[Info  - 01:17:38.208] Parsing compilation database /home/hsm/.vscode/compile_commands.json
[Info  - 01:17:38.242] Skip analysis of file: /home/hsm/src/hello.c
[Info  - 01:17:38.243] Subprocess(es) done in 60ms
[Info  - 01:17:38.243] 0 compilation units analyzed
[Info  - 01:17:38.262] Found 0 issues
[Info  - 01:17:47.423] Analyzing file 'file:///home/hsm/.vscode/settings.json'...
[Info  - 01:17:47.434] Index files
[Info  - 01:17:47.434] 1 file indexed
[Info  - 01:17:47.451] Found 0 issues
{
    "sonarlint.pathToCompileCommands": "/home/hsm/.vscode/compile_commands.json"
}

Hello, thank you for the detailed info!

I did not manage to reproduce with the same setup on Ubuntu 20.04.

Could you please set sonarlint.output.showVerboseLogs to true in your user settings, re-analyze the file and post the SonarLint output? I believe we could get additional info from this.

Jean-Baptiste Lievremont via Sonar Community <notifications@sscommunity.discoursemail.com>于2022年5月25日 周三15:40写道:

Try this out: SonarLint for C/C++ with Makefile support on VS-Code | Medium