Experiences with SonarLint in CLion with bazel

Please provide

  • Operating system: ubuntu 20.04
  • SonarLint plugin version: 8.1.0
  • Programming language you’re coding in: cC++
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): SonarQube

And a thorough description of the problem / question:

Has anyone experience how to set up SonarLint within CLion on a bazel project.
So far I was able to install the SonarLint plugin, connect to the SonarQube server and bind to a porject. When I hit the run button, nothing happens, i.e. no findings appear (which are actually listed on the server). Do I have to set some parameters? I imagine so (e.g. project root, build command…)
If yes, which ones are needed, I was not able to find any documentation on the parameters yet.

Thanks for your help.

Hello @peterpedron,

First could you enable verbose logging and share them with us ?

Hi,

I have the same issue. Apparently the “compiler” used is a wrapper, which isn’t avaible when SonarLint tries to run the analysis

This is an anonymized verbose log of a header file

Trigger: ACTION
[ACTION] 1 file(s) submitted
Configuring analysis with org.sonarlint.intellij.clion.CFamilyAnalysisConfigurator
Using connection 'MyCompanysQube' for project 'ProjectX'
Analysing 'SomeFile.hpp'...
Starting analysis with configuration:
[
  projectKey: ProjectX
  baseDir: /home/ProjectPath/.clwb
  extraProperties: {sonar.cfamily.build-wrapper-content={"version":0,"captures":[{"compiler":"clang","cwd":"/home/ProjectPath","executable":"/tmp/blaze_compiler5.sh","properties":{"isHeaderFile":"true"},"cmd":["/tmp/blaze_compiler5.sh","/home/ProjectPath/File/Path/Within/Project/SomeFile.hpp","-U_FORTIFY_SOURCE","-fstack-protector","-Wall","-Wunused-but-set-parameter","-Wno-free-nonheap-object","-fno-omit-frame-pointer","-g","-std=c++0x","-std=c++17","-fno-canonical-system-headers","-Wno-builtin-macro-redefined","-D__DATE__=\"redacted\"","-D__TIMESTAMP__=\"redacted\"","-D__TIME__=\"redacted\"","-iquote/home/ProjectPath/.",<SomeMore -iquotes for external libs>]}]}}
  moduleKey: Module: '.workspace'
  inputFiles: [
    file:///home/ProjectPath/File/Path/Within/Project/SomeFile.hpp (UTF-8) [cpp]
  ]
]

  * cpp: 432 active rules
Rule cpp:S5527 is enabled on the server, but not available in SonarLint
Rule cpp:S4830 is enabled on the server, but not available in SonarLint
  * c: 209 active rules
Rule c:S4830 is enabled on the server, but not available in SonarLint
Rule c:S5527 is enabled on the server, but not available in SonarLint
  * secrets: 7 active rules
Start analysis
Index files
Language of file 'file:///home/ProjectPath/File/Path/Within/Project/SomeFile.hpp' is set to 'C++'
1 file indexed
Execute Sensor: CFamily
Probing compiler: [/tmp/blaze_compiler5.sh, -x, c++, --std, c++17, -v, -dM, -E, -]
stdout:

stderr:
[Error] Couldn't run program "/tmp/blaze_compiler5.sh" in directory "/home/ProjectPath" because: No such file or directory

Invalid probe found, skip analysis of files: [/home/ProjectPath/File/Path/Within/Project/SomeFile.hpp]
The compiler probe 'stdout' is expected to contain at least one '#define' directive:

Subprocess(es) done in 9ms
0 compilation units analyzed
Execute Sensor: TextAndSecretsSensor
1 source file to be analyzed
1/1 source file has been analyzed
Done in 23ms

Processed 0 issues
Found 0 issues and 0 hotspots