SonarQube Version: Data Center Edition Version 9.9 (build 65466)
Sonar Scanner Version: 4.8.0.2856
TI Compiler Version: TI ARM C/C++ Compiler v20.2.7.LTS
OS: Debian based Linux x64
I have a CMake build project, and I use the build wrapper to generate the dump of the compile commands. After which I try to use sonar scanner and get the error that JSON file was found, but 0 files were analyzed. I followed this post: Texas instruments compilers. ARMCL compiler support - #9 by Tomasz_Kaminski to make the necessary changes so the build wrapper would work. Any help would be appreciated.
if you are using CMake there is no need to use that trick to capture the compiler calls with build-wrapper. You can directly use the compilation database to configure the analysis. You just need to set CMAKE_EXPORT_COMPILE_COMMANDS=ON (CMAKE_EXPORT_COMPILE_COMMANDS — CMake 3.26.4 Documentation). You can just add set(CMAKE_EXPORT_COMPILE_COMMANDS ON) to your CMakeLists.txt and it will generate compile_commands.json file in your build directory.
You then need to set sonar.cfamily.compile-commands=path/to/build/compile_commands.json in your sonar analysis.
So I am now using the compile_commands.json file that is generated by the cmake project. I am also running the sonar scanner on x64 Windows 11 OS. I still see the same issue where no files were analyzed but the compilation database was found.
This being the exact error:
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The Compilation Database JSON file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
* you are correctly invoking the scanner with correct configuration
* your compiler is supported
* you are providing the path to the correct Compilation Database JSON
* you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:494)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:215)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:64)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
if you are still facing an issue there could be two cases:
you have a misconfiguration in your analysis properties
you are using an unsupported compiler or compiler property
In both cases, I need the log output of the sonar-scanner in verbose mode and the compilation database. Would you be able to share them if I send you a private message?