-
-
Notifications
You must be signed in to change notification settings - Fork 377
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
prevent uncovered classes from showing up in html coverage report #864
Conversation
@dvdoug Does this make sense to you? It's been a while since I looked at this in detail, and I do not have the time right now to dig into this. Thanks in advance! |
I'll take a look in the next couple of days 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @yanghva
Your diagnosis of the potential issue seems correct to me from code introspection, however without a minimal reproducing testcase it's hard to confirm the fix is the right one. Could you please add one? (even if it's not in the PR, just a separate comment on GitHub. Something I can QA with).
In this case, a reproducer for the bug is also important because php-code-coverage 7 and php-code-coverage 9 have very different code in this area so although I don't think v9 has the issue you refer to, I'd like to make sure...
Many thanks!
Hi @dvdoug here is a minimal example, coverage-minimal.zip. Unzip it and do the usual
In this case, class A still showed up in the final report. FYI I am using PCOV, below are the versions used for each components. Generated by php-code-coverage 7.0.15 using PHP 7.2.34 with PCOV 1.0.9 and PHPUnit 8.5.20 at Wed Sep 22 2:39:15 UTC 2021. |
Out of curiosity and because I am thinking about removing |
@sebastianbergmann For two reasons:
|
Thank you for your feedback. |
@sebastianbergmann these changes look good to me for v7. v9 does suffer from the same bug, but the sequencing of events is different so will require a different fix. I'll work on that and send over an additional PR once I've got something. |
Actually, I take that back - this branch is so old the tests haven't run on CI because they're configured to run on Travis not GitHub Actions. This PR breaks quite a lot of them. It may well be the tests are wrong of course, but this can't get merged as-is |
Let's take With this change, that method becomes excluded from the data entirely - all of the stats now claim the file has 3 methods instead of 4 etc. This is not correct.
|
Thank you for your contribution. I appreciate the time you invested in preparing this pull request. However, I have decided not to merge it. |
When
@covers
annotation was applied to tests, some uncovered classes still ended up in final coverage report,html
in my case. Apart from cluttering the report and messing up the code coverage caculation, it also slowed down report generation significantly, especially for html.It boils down to this two lines of code.
applyCoversAnnotationFilter
removes the uncovered files, however before thatinitializeFilesThatAreSeenTheFirstTime
would have already added them to the output (unless that's intentional). In this commit I switched their orders. It is also slightly faster because nowapplyIgnoredLinesFilter
has less work to do.From what I read the change shouldn't have any other side effects. However the code is old, let me know if it breaks anything.