0 C/C++/Objective-C files were analyzed

Hi guys. As a devops i have problem with one of C++ projects. I cant publish here actual filenames and paths because they contain confidential information. But i will publish at least some basic stuff to give you a picture how all works.

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Sonar Version 8.0 (build 29455)
    SonarQube Scanner 4.2.0.1873
    CMake 3.15.2
    Jenkins 2.190.3
    Windows 10 agent

  • what are you trying to achieve
    Directory structure (simplified):
    PROJECT/ - directory where project is cloned.
    BUILD/PRODUCT - temporary directry which is deleted in each iteration. There SDK environment is generated there.

The build process is based on these steps

  1. Generate SDK enviroment in BUILD/PRODUCT directory by copying some stuff from PROJECT directory
  2. Run the build command (with wrapper) in BUILD/PRODUCT/BIN directory and build_wrapper is generated in PROJECT/build_wrapper directory
  3. Run scan in BUILD/PRODUCT/BIN/SRC directory

This worked ok. We had no issue with that.

Now because we are limited with lines of code we cant scan whole SRC directory. Also filtering things in SRC directory is not an option because they are scattered too much. The best way is to scan them in place from which they are copied -> PROJECT/. So i set

PROJECT/DIR1
PROJECT/DIR2
PROJECT/DIR3
in sonar.sources. And now im getting

INFO: 0 compilation units analyzed
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 14.192s
INFO: Final Memory: 27M/458M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
  * you are using the latest version of the build-wrapper and the SonarCFamily analyzer
  * you are correctly invoking the scanner with correct configuration  * your compiler is supported
  * you are wrapping your build correctly
  * you are wrapping a full/clean build
  * you are providing the path to the correct build-wrapper output directory
	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:247)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:62)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:387)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:383)
	at org.sonar.scanner.scn.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:346)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	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:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
script returned exit code 1
  • what have you tried so far
  • setting sonar.projectBaseDir = PROJECT/
  • copying sonar.properties file to BUILD/PRODUCT/BIN and copying manually DIRx to some subfolder and run scanning from there
  • deleting sonar cache in user dir, deleting project in SonarQube
  • disabling gitignores

Hi @Dominik_Panas,

You must analyze the same files you build, there is a tight link to absolute paths.

If you are not able to solve the issue, would you be able to share the scanner log and build-wrapper output folder if I send you a PM?