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:(https://app.circleci.com/pipelines/github/usdot-fhwa-stol/carma-platform/7787/workflows/dd3d8a6c-363b-4691-8ac5-6ac09b3f5805/jobs/7991)

Docker hub image :Docker Hub

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

Regards,
Sai

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:
colcon build --cmake-args -DCMAKE_CXX_FLAGS=“${COVERAGE_FLAGS}” -DCMAKE_C_FLAGS=“${COVERAGE_FLAGS}” -DCMAKE_BUILD_TYPE=“Debug”

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 : https://app.circleci.com/pipelines/github/usdot-fhwa-stol/carma-platform/7830/workflows/ab24b03c-e276-4dd6-95af-08afe2ac0506/jobs/8034

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!

Regards,
Sai.

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 .
pwd
ls -la
mv coverage.xml ${output_dir}

here is the CI build link: https://app.circleci.com/pipelines/github/usdot-fhwa-stol/carma-platform/7853/workflows/739041bc-cbaa-41ad-8681-d4d9ca505d70/jobs/8057

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

I have updated the sonar.properties 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!

Regards,
Sai.

@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:
build/approximate_intersection/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.c
build/approximate_intersection/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp
build/arbitrator/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.c
build/arbitrator/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp
build/asn1c/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.c

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)