Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add branch/path coverage to reports #761

Merged
merged 4 commits into from
May 30, 2020

Conversation

dvdoug
Copy link
Contributor

@dvdoug dvdoug commented May 29, 2020

For #380

Hello @sebastianbergmann

This PR:

  • Adds new columns for branch and path coverage to the HTML reports when available (I could not see a way to have conditional rule inside the template itself, so have implemented this by duplicating the templates)
  • Adds branch and path data to the text report when available
  • Adds branch and path data to the clover report where available
  • Changes the calculation of CRAP to use path coverage rather than line coverage where this is available to better align with the definition. Interestingly, I've noted this sometimes reduces the score on a partially covered function, it doesn't necessarily increase it.
  • Changes the definition of "covered" for a function/method/class to use branch coverage rather than line coverage where this available.

I've opted to use branch coverage rather than path coverage for that last metric because like line coverage, 100% branch coverage is realistically achievable whereas 100% path coverage for non-trivial functions is often not due to the exponential nature of paths. The large number of uncovered paths on such methods then has a disproportionate effect when summing up coverage on larger units like files and directories tending to mark them as uncovered even when most of the other methods and functions actually do have good coverage. This effect doesn't happen with branch coverage so I think it's a good middle ground between lines and paths and the CRAP score will still reveal the many-pathed functions as danger areas and good potential candidates for a refactoring.

@codecov
Copy link

codecov bot commented May 29, 2020

Codecov Report

Merging #761 into master will increase coverage by 0.63%.
The diff coverage is 89.28%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #761      +/-   ##
============================================
+ Coverage     84.55%   85.19%   +0.63%     
- Complexity      894      951      +57     
============================================
  Files            40       40              
  Lines          2584     2809     +225     
============================================
+ Hits           2185     2393     +208     
- Misses          399      416      +17     
Impacted Files Coverage Δ Complexity Δ
src/Node/File.php 76.09% <74.04%> (+1.09%) 118.00 <10.00> (+29.00)
src/Report/Text.php 80.23% <82.53%> (+0.90%) 25.00 <0.00> (+3.00)
src/Node/AbstractNode.php 81.48% <100.00%> (+2.75%) 41.00 <4.00> (+4.00)
src/Node/Builder.php 97.14% <100.00%> (ø) 24.00 <0.00> (ø)
src/Node/Directory.php 91.78% <100.00%> (+1.61%) 63.00 <13.00> (+12.00)
src/Report/Clover.php 82.75% <100.00%> (ø) 30.00 <0.00> (ø)
src/Report/Html/Facade.php 94.91% <100.00%> (+0.08%) 7.00 <0.00> (ø)
src/Report/Html/Renderer.php 96.85% <100.00%> (+0.70%) 30.00 <1.00> (+3.00)
src/Report/Html/Renderer/Dashboard.php 99.18% <100.00%> (ø) 32.00 <0.00> (+1.00)
src/Report/Html/Renderer/Directory.php 88.00% <100.00%> (+3.00%) 8.00 <0.00> (+2.00)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d2ad210...7361dda. Read the comment docs.

@dvdoug dvdoug force-pushed the branch_coverage branch from 78deab6 to 7361dda Compare May 29, 2020 22:10
@sebastianbergmann sebastianbergmann merged commit 4276667 into sebastianbergmann:master May 30, 2020
@dvdoug dvdoug deleted the branch_coverage branch July 14, 2020 11:02
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