Skip to content

Squiz/VariableComment: make errorcode for "TagNotAllowed" warning modular #1039

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

Merged

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 20, 2025

Description

Squiz/VariableComment: make errorcode for "TagNotAllowed" warning modular

As things are, the VariableComment sniff only allows @see tags and @var tags in property docblocks.

This practice feels dated to me, as commonly used tags, such as @link, @deprecated etc are not allowed.

This commit replaces the generic TagNotAllowed error code in the sniff with a more modular [TagName]TagNotAllowed error code.

This allows for rulesets to selectively ignore the TagNotAllowed error code for specific tags the ruleset maintainer wants to allow for the code base under scan.

Includes tests.

CS: allow @link and @deprecated in property docblocks

... for this codebase.

Suggested changelog entry

Changed:

  • The error code Squiz.Commenting.VariableComment.TagNotAllowed has been replaced by a dynamic Squiz.Commenting.VariableComment.[TagName]TagNotAllowed error code.
    • This allows for selectively allowing specific tags by excluding the error code for that tag.
    • Example: to allow @link tags in property docblocks, exclude the Squiz.Commenting.VariableComment.LinkTagNotAllowed error code.

Related issues/external references

Loosely related to #122

jrfnl added 2 commits April 29, 2025 14:21
…ular

As things are, the `VariableComment` sniff only allows `@see` tags and `@var` tags in property docblocks.

This practice feels dated to me, as commonly used tags, such as `@link`, `@deprecated` etc are not allowed.

This commit replaces the generic `TagNotAllowed` error code in the sniff with a more modular `[TagName]TagNotAllowed` error code.

This allows for rulesets to selectively ignore the `TagNotAllowed` error code for specific tags the ruleset maintainer wants to allow for the code base under scan.

Includes tests.
@jrfnl jrfnl force-pushed the phpcs-4.0/feature/squiz-variablecomment-make-tagnotallowed-modular branch from 870e42b to 20994a2 Compare April 29, 2025 12:21
@jrfnl
Copy link
Member Author

jrfnl commented Apr 29, 2025

Rebased without changes. Merging once the build has passed.

@jrfnl jrfnl merged commit 570ce73 into 4.x Apr 29, 2025
150 checks passed
@jrfnl jrfnl deleted the phpcs-4.0/feature/squiz-variablecomment-make-tagnotallowed-modular branch April 29, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant