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

Generic/DisallowYodaConditions: add code coverage ignore annotation for untestable line #525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jun 7, 2024

  1. Generic/DisallowYodaConditions: add code coverage ignore annotation

    This commit 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 PHPCSStandards#465, but I
    wrongly assumed that was not an option due to the
    `Squiz.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:
    
    ```
    // Shouldn't be possible but may happen if external sniffs are using this method.
    // @codeCoverageIgnoreStart
    ```
    
    Adding the annotation before the comment as it is done in this commit
    does not trigger the error because the `Squiz.Commenting.InlineComment`
    sniff will only trigger the `InvalidEndChar` error if the first
    character of the comment is a letter.
    
    Using `return true; // @codeCoverageIgnore` is not an option because it
    triggers `Squiz.Commenting.PostStatementComment.Found`.
    rodrigoprimo committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    8457fd6 View commit details
    Browse the repository at this point in the history