MacOS Sonar-Scanner error: Compilation DB was found but 0 C/C++/Objective-C files were analyzed

I’m using Sonar-Cloud for C++ code static analysis of my open-source project Methane Kit for several years already as a part of GitHub Actions CI system. CI Sonar Scan workflow runs separately for Windows, Linux and MacOS to cover platform and API dependent code and submit results to platform-dependent projects on Sonar-Cloud. CI Code Scan was working fine 3 weeks ago on all platforms, then it did not run for several weeks due to blocking code issue, but when code was fixed I’ve noticed that sonar-scanner started failing on MacOS with error “java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed”, while it was working fine for other platforms (Windows and Linux). According to the error message I though that the problem was caused by build-wrapper issue somehow related to changes in build environment, like updated Xcode version, so I decided to switch from build-wrapper approach to compilation database generated by CMake with Ninja generator. Surprisingly, after changing workflow to generate and use compilation database for sonar-scanner, I received similar error on MacOS “java.lang.IllegalStateException: The Compilation Database JSON file was found but 0 C/C++/Objective-C files were analyzed”, while scans on Windows and Linux were working fine. Could you please help me to find a root cause of this issue and may be propose a solution to fix it?

Command line

sonar-scanner -X --define --define sonar.organization=methane-powered --define sonar.projectKey=methane-powered-kit-macos --define sonar.projectVersion= --define sonar.cfamily.compile-commands=Build/Output/Ninja-Mac-MTL-Scan/Build/compile_commands.json --define sonar.testExecutionReportPaths=Build/Output/Ninja-Mac-MTL-Scan/Install/Tests/Results/MethaneDataTypesTest.xml,Build/Output/Ninja-Mac-MTL-Scan/Install/Tests/Results/MethaneDataEventsTest.xml,Build/Output/Ninja-Mac-MTL-Scan/Install/Tests/Results/MethaneDataRangeSetTest.xml,Build/Output/Ninja-Mac-MTL-Scan/Install/Tests/Results/MethanePlatformInputTest.xml,Build/Output/Ninja-Mac-MTL-Scan/Install/Tests/Results/MethaneGraphicsTypesTest.xml,Build/Output/Ninja-Mac-MTL-Scan/Install/Tests/Results/MethaneGraphicsCameraTest.xml,Build/Output/Ninja-Mac-MTL-Scan/Install/Tests/Results/MethaneUserInterfaceTypesTest.xml --define sonar.coverageReportPaths=Build/Output/Ninja-Mac-MTL-Scan/Install/Tests/Coverage/Report/SonarQube.xml --define sonar.scm.revision=628ec12a83ca28241aa60c6f693e06a56c1218fd

# Sonar Cloud projects common scanner configuration properties

sonar.cloudName='Methane Powered Graphics'



compile_commands.json (2.6 MB)

SonarScan.log (1.1 MB) with error

17:51:21.313 INFO: 95/644 files marked as unchanged
17:51:21.313 INFO: 13/22 test files marked as unchanged
17:51:21.314 INFO: Cache: 0/0 hits, 125 bytes
17:51:21.314 INFO: 0 compilation units analyzed
17:51:21.366 INFO: ------------------------------------------------------------------------
17:51:21.367 INFO: ------------------------------------------------------------------------
17:51:21.367 INFO: Total time: 37.849s
17:51:21.458 INFO: Final Memory: 39M/134M
17:51:21.458 INFO: ------------------------------------------------------------------------
17:51:21.458 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(
	at com.sonar.cpp.plugin.CFamilySensor.execute(
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.scanner.scan.ProjectScanContainer.scan(
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.batch.bootstrapper.Batch.doExecute(
	at org.sonar.batch.bootstrapper.Batch.execute(
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(
	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(
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(
	at org.sonarsource.scanner.cli.Main.execute(
	at org.sonarsource.scanner.cli.Main.execute(
	at org.sonarsource.scanner.cli.Main.main(

Build.log (143.6 KB) proves that code builds successfully.

Other details can be found in GitHub Actions run output and zipped build artifacts.

Hi @egorodet ,

thank you for the detailed report, very useful!

The reason why 0 files are analyzed is that objective-c++ is not supported and files are skipped. All the files in the compile_commands.json have -x objective-c++ and you set OBJCXX language only on macOS. Are you really using Objective-C++?

Yes, you’re right. I root-caused this issue myself yesterday and set objective-c++ flag only for *.mm source files which are actually using it. As the result, other C++ files were normally analyzed. I’m using Obj-C++ for C++ class wrappers implementation around Obj-C Metal API. Do I correctly understand that Objective-C language is supported, but Objective-C++ is not?

@mpaladin Byt the way, is there any chance Objective-C++ would be supported by Sonar Cloud for static analysis? It looks to me like a combination of C++ and Objective-C code checks that need to be run for Objective-C++ source files. Or is it more complex than that?

Hi @egorodet,

Yes, you are right.

Even if it is mostly a combination of C++ and Objective-C, it would still require some work to support it, and we have not had a lot of requests for that.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.