Repository navigation
Support nocov comment at the end of a line - #1068
cyberdelia wants to merge 2 commits into
Conversation
|
Fixed the build failure in #1069. |
e05c83f to
8efae45
Compare
33cbb8e to
574b45c
Compare
8efae45 to
4da33c3
Compare
|
Freshly rebased! cc/ @PragTob |
|
@amatsuda please consider this pull request |
3422349 to
4f8fece
Compare
sferik
left a comment
There was a problem hiding this comment.
I have a bit of feedback but support this feature overall.
Somewhat related: as we approach a 1.0.0 release, I was considering changing the block syntax to be more explicit. Something like:
case coverage_criterion
when :line then compute_line
when :branch then compute_branch
when :method then compute_method
else
# coverage:disable
raise "Unknown criterion: #{coverage_criterion}"
# coverage:enable
endIf that was the block syntax, presumably we’d want the inline syntax to match:
case coverage_criterion
when :line then compute_line
when :branch then compute_branch
when :method then compute_method
else
raise "Unknown criterion: #{coverage_criterion}" # coverage:disable
endThis seems as good a place as any to debate making this change.
| "puts 'Still relevant'", | ||
| "# :nocov:", | ||
| "puts 'Not relevant till the end'", | ||
| "puts 'Not relevant till the end' # :nocov:", |
There was a problem hiding this comment.
I would add a separate, focused test for interactions between inline markers and blocks, instead of making this (already complex) test more complex. There are also a few other edge cases worth testing (e.g. inline # :nocov: comment inside a block).
|
@sferik I like the idea of beginning and end comments, makes diagnosis easier 👌 As for one line/in-line comments I can see the appeal but there's a lot of edge cases to consider (as Erik pointed out) and iirc the lines classifier has been a source of performance degradation in the past - those together make me wonder how much of this we need. The other thing to consider here is how this plays with branch coverage/other coverage types in general. |
Yes. Since #1161 we also now support method coverage, in addition to line and branch coverage. Perhaps we should have more granular disabling like: # coverage:disable:line
# coverage:disable:branch
# coverage:disable:method
# coverage:disable (disables all three)These should work in both block and inline form. @PragTob What do you think? PS: I realize we’re bikeshedding the heck out of this PR, which is more narrowly scoped, but—if we’re going to make API changes before the 1.0 release—I want to make sure we get this right. |
|
@sferik yeah, changes live on in the API and for future support so I believe it's worth considering/talking about. I don't think we need different sub types of coverage disable/enable. The most common use case for coverage disable is "these lines of code do not matter" and I don't think the type of coverage makes a difference there. I should have been more explicit, but the question of how does it play with other types of coverage is mote like: I'm ignoring one line of code inside a branch - will the branch be counted? I'm ignoring all but one line of code inside a branch - will it be counted? I'm ignoring the condition that causes a branch, will the branch be counted? I personally think it's fine to say: Undefined behavior, you did this to yourself. If I'd wish for anything, as long as any line inside a branch is not ignored, the branch shouldn't be ignored. But I'm not sure how much code would be needed to support that or in fact not sure what the current behavior is. But people will complain that it works different from what they imagine :) |
|
I just chatted with @PragTob and we decided on the following comment syntax: # simplecov:disable line
# simplecov:disable method
# simplecov:disable branch
# simplecov:disable method,branch <- disables method and branch coverage
# simplecov:disable <- disables all three
# simplecov:enable <- enables all three
raise "Absurd case" # simplecov:disable <- just disables this line, no need to re-enable |
|
Resolved by #1179. |
Support
nocovcomments at the end of a line to mark it as irrelevant, it's a bit less verbose than blocks to ignore some benign things, i.e: