Skip to content

fix: guard against NaN line-rate in Cobertura when no lines tracked#292

Merged
mcarvin8 merged 1 commit into
mainfrom
fix/cobertura-nan-zero-lines
May 29, 2026
Merged

fix: guard against NaN line-rate in Cobertura when no lines tracked#292
mcarvin8 merged 1 commit into
mainfrom
fix/cobertura-nan-zero-lines

Conversation

@mcarvin8
Copy link
Copy Markdown
Owner

Summary

  • finalize() in CoberturaCoverageHandler computed package and global @line-rate via division without guarding for a zero denominator
  • A file with no tracked lines (empty lines object) produced NaN in both values, silently breaking every downstream tool that reads line-rate from the Cobertura XML (Codecov, Azure DevOps, Jenkins, GitLab, etc.)
  • Both division sites now return 0 when the denominator is zero

Test plan

  • Existing empty-file test extended to assert pkg['@line-rate'] and result.coverage['@line-rate'] are 0, not NaN
  • All 104 unit tests pass (npm run test:only)
  • Branch coverage 100% (192/192)

🤖 Generated with Claude Code

finalize() computed package and global line-rate via division without
guarding for a zero denominator. A file with no tracked lines (empty
lines object) produced NaN in both values, silently breaking every
downstream tool that reads line-rate from the Cobertura XML.

Both division sites now return 0 when the denominator is zero.
Extended the existing empty-file test to assert package and global
line-rate are 0, not NaN.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/handlers/cobertura.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcarvin8 mcarvin8 merged commit f44d69d into main May 29, 2026
11 checks passed
@mcarvin8 mcarvin8 deleted the fix/cobertura-nan-zero-lines branch May 29, 2026 13:14
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