Large discrepancy between "Estimated after merge" and overall coverage

Hi @GeekOnIce

My apologies for the delay, I’m handing over my colleague Anita.
Thank you so much for the reproducer!

Using the provided XML files and the SonarCloud project, I confirmed that the difference comes from files that are included in the main branch and not in the PR: the estimated coverage of 56.7% is computed using the 3 Swift classes only. The scripts/setup.swift file is not included in the total coverage computation of the PR while it is on the long branches. It matches what you found previously.

When the SonarScanner analyzes a pull request, it sends to the server only the global coverage report and the changed files.
Since the files in the script directory are not changed nor part of the coverage XML file, then the server has no way of knowing that they exist when analyzing the PR (we are not doing any diffs with the main branch nor the target branch), and therefore can’t include them in the estimated coverage computation with 0%.

I suspect that finding a way to have those script files mentioned as uncovered in the XML coverage file would change the estimated coverage on the PR, with a value equal to the long branch analysis.

I’ll continue to dig to see if there is something we can do about that.
Claire

1 Like

Glad to hear that the project helped identify the underlying issue! Let me know if there is anything else I can do to help.

1 Like

Hi Darrell

I couldn’t find any quick fix for this one. I’ve filled a ticket in our backlog to properly fix it.
I’ll copy your excellent reproducer to keep it with the ticket.

Thanks again for your great help!
Claire

Has there been a resolution on this ? We are on Enterprise edition and see the same discrepancy.
Math on Coverage after PR merge doesn’t add up.