-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Enhanced support for nested rulesets #380
Comments
This sounds loosely related to #126, though more than anything, it feels that this is about understanding how rulesets work. I can see two solutions here:
<rule ref="Inpsyde"/>
<rule ref="Inpsyde.CodeQuality.NoElse">
<exclude-pattern>*/templates/*</exclude-pattern>
</rule>
Note: while looking at this, I checked out your repo and there are more problems with it, including the standards not complying with the naming conventions set out by PHPCS, which can cause problems with the autoloading and configuration. |
Thanks a lot for your fast feedback!
Perhaps it's the only way to go.
Unfortunately, it doesn't work. I tested your suggestion, and it works exactly as my Option 1 (even a bit worse because of using severity). This is the debug output from ignorePatterns PHP_CodeSniffer/src/Files/File.php Lines 464 to 480 in 8b83793
ignorePatterns property all those sniffs will be ignored for templates directory.
includePatterns It means So as I can see, it's impossible to
Thanks for the hint. We considering refactoring now 😄 . |
@shvlv Sorry, my bad. I'll have another think about this. |
Is your feature request related to a problem?
The use use-case we are trying to implement is described here - inpsyde/php-coding-standards#81.
In short, we want to introduce template-specific sniffs. It's easy to do with the
include-pattern
property:But during the discussion, we decided to make
InpsydeTemplates
extend the existingInpsyde
standard but several sniffs. So theInpsydeTemplates
config is:But it seems it's not possible to do what we want to provide proper setup at the consuming package. There are several options:
Option 1
It does not work because no Inpsyde specific and imported sniffs are applied to
templates
directory.Option 2
Imported
Inpsyde
rules are applied totemplates
but custom sniffs not.Option 3
It's very close to what we need. The single problem is
Inpsyde.CodeQuality.NoElse
is still applied totemplates
what we want to avoid.Option 3a
The consumer config is the same as above.
The
InpsydeTemplates
config is:Inpsyde.CodeQuality.NoElse
rule is disabled for whole package.Describe the solution you'd like
Make the
include-pattern
(and maybeexclude-pattern
) directive more sophisticated. We can useinclude-pattern
to exclude/include sniffs or to define different sniff severity per-directory (regexp).Additional context (optional)
I briefly checked the PHPCS codebase and saw it's impossible now and may require much effort. After processing all rulesets, we get independent maps of include/ignore patterns and severity per sniff. If so, maybe we can just stick with Option 3. But maybe I missed something.
Thanks a lot for maintaining such an important project!
The text was updated successfully, but these errors were encountered: