Skip to content

Add --branch-coverage flag to respect partial branch coverage#608

Merged
Bachmann1234 merged 1 commit into
Bachmann1234:mainfrom
mofr:branch-coverage-flag
Jul 22, 2026
Merged

Add --branch-coverage flag to respect partial branch coverage#608
Bachmann1234 merged 1 commit into
Bachmann1234:mainfrom
mofr:branch-coverage-flag

Conversation

@mofr

@mofr mofr commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Adds an opt-in --branch-coverage flag.

By default diff-cover treats any executed line as covered, so a partially exercised branch in a Cobertura coverage.xml passes even at --fail-under=100. With the flag, a line with branch="true" and condition-coverage below 100% counts as uncovered. Default behaviour is unchanged; scope is Cobertura XML.

Related: #182, #513

diff-cover treated any executed line (hits > 0) as covered, ignoring
Cobertura branch/condition-coverage data. A branch that was reached but
only partially exercised therefore passed even --fail-under=100.

Add an opt-in --branch-coverage flag that treats a partially covered
branch (branch="true" with condition-coverage below 100%) as a
violation. Default behaviour is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Bachmann1234

Copy link
Copy Markdown
Owner

Thanks for the pr! Ill get this out!

@Bachmann1234
Bachmann1234 merged commit ca4effc into Bachmann1234:main Jul 22, 2026
14 checks passed
@Bachmann1234

Copy link
Copy Markdown
Owner

Released! https://pypi.org/project/diff-cover/10.4.0/ thanks again!

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