Skip to content

Let class-level lines decide a file's lines - #76

Merged
ANcpLua merged 1 commit into
mainfrom
fix/class-lines-decide-file-totals
Oct 13, 2026
Merged

ANcpLua merged 1 commit into
mainfrom
fix/class-lines-decide-file-totals

Conversation

@ANcpLua

@ANcpLua ANcpLua commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Count a file's lines from the class-level <lines> when a class has them, so istanbul's function-declaration lines stop inflating line totals.

Problem

istanbul (the Cobertura writer behind Jest and Vitest) lists each function's declaration line under <methods>. That line is often not part of its own line coverage, the class-level <lines>. DotCov counted it as a file line, so line totals ran above the tool's own.

On the ten typescript-sdk Vitest reports, all 10 disagreed before this change, by up to 823 lines. For example, server: Vitest 3170/6194 lines, DotCov 3473/6973.

What changed

  • Lines under <methods> count toward the file only when the class has no class-level <lines>. They still feed the method data (CRAP).
  • Coverlet repeats its method lines in the class summary, so its totals do not change. A class with method lines only keeps today's behavior.
  • README: one paragraph on istanbul's branch counts (see below).

Verification

  • fallout Test: 1392 passed. fallout Coverage: line 100.0%, branch 100.0%.
  • New specs: an istanbul-shaped class whose declaration line is not a file line; a class without class-level lines keeps its method lines, branches and conditions.
  • All ten typescript-sdk Vitest reports: DotCov's line totals now equal Vitest's.

Not fixable from the report

istanbul attaches branches only to lines that hold statements. Branches on other lines exist only in the report's header totals, so DotCov's branch count can stay lower (server: Vitest 4234, DotCov 3850). The README now says so.

🤖 Generated with Claude Code

istanbul (Jest, Vitest) lists each function's declaration line under
<methods>, and that line is often not part of its own line coverage, the
class-level <lines>. DotCov counted those declaration lines as file lines, so
its line totals ran above the tool's own: on the typescript-sdk packages by
up to 779 lines per report.

Lines under <methods> now count toward the file only when the class has no
class-level <lines>; they still feed the method data. Coverlet repeats its
method lines in the class summary, so its totals do not change.

On all ten typescript-sdk Vitest reports, DotCov's line totals now equal
Vitest's. Branch totals can stay lower, because the writer attaches
branches only to statement lines; the README says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 01:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T01:48:12.375029Z ec0bc11 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec0bc11f43

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


while (sub.Read())
context.Visit(sub);
context.Complete();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Finalize method-only classes on the async path

When a report contains a class whose coverage exists only under <method><lines>—the fallback this change explicitly supports—ParseAsync buffers those records in _methodLines but never invokes context.Complete() after its class loop, unlike this synchronous path. The async report therefore materializes the file with zero lines and branches rather than its method coverage; invoke Complete() from the async class case as well and cover that entrypoint.

Useful? React with 👍 / 👎.

@ANcpLua
ANcpLua merged commit 831a8e7 into main Oct 13, 2026
28 checks passed
@ANcpLua
ANcpLua deleted the fix/class-lines-decide-file-totals branch October 13, 2026 01:48
@ANcpLua ANcpLua mentioned this pull request Oct 13, 2026
ANcpLua added a commit that referenced this pull request Oct 13, 2026
Set 2.0.0 as the package version, the badge action's default and the README's
action snippet and release-notes link, and add docs/releases/2.0.0.md. The
major version marks that the same report can now count differently: istanbul
line totals and coverage.py multi-root paths (#74, #76). The README's
migration section now covers 1.x and points 0.x users to the 1.0 notes.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants