fix: correct coverage percentage when branch coverage is enabled#285
Conversation
- combine statement + branch coverage and round like `coverage report` (never rounding up to 100% or down to 0%) - reject malformed coverage XML instead of falling back to 100% - make the text-badge fraction branch-aware (e.g. 10/12, not 8/8) - bump version to 1.9.0 and add changelog entry Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
CodeAnt AI is reviewing your PR. |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PR Summary by QodoFix branch-aware coverage percentage rounding and harden Cobertura XML parsing
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
|
CodeAnt AI finished reviewing your PR. |
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect coverage reporting when Cobertura XML includes branch coverage by computing a combined statement+branch percentage and matching coverage report rounding behavior, while also hardening XML parsing and updating the release metadata.
Changes:
- Compute coverage as
(covered statements + covered branches) / (total statements + total branches)and round likecoverage report(avoiding false 100%/0%). - Reject malformed coverage XML totals instead of producing misleading results.
- Make the text badge fraction branch-aware for XML-based reports; bump version to
1.9.0and add a changelog entry.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/parseXml.ts | Adds combined statement+branch coverage computation, rounding, and stricter XML validation paths. |
| src/parse.ts | Updates text badge fraction logic to incorporate branch counts. |
| tests/parseXml.test.ts | Adds tests for partial-branch 83% case and branch-aware text badge in XML mode. |
| CHANGELOG.md | Adds 1.9.0 release notes for the branch-coverage fix. |
| package.json | Bumps package version to 1.9.0. |
| package-lock.json | Updates lockfile version metadata to 1.9.0. |
| dist/index.js | Rebuild output reflecting source changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Warning Review limit reached
Next review available in: 29 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. WalkthroughThis PR updates coverage handling to include branch coverage in total and per-file percentage calculations. Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7df8264f-95a4-4826-9a65-8ca0a4dc20bb
⛔ Files ignored due to path filters (2)
dist/index.jsis excluded by!**/dist/**package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
CHANGELOG.md__tests__/parseXml.test.tspackage.jsonsrc/parse.tssrc/parseXml.ts
There was a problem hiding this comment.
3 issues found across 7 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
The branch-aware fraction assumed `brpart` is the count of missing branches, which is only true for XML totals. Text reports expose coverage.py's `BrPart` (partial branches), so gate the branch math on the XML path to avoid overstating covered branches. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pre-existing formatting drift (prettier bump in #275) that broke the format-check CI step once this branch touched src files. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@MishaKav Thanks a lot for finishing this up! |
Continues #284 by @mschoettle (which landed on
fix-branch-coverage-percentage), with hardening added on top.What
coverage reportdoes (never rounding up to100%or down to0%)100%10/12, not8/8)1.9.0+ changelog entryCredit
Original branch-coverage fix by @mschoettle in #284. This PR carries that work plus the follow-up hardening to
main.Test
npm run allgreen (95 tests). Added coverage for the partial-branch83%case and the branch-aware text badge.🤖 Generated with Claude Code