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