fix(patch): skip zero-hit comment lines in patch coverage#80
Open
betegon wants to merge 3 commits into
Open
Conversation
Coverage tools (notably bun under --isolate --parallel) sometimes emit DA:x,0 LCOV entries for JSDoc continuation lines and other comment-only lines as a source-map artifact. The action was faithfully counting those as "missing coverage", dragging patch percentages down incorrectly. The fix: when a diff-added line has a DA entry with count=0, check whether the line content is purely a comment (//…, /*…, * …, #…) or blank. If so, skip it — comments are never executable and a zero-hit DA entry for them is always a false positive. Lines absent from the LCOV entirely were already ignored; this closes the gap for zero-hit comment DA entries that some tools emit. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Codecov Results 📊✅ 197 passed | Total: 197 | Pass Rate: 100% | Execution Time: 287ms 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 759 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 56.82% 56.91% +0.09%
==========================================
Files 24 24 —
Lines 1753 1756 +3
Branches 1257 1264 +7
==========================================
+ Hits 994 997 +3
- Misses 759 759 —
- Partials 97 97 —Generated by Codecov Action |
startsWith("#") incorrectly treated private class members (#myField,
#_backing) as comments, causing their zero-hit DA entries to be skipped
instead of counted as missed coverage.
Replace with /^#(?!\w)/u — # is only a comment marker when NOT followed
by a word character. Shell/Python comments and shebangs (#!, # text) are
still detected; private fields (#field, #_count) are now correctly
treated as executable code.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 22652df. Configure here.
startsWith("*") matched generator method declarations (*myGenerator,
*[Symbol.iterator]) in addition to JSDoc continuation lines, causing
those uncovered methods to be silently skipped instead of counted as
missed coverage.
Confirmed by actual bun LCOV output: an uncalled *range(n: number)
method produces DA:4,0 (bun's "unexecuted function range fill" writes
DA:x,0 for the entire function range). With startsWith("*"), that line
was classified as a comment and excluded from patch coverage.
Fix mirrors the earlier # fix: /^\*(?![a-zA-Z_$\[])/ treats * as a
comment marker only when NOT followed by an identifier-start char or [.
JSDoc * text and */ are still caught; *myGen and *[Symbol] are not.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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
When a coverage tool emits
DA:x,0entries for comment-only lines (JSDoc* ...,//,/*,#) — which happens with bun under--isolate --paralleldue to TypeScript source-map artifacts — the action counts those lines as missed coverage. Lines with no DA entry at all are correctly ignored; the gap was zero-hit DA entries for non-executable lines.Concrete example from getsentry/cli#960: bun's LCOV includes
DA:18,0–DA:24,0for 7 JSDoc continuation lines that appear as+lines in the patch diff. The action counted all 7 as missing, pulling patch coverage from ~100% to 65% and failing the coverage gate.bun's
CodeCoverage.zigdocuments that comments should be excluded from coverage (lines 11–12), but under certain V8/source-map conditions this doesn't hold. The fix belongs here too — we should be defensive against any tool that emits zero-hit DA entries for comment lines.Solution
Added
isCommentOrBlankLine(diffLine)inpatch-analyzer.ts. When a diff-added line has a DA entry withcount === 0, we strip the+prefix and check whether the content is a comment (//,/*,*,#) or blank. If so, it's skipped — comments are never executable, so a zero-hit DA entry for them is always a false positive.Lines absent from LCOV entirely are still ignored as before. This only affects lines that are both in the LCOV (with count=0) and contain only comment/whitespace content.
One new test covers the exact failure mode: DA:x,0 entries for JSDoc
*lines,/**,*/,//, and#lines alongside a real covered line. The real line counts; the comment lines don't.