fix(ci): align coverage scope between the gate and SonarCloud - #32
Merged
Merged
Conversation
The coverlet gate reported 97.4% but ~89% of its denominator was EF Core migration scaffolding (.Designer.cs / ModelSnapshot), which the integration fixture applies verbatim and therefore counts as ~100% covered: the gate was effectively measuring generated code. Exclude that scaffolding (keeping migration Up/Down logic) so the line gate reflects hand-written code (now ~76.5%). SonarCloud only receives backend opencover coverage in this job, yet it analyzed the Angular frontend and repo scripts too, counting every TS/JS line as 0% covered. That diluted the project coverage to 36.9% and would fail the new-code coverage gate on any frontend PR. Add sonar.coverage.exclusions for the languages this job cannot measure plus the same generated scaffolding. The residual difference between the two numbers is documented in the master plan.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
The CI coverage gate and SonarCloud reported very different numbers for the same repository (gate 97.4% / Sonar 36.9% on SplitIt). Investigation showed the two tools were measuring different things.
Root cause 1 — the gate was measuring generated code
coverletincluded the EF Core migration scaffolding (.Designer.csand*ModelSnapshot.cs). Those files are auto-generated and applied verbatim by the integration-test fixture, so coverlet reports them as ~100% covered, while they dominate the denominator:The gate was not above Sonar because of good coverage; it was above because of generated code.
ExcludeByFilenow drops only the generated Designer/snapshot files — migrationUp/Downlogic stays in scope, so this is a scope fix, not a threshold change.Root cause 2 — SonarCloud counted the frontend as 0% covered
This job only runs backend .NET tests and only supplies
coverage.opencover.xml. SonarCloud still analyzed the Angular frontend and the repo scripts, so every TS/JS line was counted as uncovered (SplitIt: ~1,096 lines; Bikontrol: ~989). That diluted project coverage and would have failed the new-code coverage gate on any frontend PR.sonar.coverage.exclusionsnow excludes the languages this job cannot measure, plus the same generated scaffolding.What changed
coverlet.runsettings: exclude generated migration scaffolding from line coverage..github/workflows/sonarcloud.yml:sonar.coverage.exclusionsfor frontend/scripts and generated scaffolding.No threshold was modified (SplitIt 70, Bikontrol 80).
Residual difference (documented in the master plan)
Even with both scopes aligned, the two numbers are not identical: SonarCloud measures every executable line across every backend project, while coverlet only measures sequence points in assemblies the test host actually loads (e.g. SplitIt's
Applicationlayer is not instrumented today). This is a real coverage gap that Sonar surfaces and coverlet hides; it is documented rather than papered over.Verification