-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Suggest sniff code if invalid #2646
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR. I intend on allowing Standard, Category, Sniff, and message codes on the CLI at some point in the future so that the feature set lines up with how rulesets work, but this is a nice message to have in the meantime. The only issue I have with the PR is that it only works for 4-part codes and so the message is misleading when anything else is used. For example, when using a standard or category name (as you can in a ruleset):
A good change might be to only make the suggestion of the sniff code when there are exactly 4 parts to the specified code. If a user specifies 4 parts, they have probably used a message code instead. But ff they specify less than 3 or more than 4, they probably need a more specific error message than current "The specified sniff code is invalid" message. So maybe for a 4-part code, the message could look something like:
And for anything else, the message could just have:
This finally gives the error some actual information about what is expected, but also keeps that suggestion for the case when a message code is used. Of course, we could extend it even further to print more information like:
and
and
What do you think about those suggestions? |
While I like the principle of this change, the PR was never updated after the feedback by @gsherwood, so I'm marking it as a candidate for closure now. |
This change is a quality of life improvement. I wanted to exclude a sniff, namely
Generic.WhiteSpace.ScopeIndent.Incorrect
. This sniff code came from the phpcs report that showed an error I wanted to ignore. When I entered this, phpcs told me:So why is the sniff code invalid? After digging in the source code, I found that a sniff code may consist of only 2 periods.
With this change, the output will look like the following: