Squiz/PostStatementComment: use a different error code for annotations #627
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
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