Code coverage says 0 new lines, but duplication says 26 new lines

  • Azure DevOps pipeline
  • GH repo, private
  • 1 .net solution with 4 csharp projects
  • SonarCloud, private project

The PR verification build reports the following in sonarcloud

Thats 26 new lines known for purposes of duplication analysis, but 0 new lines for code coverage analysis. There are no analysis exclusions configured for this project in sonar, the classes do not have any exclusion attributes or file name patterns. The testing task in the pipeline is creating TRX and Coverage files and the sonar code analysis task is finding them.

I dont see any setting different between this and another project/repo that seems to be reporting new lines for coverage. Our default for New Code is < 30 days, but I tried using previous version and having the build autoincrement the project version in the sonar prep task and it did not work either.

What else can be preventing the coverage percentage from being reported?

EDIT: At one point this was reporting quality gate failure and blocking the PR due to 0% coverage but that quality gate condition for new code coverage was removed because we cant get it to calculate, so I dont think its a problem with the quality gate

Hello @StingyJack,

Apologies for taking so much time to get back to you. Are you still experiencing this behaviour?
If so, could you provide me with a recent Background Task ID? You can find this by navigation to your project on SonarCloud > Administration > Background tasks.

Yeah, this is still weird. After several pull requests and commits, it started counting new lines but its way off still. This is the stats for a PR i just converted from a draft.

The dupe and coverage should both show 1.9K new lines, but coverage only reports 26 62 new lines. That does not make sense, the dupe new line count is probably correct for this branch/PR.

Here are some background task ID’s…

For the PR/branch on the screenshot above :     AXgKo1r4zHqTL4JgPdr_
The latest one for the 'Main' branch :          AXgKopKtQUCmEwYinTyz
The oldest one in the list:                     AXdOiS4w1jNk10YTSEKB

Hi @StingyJack,

Thanks for reaching out to us.

The Coverage and Duplication measures don’t count lines the same way.

Coverage only takes into account new lines that follow these 2 conditions : included in the coverage report and testable (for instance we don’t count lines that are only composed of “}” )
For the duplication measures all new lines are taken into account.

In that case it is normal to have a Coverage number of new lines <= Duplication number of new lines

I hope this helps. Don’t hesitate if you have more questions
Have a nice day.

@Amelie_Foulc - What was the results of investigating those background tasks?