I have a custom phpcs ruleset file, where I am including a couple of rulesets and also excluded files from certain directories like tests or vendor.
The full phpcs.xml config file is at https://github.com/sudar/bulk-move/blob/master/phpcs.xml Below I have mentioned the interesting bits
<file>./</file>
<!-- Exclude test directories -->
<exclude-pattern>tests/*</exclude-pattern>
<!-- PHP Compatibility -->
<config name="testVersion" value="5.2-"/>
<rule ref="PHPCompatibility">
</rule>
Now when I run phpcs
command from the root of my project, it excluded the files from tests directory and runs phpcs only on the other files.
In PhpStorm I have selected this phpcs.xml file as the custom coding standard while configuring phpcs. But when I am editing a file from the tests directory (that is excluded) PhpStorm still calls phpcs with the custom coding standard and show warnings.
So my question is how to tell PhpStorm to exclude the files that are excluded in the phpcs.xml ruleset file?
<exclude-pattern>
is not currently supported.
https://youtrack.jetbrains.com/issue/WI-22102 -- watch this ticket (star/vote/comment) to get notified on any progress.
Right now you can exclude files from PHPCS processing .. but it must be done manually in IDE.
PHP CodeSniffer integration (displaying the validation results) is done as an Inspection .. so you can configure it (enable/disable) on per scope basis:
Settings/Preferences | Editor | Inspections
PHP | PHP Code Sniffer validation
)tests
folder as Tests Root
in Project View panel (or Settings/Preferences | Directories
.. or maybe it was auto-detected from composer.json file) then such folder is already a part of standard "Tests" scope)Settings/Preferences | Appearance & Behavior | Scopes
and then use it there.Some links: