fix(cobertura): deduplicate method names within a class - #11
Merged
AriPerkkio merged 2 commits intoAug 31, 2026
Merged
Conversation
AriPerkkio
reviewed
Aug 31, 2026
AriPerkkio
left a comment
Member
There was a problem hiding this comment.
Just a note that in addition to fixing merge() (which will happen in #10), this change is required on its own. It's possible to end up with duplicate fnMap entries with plain single-file Javascript too: AriPerkkio/ast-v8-to-istanbul#169 (comment). This PR will make sure Jenkins doesn't crash in those cases either.
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.
Summary
Deduplicate
<method name="...">values in the Cobertura reporter when a file'sfnMapcontains colliding function names (e.g. two(anonymous_0)or twoconstructorentries).Related: vitest-dev/vitest#11069
Scope
This PR intentionally fixes the issue only at the Cobertura report layer.
Duplicate function names in a merged
fnMapare valid in JavaScript and can be expected when coverage from multiple chunks is combined. Rather than renaming functions duringmerge()inistanbul-lib-coverage, this change ensures the Cobertura XML output is safe for downstream consumers (notably the Jenkins Coverage plugin), which require method names to be unique within a class.Rationale:
fnMapnames unchanged preserves existing coverage data semantics; only the Cobertura XML representation is adjusted.Problem
When coverage from multiple chunks is merged,
fnMapentries for the same source file can end up with identicalnamevalues but different source locations. The Cobertura reporter previously emitted both with the samenameattribute, causing Jenkins to fail parsing the report.Example:
(anonymous_0)at line 12(anonymous_0)at line 16Solution
When emitting
<method>tags for a class, deduplicate names within that class:name_2,name_3, …State is scoped per class via a
createUniqueNamer()helper.Test plan
constructorand(anonymous_0)names in the same fileconstructor,constructor_2,(anonymous_0),(anonymous_1)