-
Notifications
You must be signed in to change notification settings - Fork 12
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
In clover.xml, count all method definitions once #115
Open
mike-burns
wants to merge
1
commit into
master
Choose a base branch
from
clover-ignore-method-lines
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<coverage generated="1693391816"> | ||
<project timestamp="1693391816"> | ||
<file name="/home/yu/projects/PHPCSUtils/PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php"> | ||
<class name="PHPCSUtils\AbstractSniffs\AbstractArrayDeclarationSniff" namespace="global"> | ||
<metrics complexity="44" methods="1" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="79" coveredstatements="79" elements="82" coveredelements="82"/> | ||
</class> | ||
<line num="1" type="method" name="process" visibility="public" complexity="4" crap="4" count="0"/> | ||
<line num="2" type="stmt" count="0"/> | ||
<metrics loc="552" ncloc="237" classes="1" methods="1" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="79" coveredstatements="79" elements="82" coveredelements="82"/> | ||
</file> | ||
<metrics files="1" loc="11201" ncloc="5558" classes="36" methods="1" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="2420" coveredstatements="2376" elements="2602" coveredelements="2539"/> | ||
</project> | ||
</coverage> |
This file contains 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
Oops, something went wrong.
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.
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.
@mike-burns question:
Will this solution place the correct number of hits for the method on the line declaring the method (in the Coveralls source file report)? See the example I refer to below, pls.
I see that this code will solve the problem of lines declaring functions displaying as (relevant but) uncovered. It appears this will always at least make sure they are shown as covered (green) in Coveralls reports.
However, given your discovery that the number of hits for a method is taken to be equivalent to the highest number of hits for any of its (statement) lines, won't this miss the opportunity to show the correct number of hits for the method, and always just show (
1
)?I can understand using this code as a failsafe to make sure lines declaring a method appear as covered, but it seems to me that the correct number of hits should be what we get from a correct XML report, which appears to be that highest number for the method's lines.
Check out the example pertaining to the
AbstractArrayDeclarationSniff.php
file in my comment on the OP's public issue:To be perfectly honest, I kind of forget the point of my comment there, but now I'm stuck on the fact that recent source file reports (like this one, as opposed to this older version from Aug 2023) seem to show the correct hit count for the method. in the case of Line 178,
52
.Isn't that what a correct clover.xml report should show as the hit count for the method? And isn't that what we want to show in our reports?
Forgive me for being rusty on this one, I may have missed something.
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.
This really comes down to: what number do we want to show for line 178 in that screenshot? What is "correct", in this case?
52
, the highest number of any line within the method (so0
for an untested method).max(52, 1)
, the highest number of any line within the method (or1
for an untested method, meaning that line 178 is OK).1
, simply indicating that the method was defined.As a base case, what numbers do we want for this method definition:
Do we want to say that the
public function someNoOpMethod()
line was never run? No amount of test coverage can change that -- calling the method executes zero statements, so the method definition line is still considered0
.I'm happy to go with your decision -- you might have more context than I do around what these numbers are used for.