Code Coverage is showing 0% in sonar cloud projects

Hello team,

I would like to reach out to community again regarding the sonar scan analysis for Carma-Platform, there are gcov files but it is not moving to output directory which was working previously. Could you please help me with what I’m missing here. Thank you!

Here is the link to the previous conversation I had (Code Coverage is showing 0% in sonar cloud)
Here my test branch circle CI build:(

Docker hub image :Docker Hub

Please let me know if you need any other information. Thanks!


Hey there.

It looks like SonarCloud is still behaving as expected – parsing the .gcov files that it has access to. I would suggest reviewing the script that generates/moves these files, as @necto suggested before.

Specifically you probably want to look at what changed between November 3rd (when coverage was still reported) and December 14th.

Once the coverage files are in the right place, SonarCloud should do its job and read them. Up to that point – SonarCloud isn’t involved.

Hi Colin,
sorry of the late response, I don’t see any major changes except the below CI jobs restrict changes, I was trying to update the Gcov version to 5.0 and see if it publishes any reports to sonar cloud.
File changed on NOV 1st 2021(make_with_coverage.bash):
from this:

to this:

colcon build --parallel-workers 2 --cmake-args -DCMAKE_CXX_FLAGS=“${COVERAGE_FLAGS}” -DCMAKE_C_FLAGS=“${COVERAGE_FLAGS}” -DCMAKE_BUILD_TYPE=“Debug”

Github Link: Restrict job count for CI · usdot-fhwa-stol/carma-base@14658f8 · GitHub

I do have additional question in our build step I see the GCC Code Coverage Report details with 0% of cover and missing lines. Not sure if this is causing the issue.

Ci build :

Also, I see below error in run c++ test step seems like the script is running anyway
/home/carma/.ci-image/engineering_tools/code_coverage/make_with_coverage.bash: line 59: [: missing `]. Any inputs would help me here. Thanks!

Please let me know if you need any other information. Thank you!


Hey there.

At the end of the day, the scanner is only finding two coverage files.

INFO: Parsing /opt/carma/coverage_reports/gcov/CMakeCCompilerId.c.gcov
WARN: File not analysed by Sonar, so ignoring coverage: /opt/carma/src/CARMAPlatform/platooning_strategic/CMakeCCompilerId.c
INFO: Parsing /opt/carma/coverage_reports/gcov/CMakeCXXCompilerId.cpp.gcov
WARN: File not analysed by Sonar, so ignoring coverage: /opt/carma/src/CARMAPlatform/platooning_strategic/CMakeCXXCompilerId.cpp
INFO: Sensor gcov [cpp] (done) | time=1ms

You’ll have to find out why the other files aren’t in /opt/carma/coverage_reports/gcov/ – and we (Sonar) won’t be able to help you adjust your script. If you still face coverage issues once that folder is properly populated, we’ll be happy to help.

Hi Colin,

I went back and gone through the github history for the changes between Nov 3rd to Dec 15th there was no major changes to collect_gcovr.bash file but there are few changes in make_with_coverage.bash file to build our source code for ROS2, we tried changing few things and still the gcov files were not moving to output directory. I would like to change to generate the reports in XML formate I used the below command to execute in our current directory and directly move to output directory.

gcovr --sonarqube coverage.xml -k -r .
ls -la
mv coverage.xml ${output_dir}

here is the CI build link:

here is GitHub link: carma-platform/ at fix/sonar_cloud · usdot-fhwa-stol/carma-platform · GitHub

I have updated the with below path but I don’t see any coverage sonar.coverageReportPaths=/opt/carma/coverage_reports/gcov/coverage.xml

Could you please help me here if I’m missing anything. Thank you so much!


@Colin Did you get a chance to see my previous comment? Any inputs from you would be very helpful. Thanks!

Hey there.

INFO: Parsing /opt/carma/coverage_reports/gcov/coverage.xml
INFO: Imported coverage data for 0 files
INFO: Coverage data ignored for 4995 unknown files, including:

It looks like SonarCloud is having trouble with the paths in the generated report. Since gcovr/gcovr maintains the SonarQube reporter, you might want to raise an issue on their GitHub repository.

And, before changing your coverage strategy, it really seems like making sure files are moved to the appropriate directory is a solvable problem (and doesn’t involve SonarCloud at all).

SonarCloud is just reading reports, it’s not involved in producing them – and that’s about as much support as this community can provide.

Sure, Thanks! for the Input.

Hi @Colin,

Hope you are doing great!

we have updated the coverage scripts and few of the projects are able to generate the reports in sonarcloud but few of them are failing at sonar scanner step in CI, Here is the new ticket I have created could you please help me here. Thanks!

Here is new ticket I have created ( "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed by scanner)