Skip reporting coverage on main source files that aren't uniquely named - #465
Merged
cirras merged 1 commit intoSep 22, 2026
Conversation
romain-cureau
force-pushed
the
fix/coverage-ambiguous-file-names
branch
from
September 14, 2026 18:49
75e9b96 to
f2406d1
Compare
cirras
self-requested a review
September 22, 2026 04:03
cirras
force-pushed
the
fix/coverage-ambiguous-file-names
branch
from
September 22, 2026 04:03
f2406d1 to
26d810c
Compare
cirras
approved these changes
Sep 22, 2026
cirras
merged commit Sep 22, 2026
f1b67ba
into
integrated-application-development:master
2 checks passed
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.
What
DelphiCodeCoverageParser.indexInputFiles()builds its file-name index withImmutableSortedMap, whosebuild()throws on duplicate keys. The index is keyed by thebare file name, so any two source files sharing a name make it throw:
The exception is caught in
parseReportFile, so the analysis completes — but the entirecoverage report is discarded, leaving the project at 0 % with only an ERROR line in the
scanner log to explain it.
Why it matters
Sharing a file name across units is ordinary in Delphi codebases. On the project where this
surfaced, 274 of 2012 files in scope share 92 names:
MainForm.pas(×20),SvcDefinitionsImpl.pas(×14, one per service),Main.pas(×10),CommonGateway_TLB.pas(×10). These are conventions, not defects — excluding them would mean excluding the core of
the codebase.
The failure is all-or-nothing: that project's report covers 67 files, of which only 3
have an ambiguous name, yet all 67 were dropped.
What this changes
Ambiguous names are removed from the index and reported once, instead of aborting the whole
report. Coverage is still recorded for every file whose name is unique — 64 of 67 in the
case above, rather than none.
The ambiguity itself isn't resolvable here: Delphi Code Coverage identifies files by bare
name, with no path to disambiguate against. Skipping those entries and saying so seemed more
useful than losing everything.
Notes
ImmutableSortedMapis no longer used in this class, so the import is removed.testAmbiguousFileNamesDoNotDiscardTheWholeReport, which registers a secondMainWindow.pasand asserts thatGlobals.pascoverage is still recorded while theambiguous name is skipped. The full
DelphiCoverageToolParserTestsuite passes (10 tests).SonarQube 26.1 with the plugin built from this branch: coverage went from unreported to
7.5 %, with
Coverage data skipped for 92 ambiguous file name(s)in the log.