Project Overview showing 0% coverage but correct in branch comparison

  • ALM Azure DevOps
  • CI system used Azure DevOps
  • Repro language C# (Xamarin iOS and Android project)
  • Steps to reproduce
  • Potential workaround

SonarCloudAnalyze statement is

- task: SonarCloudPrepare@1
  inputs:
    SonarCloud: 'Sonarcloud Connection'
    organization: 'ourorg'
    scannerMode: 'MSBuild'
    projectKey: 'Us_App'
    projectName: 'App'
    extraProperties: |
        sonar.cs.opencover.reportsPaths=$(Common.TestResultsDirectory)\*.opencover.xml
        sonar.coverage.exclusions=**\App.Devices.Mir.Droid\*.cs,**\Views\**\*.cs,**\App.Devices.Mir.Fake\*.cs
        sonar.verbose=true

When we view the Sonarcloud project at the top level alongside our other projects at https://sonarcloud.io/projects it says 0% coverage. If I go to the project’s dashboard I get 0% code coverage.

However if I select a feature branch which was branched from “master” it does give me a code coverage value AND an “Estimated after merge” value. This suggests that Code Coverage is configured in “master” branch so why is it not displaying at the top level?

Both the top level view, and the project’s dashboard show details about the main branch of the project. (I’m guessing that’s master in your case.)

Your deduction in “This suggests […]” is not correct, that’s not the way the tool works. Here’s what the coverage and estimate coverage fields really mean in a branch:

  • estimated coverage: the total coverage of the project, according to the coverage reports processed
  • coverage: the coverage over the lines changed in the branch, as computed from the lines changed in the branch, and the data in the coverage reports processed

The coverage value you see in the main branch will depend on the analysis of the main branch. If you don’t see coverage there, it looks like the coverage reports were not correctly processed. I suggest to look for the following:

  • How is the analysis of master configured, and how is the analysis of feature branches configured? Look for any differences, especially related to coverage reports.
  • When analyzing master, are the coverage reports present? Check the output of the scanner, look for warnings related to the processing of coverage reports. Compare with the logs you get from feature branches, where the coverage reports are correctly imported.
1 Like

@janos thanks for replying and explaining the error in my deduction. That gave me the shove in the right direction.

I foound that the SonarSource Analyze had not run for a long time against MASTER as we had changed our release and branching process and that was incompatible with me “excluding” the MASTER branch from YAML pipeline.

In summary our fault

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.