C files are being analysed but no issues are found (3 out of 100 work fine)

  • Operating system: Windows 10 Enterprise
  • SonarLint plugin version: 4.11
  • Programming language you’re coding in: C
  • Is connected mode used: No

I’m using SonarLint to try it out for our team on a large existing C project. I have the VS code plugin installed. We compile with the Keil_v5 compiler (ArmCC). I’ve used the sonar tool to create a compile_commands.json which seems to be okay.

I’ve followed all instructions so far. I’ve inspected the verbose versions of the logs and there are no errors shown. When i make a change the analysis is triggered and says no issues found on every file.

Interestingly, on a couple of the source files sonarlint is fully working - if i type //TODO in my source (as an example) sonarlint picks up the issue immediately for those files. This seems to be an intermittent issue and at the moment i have no source files being properly analysed (they haven’t changed).

I suspect there’s an issue somewhere between the compiler / json file and sonarlint as I’ve also tried building a small C++ CMake project with Clang without issue.

Here’s the log output for a typical round of analysis - redacted for product names

[Debug - 16:17:30.251] Module file event for [uri=file:///c:/dev/REDACTED/Build.txt] has been ignored because it's not a Python file.

[Info - 16:17:30.251] Module file event for MODIFIED for file [uri=file:///c:/dev/REDACTED/Build.txt] has been ignored because it's not a Kubernetes file.

[Debug - 16:17:30.251] Computing file exclusion for uri 'file:///c:/dev/REDACTED/Build.txt'

[Debug - 16:30:18.249] Language of file "file:///c:/dev/REDACTED/Source/Torque.c" is set to "C"

[Debug - 16:30:18.249] Module file event for [uri=file:///c:/dev/REDACTED/Source/Torque.c] has been ignored because it's not a Python file.

[Info - 16:30:18.249] Module file event for MODIFIED for file [uri=file:///c:/dev/REDACTED/Source/Torque.c] has been ignored because it's not a Kubernetes file.

[Debug - 16:30:18.249] Computing file exclusion for uri 'file:///c:/dev/REDACTED/Source/Torque.c'

[Info - 16:30:18.261] Git Repository not found for c:\dev\REDACTED. The path c:\dev\REDACTED is not in a Git repository

[Debug - 16:30:18.261] Relativizing path: c:\dev\REDACTED\Source\Torque.c for git repo c:\dev\REDACTED

[Info - 16:30:18.262] Triggering analysis with configuration: [

baseDir: c:\dev\REDACTED

extraProperties: {sonar.cfamily.compile-commands=c:\dev\REDACTED\build-wrapper\compile_commands.json}

activeRules: [14 kubernetes, 214 python, 425 cpp, 189 c, 23 go, 210 ipython, 90 secrets, 26 docker, 455 java, 46 Web, 15 xml, 314 csharpsquid, 155 php, 7 terraform, 18 azureresourcemanager, 7 cloudformation]

inputFiles: [

file:///c:/dev/REDACTED/Source/Torque.c (UTF-8) [c]

]

]

[Info - 16:30:18.262] Git Repository not found for file:///c:/dev/REDACTED. The path c:\dev\REDACTED is not in a Git repository

[Debug - 16:30:18.274] Start analysis

[Info - 16:30:18.275] Index files

[Debug - 16:30:18.275] Language of file "file:///c:/dev/REDACTED/Source/Torque.c" is set to "C"

[Info - 16:30:18.276] 1 file indexed

[Debug - 16:30:18.299] 'JavaSensor' skipped because there are no related files in the current project

[Debug - 16:30:18.299] 'Python Sensor' skipped because there are no related files in the current project

[Debug - 16:30:18.299] 'IPython Notebooks Sensor' skipped because there are no related files in the current project

[Debug - 16:30:18.299] 'OmniSharp' skipped because there are no related files in the current project

[Debug - 16:30:18.299] Execute Sensor: HTML

[Debug - 16:30:18.299] 'XML Sensor' skipped because there are no related files in the current project

[Debug - 16:30:18.299] 'Code Quality and Security for Go' skipped because there are no related files in the current project

[Debug - 16:30:18.299] 'PHP sensor' skipped because there are no related files in the current project

[Debug - 16:30:18.299] 'Analyzer for "php.ini" files' skipped because there are no related files in the current project

[Debug - 16:30:18.299] 'IaC Terraform Sensor' skipped because there are no related files in the current project

[Debug - 16:30:18.299] 'IaC CloudFormation Sensor' skipped because there are no related files in the current project

[Debug - 16:30:18.299] 'IaC Kubernetes Sensor' skipped because there are no related files in the current project

[Debug - 16:30:18.299] 'IaC AzureResourceManager Sensor' skipped because there are no related files in the current project

[Debug - 16:30:18.299] Execute Sensor: Java Config Sensor

[Info - 16:30:18.299] 0 source files to be analyzed

[Info - 16:30:18.299] 0/0 source files have been analyzed

[Debug - 16:30:18.309] Execute Sensor: IaC Docker Sensor

[Info - 16:30:18.310] 0 source files to be analyzed

[Info - 16:30:18.310] 0/0 source files have been analyzed

[Debug - 16:30:18.310] Execute Sensor: CFamily

[Debug - 16:30:18.310] Cached compilation database modified time did not change

[Debug - 16:30:18.310] Time to parse Compilation Database: 0ms

[Info - 16:30:18.310] Analysis done in: 0ms

[Info - 16:30:18.310] 0 compilation units analyzed

[Debug - 16:30:18.310] Execute Sensor: TextAndSecretsSensor

[Info - 16:30:18.310] Available processors: 20

[Info - 16:30:18.310] Using 20 threads for analysis.

[Info - 16:30:18.326] The property "sonar.tests" is not set. To improve the analysis accuracy, we categorize a file as a test file if any of the following is true:

* The filename starts with "test"

* The filename contains "test." or "tests."

* Any directory in the file path is named: "doc", "docs", "test" or "tests"

* Any directory in the file path has a name ending in "test" or "tests"

[Info - 16:30:18.326] Analyzing all except non binary files

[Info - 16:30:18.326] 1 source file to be analyzed

[Info - 16:30:18.366] 1/1 source file has been analyzed

[Info - 16:30:18.366] Analysis detected 0 issues and 0 Security Hotspots in 117ms

Hello @timVarl,

Could you share the compile_command.json file with us? If you’d like to share it privately, I can start a private thread.

Thank you.

Hi Mostafa, yes no problem. Would have to do that privately as it’s got company info.

I created a ticket to track the issue, you can find it here: CPP-5846

That’s great thanks Mostafa. Just for anyone else with the same problem, I think it must be because we have our build building -i files for each translation unit for debugging purposes, this is creating two compile commands in the compile_commands.json. The one which just creates the -i file has an -E flag which seems to be causing Sonar Lint to skip analysis of that file.

1 Like