No new code is detected for coverage of a c++ project

  • SonarQube Version 6.7.6 (build 38781)
  • sonar-scanner-4.0.0.1744-windows
  • Plugin: C++ (Community) 1.3.0.1677 (cxx)

I have a problem with leak period for code coverage. Coverage itself is reported fine, but all metrics for new code coverage are equal to zero for some reason.


Here is my sonar-project.properties:

sonar.projectKey=Treat-AlignSDK
sonar.projectName=Treat (only AlignSDK, experimental)
sonar.leak.period=previous_version
sonar.language=c++
sonar.showProfiling=true
sonar.verbose=true
sonar.login=ae93c0224edd48bb705868136dd946fa6941aa92
sonar.password=
sonar.projectVersion=TRT-TMN_0.1.0.54
sonar.projectBaseDir=e:/dev/prod4/Shared
sonar.sources=.
sonar.sourceEncoding=UTF-8
sonar.cxx.coverage.reportPath=../input/bullseyecoverage-result.xml
sonar.cxx.xunit.reportPath=../input/ttsuttreat.xml
sonar.log.level=DEBUG
sonar.cxx.errorRecoveryEnabled=true
sonar.cxx.msbuild.charset=UTF-8

Here is what I do:

  1. Checkout my repo to tag TRT-TMN_0.1.0.54
  2. Put proper coverage and unit test reports to input folder
  3. Run the analysis

It runs and uploads fine, without any errors. Coverage is properly reported in Sonar. No leak period is available yet, which makes sense. Some relevant logs from the scanner:

11:14:02.822 INFO: SCM provider for this project is: git
11:14:02.823 INFO: 824 files to be analyzed
11:14:02.850 DEBUG: readpipe [git, --version],C:\Program Files\Git\cmd
11:14:02.896 DEBUG: readpipe may return 'git version 2.22.0.windows.1'
11:14:02.896 DEBUG: remaining output:

11:14:02.903 DEBUG: readpipe [git, config, --system, --edit],C:\Program Files\Git\cmd
11:14:03.057 DEBUG: readpipe may return 'C:/Program Files/Git/mingw64/etc/gitconfig'
11:14:03.058 DEBUG: remaining output:

11:14:03.116 DEBUG: Blame file sdk/Src/RendererUtils/TextureMappings.cpp
11:14:03.116 DEBUG: Blame file sdk/Src/Util/FileUtils.h
...
11:15:32.385 DEBUG: Blame file sdk/Src/SceneObj/PrimitiveMode.h
11:15:32.863 INFO: 822/824 files analyzed
11:15:32.929 INFO: 823/824 files analyzed
11:15:32.929 WARN: Missing blame information for the following files:
11:15:32.929 WARN:   * sdk/Src/RendererUtils/ShapesFwd.h
11:15:32.929 WARN: This may lead to missing/broken features in SonarQube

(I believe this error message about ShapesFwd.h is not related and should not be a problem)

Then I do the following:

  1. Checkout my repo to tag TRT-TMN_0.1.0.62
  2. Put proper coverage and unit test reports to input folder
  3. Set sonar.projectVersion to TRT-TMN_0.1.0.62 in sonar-project.properties
  4. Run the analysis

Again, it runs and uploads fine, without any errors. Coverage is properly reported in Sonar. But no leak period is available still, which is totally unexpected! Some relevant logs from the scanner:

11:21:57.019 INFO: SCM provider for this project is: git
11:21:57.020 INFO: 29 files to be analyzed
11:21:57.034 DEBUG: readpipe [git, --version],C:\Program Files\Git\cmd
11:21:57.071 DEBUG: readpipe may return 'git version 2.22.0.windows.1'
11:21:57.071 DEBUG: remaining output:

11:21:57.078 DEBUG: readpipe [git, config, --system, --edit],C:\Program Files\Git\cmd
11:21:57.146 DEBUG: readpipe may return 'C:/Program Files/Git/mingw64/etc/gitconfig'
11:21:57.146 DEBUG: remaining output:

11:21:57.179 DEBUG: Blame file sdk/Src/AlfTreatmentPlanningSdk/ExportMacros.h
11:21:57.179 DEBUG: Blame file sdk/Src/AppServices/AlignAppUI.cpp
...
11:21:58.640 DEBUG: Blame file sdk/Src/Modules/ExternalModule.h
11:21:59.515 DEBUG: Ignoring blame result since provider returned 567 blame lines but file sdk/Src/RendererUtils/ShapesFwd.h has 569 lines
11:21:59.750 INFO: 28/29 files analyzed
11:21:59.750 WARN: Missing blame information for the following files:
11:21:59.750 WARN:   * sdk/Src/RendererUtils/ShapesFwd.h
11:21:59.750 WARN: This may lead to missing/broken features in SonarQube

The scanner has correctly identified that only 29 files were changed. However, as you can see on the screenshots above, no coverage for the new code is detected. But the new tests were added, and Sonar detected it. New code was added, and it was covered with new tests. I can see how it appeared in bullseyecoverage-result.xml.

What is going on? Why I don’t see any coverage for the new code?

Hi,

The Cxx plugin isn’t supported in this venu. If you have issues with it you need to raise them in GitHub issues on that project.

 
Ann

Hi, Ann,

I will ask this on GitHub. However, the plugin was able to collect coverage successfully. That’s why I feel like the issue is with the core Sonar functionality, not with the plugin. Can you please share your thoughts?