-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Squiz/PostStatementComment: use a different error code for annotations #627
Squiz/PostStatementComment: use a different error code for annotations #627
Conversation
This commit changes `Squiz.Commenting.PostStatementComment` to use a different error code when an annotation is found. This will allow ruleset maintainers to selectively exclude the flagging of trailing annotations from their ruleset. For example, for PHPCS itself, this will make it possible to use the `// @codeCoverageIgnore` annotation where needed. An annotation is defined as any comment that starts with an optional space, followed by a `@` and any character, as long as it is not a whitespace. For now, only `//` comments are supported as this is the only type of comment supported by this sniff. This change only applies to PHP code as support for JS will be dropped soon, and JS doesn't seem to follow the same convention of annotations starting with `@`.
src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php
Outdated
Show resolved
Hide resolved
src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc
Outdated
Show resolved
Hide resolved
Thanks for your review, @jrfnl! I pushed a new commit to implement the changes you suggested and replied to your comments. Could you please take another look? |
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.
@rodrigoprimo Thanks for the PR and fixing the regex (and updating the tests to match). Definitely better now.
Realized only when prepping for merge that the comments in the test case files could be made a little more descriptive. Left two suggestions in-line. Other than that all good.
If you like, I can fix up those comments when merging. Let me know.
src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc
Outdated
Show resolved
Hide resolved
src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc
Outdated
Show resolved
Hide resolved
Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com>
5c83003
to
e28bf06
Compare
@jrfnl, I went ahead and committed your suggestions. Thanks. |
#627) This commit changes `Squiz.Commenting.PostStatementComment` to use a different error code when an annotation is found. This will allow ruleset maintainers to selectively exclude the flagging of trailing annotations from their ruleset. For example, for PHPCS itself, this will make it possible to use the `// @codeCoverageIgnore` annotation where needed. An annotation is defined as any comment that starts with an optional space, followed by a `@` and any character, as long as it is not a whitespace. For now, only `//` comments are supported as this is the only type of comment supported by this sniff. This change only applies to PHP code as support for JS will be dropped soon, and JS doesn't seem to follow the same convention of annotations starting with `@`.
Description
As discussed in #560, this PR changes
Squiz.Commenting.PostStatementComment
to use a different error code when an annotation is found. This will allow ruleset maintainers to selectively exclude the flagging of trailing annotations from their ruleset. For example, for PHPCS itself, this will make it possible to use the// @codeCoverageIgnore
annotation where needed.An annotation is defined as any comment that starts with an optional space, followed by a
@
and any character, as long as it is not a whitespace. For now, only//
comments are supported as this is the only type of comment supported by this sniff.This change only applies to PHP code as support for JS will be dropped soon, and JS doesn't seem to follow the same convention of annotations starting with
@
.Suggested changelog entry
Squiz.Commenting.PostStatementComment
: use a different error code for annotationsRelated issues/external references
Fixes #560
Types of changes
PR checklist