9.7.1 (build 62043)
SonarQube deployed: zip
- what are you trying to achieve
I try to get a higher score of code coverage. I have C++ project, wheremake coverage
show 73% coverage, then convert results in dir_coverage
withgcov
and run
sonar-scanner -Dsonar.cfamily.build-wrapper-output=_$BUILD_TYPE/.sonar --define sonar.cfamily.gcov.reportsPath="_coverage" --define sonar.branch.name=$CI_COMMIT_BRANCH \
--define sonar.coverage.exclusions="app/**, /root/.hunter/_Base/17fd3b9/f845a29/f96017a/Install/include/boost/**/*.*, include/**, boost/**/*.*"
and sonarqube report shows 53% coverage.
I find this is because some files include Boost
library files and sonar includes them in analysis.
for example log from make coverage
#17 0.197 ------------------------------------------------------------------------------
#17 0.197 GCC Code Coverage Report
#17 0.197 Directory: .
#17 0.197 ------------------------------------------------------------------------------
#17 0.197 File Lines Exec Cover Missing
#17 0.197 ------------------------------------------------------------------------------
#17 0.197 libs/database/cursor.hpp 15 13 86% 29,57
and sonarqube log
761 NuPay
libs/database/cursor.hpp
Lines147
Coverage 80.0%
Bug 0
Vulnerability 0
Code Smell 13
Security Hotspot 0
But I exclude them higher.
What’s wrong?
here is log from sonarqube
The analyzer was not able to find file
#20 48.33 boost/endian/conversion.hpp
#20 48.33 included from file /builds/libs/database/cursor.hpp
#20 48.33 included from file /builds/libs/database/cursor.cpp
#20 48.33
#20 48.33 This impacts the quality of the analysis and leads to inaccurate results.
#20 48.33
#20 48.33 Please check that the file exists on your machine during the analysis:
#20 48.33
#20 48.33 * if it doesn't, find a way to persist it after your build;
#20 48.33 all the files accessed during the build should be accessible during the analysis
#20 48.33
#20 48.33 * if it does, please contact SonarSource support providing
#20 48.33 the full path to the file
#20 48.33 boost/endian/conversion.hpp
#20 48.33 and the file
#20 48.33 /builds/sonar-cfamily-reproducer.zip
#20 48.33
#20 48.33 INFO: SE: 16 out of 154
#20 48.33 INFO: Z3 refutation rate: 0 out of 0
#20 48.33 WARN:
Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!