Common::getSniffCode(): be more lenient about sniffs not following naming conventions #676
+45
−16
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
Sniff classes should always follow the directory layout and naming conventions for sniffs as per the Tutorial.
However, before the change made in #524, when given a sniff class name for a sniff not following the naming conventions, the
Common::getSniffCode()
method would return a "sniff code" anyway. And even though the sniff code would be unconventional and not really valid, it would still work.Since #524 this is no longer the case.
Given the above, the change from #524 breaks custom rulesets which use
<rule>
includes for individual sniff files not complying with the naming conventions. Breaking changes can only be made in majors, so this commit reverts the problematic part of the change from #524.Includes additional tests safeguarding the (broken) behaviour which needs to be maintained (at least until the next major).
Suggested changelog entry
InvalidArgumentException
when a ruleset includes a sniff by file name and the included sniff does not comply with the PHPCS naming conventions.Related issues/external references
Fixes #675
Types of changes