SonarCloud scala coverage reports no working

SonarCloud doesn’t seem to accurately report coverage data for Scala on branches.

I have been testing our SonarCloud for one of my scala projects, and can’t seem to get coverage reporting working correctly.

The project on SonarCloud is here

The PR testing code coverage is here test sonar code coverage by eli-jordan · Pull Request #59 · eli-jordan/alfred-jenkins · GitHub

Sonar indicates that there is 0% code coverage on that branch. However, the master branch indicates 81%. I also have codecov enabled for this repo, and you can see that there IS a coverage diff in the PR.

I’m a bit at a loss as to why this is happening, any help would be greatly appreciated.

Note: I ran with the sonar.verbose flag set, but nothing stood out to me. The log is here test sonar code coverage by eli-jordan · Pull Request #59 · eli-jordan/alfred-jenkins · GitHub

Hello @eli-jordan
and welcome to the SonarSource community!
From your report I believe you may have misunderstood what SonarCloud PR analysis report is for.
As highlighted with the Pull Request documentation, Pull Request analysis will focus only on the changed lines. Therefore SonarCloud does not report a 0% coverage on your branch, but on your Pull Request code changes:

From your PR CodeCov github integration, I think this SonarCloud report is fully inline with your tests report: you have no test covering your new lines 37 and 38 on FileService.scala.
Codecov also complains about line 40 but SonarCloud detects this code cannot be entered.

Does this help?
Best regards

I see, thanks @Sylvain_Combe. Yes that is helpful.

I disabled some tests (i.e. commented them out) and was expecting the reduction in coverage to be visible, similar to what codecov shows.

So, just to make sure I understand. The coverage reported in PRs shows the coverage of any new lines added in the PR, but doesn’t consider changes to the tests themselves that may have increased coverage elsewhere, or like in my case reduced coverage elsewhere. Is that right?

Hello @eli-jordan
yes you are correct, SonarCloud won’t let you compensate missing tests on new lines of code with additional tests on existing lines.