fix(codecov): populate branch/condition data in Clover reports - #337
Merged
roxblnfk merged 2 commits intoSep 14, 2026
Merged
Conversation
Member
|
Pushed a follow-up commit (e7e4af4) on top of yours with a few review tweaks, so the PR can be merged as is:
Thanks for the clean port and the tests, the aggregator extraction is exactly what was needed. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
refactor(codecov): share branch aggregation between Clover and Cobertura test(codecov): cover Clover conditionals and type="cond" lines CloverReport hardcoded conditionals/coveredconditionals to 0 and never read FileCoverage::$functions, so branch data collected at CoverageLevel::Branch/Path was discarded, while CoberturaReport in the same package already consumed it. Resolves php-testo#334. The aggregation moves into Testo\Codecov\Internal\BranchCoverageAggregator and both writers use it. Clover counts only decision points (two or more outgoing edges) as conditionals, so file and project metrics equal the sum of truecount/falsecount over the cond lines and single-edge linear jumps do not dilute condition coverage. Branches are folded into elements/coveredelements the way php-code-coverage's Clover writer does. Cobertura keeps counting every edge for branches-valid. Assisted-By: Claude Sonnet 5 <noreply@anthropic.com> Assisted-By: Claude Fable 5.1 <noreply@anthropic.com>
roxblnfk
force-pushed
the
fix/334-clover-branch-coverage
branch
from
September 14, 2026 13:16
bd858e0 to
ee2f5cc
Compare
Result and Exception classes gain `@api`, CoverageDriver under the Internal namespace switches to `@internal`, which clears the plugin's own StructArmed findings from php-testo#330. The remaining ones, CoverageInput using core Config attributes and ApplicationPlugins depending on CodecovPlugin, are cross-package and stay open. Assisted-By: Claude Fable 5.1 <noreply@anthropic.com>
roxblnfk
force-pushed
the
fix/334-clover-branch-coverage
branch
from
September 14, 2026 13:19
ee2f5cc to
8ad0366
Compare
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.
Closes #334.
What was wrong
CloverReporthardcodedconditionals/coveredconditionalsto0at both file and project level, and never readFileCoverage::$functionsat all — even when branch data was genuinely collected (CoverageLevel::Branch/PathviaXdebugDriver). Confirmed by contrast withCoberturaReportin this same package, which already consumes that data correctly (branch-rate,condition-coverage).What this does
BranchCoverageAggregator(new,@internal): extractsCoberturaReport's owncountBranches()/buildLineBranchMap()into a shared helper, per the suggested scope in the issue, so both report writers reduceFileCoverage::$functionsthe same one way instead of drifting.CloverReport: now populatesconditionals/coveredconditionals(file and project level) fromcountBranches(), and folds them intoelements/coveredelementsalongside statements — mirroring howphp-code-coverage's own Clover writer sums methods + statements + branches intoelements.buildLineBranchMap()) now writestype="cond"withtruecount/falsecountinstead oftype="stmt"; ordinary statement lines are unaffected. Since a branch can have more than 2 outgoing edges (amatcharm per case),truecount/falsecountare populated as covered/uncovered edge counts rather than a literal true/false pair — documented inline.CloverReportTest— conditionals/coveredconditionals filled from branch data, elements including them, a per-linetype="cond"case withtruecount/falsecount, a single-outgoing-edge branch stayingtype="stmt"(not a decision point), and the "no branch data at all" Line-level shape keeping every zero at zero (per the issue's explicit ask).Verification
vendor/bin/testo --suite=Codecov/Unit: 136/136 (up from 131).composer psalm: no errors.composer cs:diff: 0 of 4 touched files need fixing.composer rector:ci(dry-run against the touched files): no changes.TESTO_CI=1: 2211/2211, excluding 3 pre-existing, unrelatedTests\Bench\Self\BenchAttrtiming-sensitive failures reproduced identically on a clean checkout of1.xbefore this change.Assisted-By: Claude Sonnet 5 noreply@anthropic.com