-
Notifications
You must be signed in to change notification settings - Fork 800
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
phpcs: Fix unintentional exclusions #37122
Conversation
Turns out that if you do like ``` <rule ref="Standard.Category.Sniff.Message"> <severity>0</severity> </rule> ``` then phpcs may implicitly set severity to 0 for all the rest of `Standard.Category.Sniff` too since it interprets the `<rule>` as wanting only that one message from the sniff. What you really want if you want to exclude only one message from a sniff is ``` <rule ref="Standard.Category.Sniff"> <exclude name="Standard.Category.Sniff.Message"/> </rule> ``` So let's add a CI linting check to tell people to do the latter when they try to do the former, and clean up all the places where people have done the former in phpcs-required files. The cleanup takes three forms: * Fix anything auto-fixable, because there's little point in ignoring them when they can be fixed with no effort. * Manually fix things that are easily enough fixable and that really shouldn't be ignored. * Add additional message exclusions for messages that it seems like they really wanted to exclude.
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. Boost plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Super Cache plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Inspect plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
<rule ref="Squiz.Commenting.FunctionComment.MissingParamTag"> | ||
<severity>0</severity> | ||
<rule ref="Squiz.Commenting.FunctionComment"> | ||
<exclude name="Squiz.Commenting.FunctionComment.Missing"/> |
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.
This should be nested in the above group (line 34).
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.
🤷 Phpcs doesn't seem to mind, and the original seemed to intentionally have all the "Missing" sniffs listed as a group.
Proposed changes:
Turns out that if you do like
then phpcs may implicitly set severity to 0 for all the rest of
Standard.Category.Sniff
too since it interprets the<rule>
as wanting only that one message from the sniff.What you really want if you want to exclude only one message from a sniff is
So let's add a CI linting check to tell people to do the latter when they try to do the former, and clean up all the places where people have done the former in phpcs-required files.
The cleanup takes three forms:
Other information:
Jetpack product discussion
None. I was looking at a plugin Phan has to flag when a doc comment is using
/*
instead of/**
, then I thought that phpcs would probably be better for that than Phan, and then came across this when looking into why phpcs hadn't already caught these.Does this pull request change what data or activity we track or use?
No
Testing instructions:
.github/files/lint-project-structure.sh
from this PR into trunk and seeing if it flags all the.phpcs.dir.xml
files I'm changing here.