INFO: 0 compilation units analyzed

Hello,

I am doing sonar cloud analysis for my CPP project using Jenkins.

I am building this project using Conan package manager and Cmake.

I am getting 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

I used most of the posts from the community but it was no helpful to me

Hi,

Have you tried automatic analysis?

 
Ann

No, I tried only CI-based analysis.

The Actual problem as per my understanding is below:

  1. I have successfully generated compile_commands.json file using build_wrapper.
  2. compile_commands.json file has some directory path and files
  3. But the build directory is not in my Jenkins workspace

Error: you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps

Is it compulsory to require the build directory must be present in the Jenkins workspace for code analysis where the source code located?

Hi,

It is compulsory that the paths in the compile_commands.json file match the paths analysis sees.

 
HTH,
Ann

Ok great,

One more question- is the artifact we generated during the build process must required in the analysis phase?

thanks,
Sagar

Hi Sagar,

No, for C and C++ analysis the build output isn’t needed.

 
HTH,
Ann

ohh. can you explain to me the things below whats it means?

INFO: Compilation database was generated by build-wrapper 6.56
INFO: Number of compilation units in the provided Compilation Database: 28
INFO: Number of skipped unsupported compilation units: 3
INFO: Number of skipped non-indexed compilation units: 24
INFO: Number of skipped duplicate compilation units: 0
INFO: Number of remaining compilation units to be analyzed: 1

Hi,

I’d say those logs mean what they say. What are you trying to get to here?

 
Ann

Ok leave this topic, I got the solution to it.
From my side, I am mismatching the path in the build and analysis phase.

Thanks
Sagar

2 Likes