-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Improve error message for an invalid sniff code #344
base: master
Are you sure you want to change the base?
Improve error message for an invalid sniff code #344
Conversation
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.
Thanks for this PR @fredden.
Unfortunately, there are no pre-existing tests covering the changes, so new tests will need to be written to cover this change - as the line you removed from the "PR checklist" pointed out... (that checklist item is there for a reason... I've added it back now)
Some observations when I look at the behaviour around this error message:
- If multiple erroneous names are passed via the
--sniffs
option, only the first error is displayed, so the user fixes that one, runs PHPCS again and will then be confronted with the next error.
I believe this should be made more user friendly. - If the list of sniffs contains a stray comma, like
--sniffs=A.B.C,,D.E.F
, this will be reported as "The specified sniff code "" is invalid".
I believe we can filter out/ignore empty sniff codes altogether without bothering the end-user with this.
As this PR introduces a dedicated method to validate the sniff codes (👍🏻), I think we should take this opportunity to make the fix comprehensive.
Other than that, I find the messaging a bit "wordy", so I wonder whether it can be made more succinct.
I have discussed this with @jrfnl. I intend to add tests to cover the existing behaviour in a separate pull request. I'll mark this as a draft until that change is complete. I'll come back to this when that change is done and make any necessary changes here at that time. |
5fa0d0e
to
1665e40
Compare
…niff-code-error-message
Description
This is an implementation of the suggestions made by @gsherwood in squizlabs/PHP_CodeSniffer#2646 (comment)
I have intentionally not looked at the code changes initially suggested in squizlabs/PHP_CodeSniffer#2646 (to avoid any copyright woes).
Suggested changelog entry
Improved error message when invalid sniff codes are supplied to
--sniffs
or--exclude
command line arguments.Related issues/external references
Replaces / closes squizlabs/PHP_CodeSniffer#2646
Related to #319
Types of changes
PR checklist