Generic/DisallowYodaConditions: add code coverage ignore annotation for untestable line #525
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.
Description
This PR adds the
@codeCoverageIgnoreStart/@codeCoverageIgnoreEnd
PHPUnit annotations to ignore, for the purposes of code coverage, a line that can't be tested. I considered doing this initially when I worked on improving code coverage for this sniff in #465, but I wrongly assumed that was not an option due to theSquiz.Commenting.InlineComment.InvalidEndChar
error (which is part of the standard used by PHPCS).What I failed to notice back then is that I was adding the annotation below a comment, and this triggers the error:
Adding the annotation before the comment as it is done in this PR does not trigger the error because the
Squiz.Commenting.InlineComment
sniff will only trigger theInvalidEndChar
error if the first character of the comment is a letter.I also considered using
return true; // @codeCoverageIgnore
, but this is not an option because it triggersSquiz.Commenting.PostStatementComment.Found
.Related issues/external references
Part of #146
Types of changes
PR checklist