Editor inspection not using custom phpcs ruleset
I'm trying to run a custom PHPCS ruleset on a WordPress plugin and a theme. My phpcs is installed locally as a /vendor directory in the root directory for the plugin and theme.
[plugin/theme dir]/vendor/bin contains both phpcs and phpcs.bat (I'm on a Windows machine and prior to getting PhpStorm I have been running phpcs from Git Bash, but PhpStorm is only able to validate the phpcs.bat file, understandably)
I've read through the documentation here: https://www.jetbrains.com/help/phpstorm/2016.3/using-php-code-sniffer-tool.html but admit I find it to be confusing to understand.
My ruleset.xml is located inside the root directory (i.e., the directory where functions.php would reside in a theme), and it's that path I specify in Settings > Editor > Inspections > PHP Code Sniffer validation > Coding standard > Custom Coding Standard
I can verify that my ruleset works, because I can run the following, for example, in Git Bash:
$ ./vendor/bin/phpcs -s --standard=/path/to/ruleset.xml functions.php
That works as expected. But the editor inspection is not picking up this ruleset, and is still flagging parts of my code for sniffs that I excluded in my XML file. Or, if it is using the ruleset but throwing errors, those errors are not getting written to the PhpStorm event log, which seems unlikely but I suppose is possible.
I can't seem to figure out how to resolve this. I've checked JB docs and PEAR, and still not sure what the problem is. Has anybody experienced this issue?
Please sign in to leave a comment.
First of all you might try to check one of our tutorials here: https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Sniffer+in+PhpStorm
Second, "the editor inspection is not picking up this ruleset" - do you mean that you've enabled PHP Code Sniffer validation in File | Settings | Editor | Inspections but it acts like it doesn't work?
What if you run Code > Inspect: would it show PHPCS inspection results?
Yes, I've looked at that tutorial and everything seems to be in order.
Yes, I've enabled the PHP Code Sniffer in Inspections and it doesn't respect my custom ruleset.xml
Yes, Code > Inspect shows PHPCS results.
I just made some screenshots this morning; I've attached them.



Here's the ruleset:
And here's my settings:
Here's the editor:
And here's the result of Code > Inspect:
You can see that PHPCS can run, but it's not using my custom ruleset.
Is there anything else I should try?
Eventually found the problem after restarting. PhpStorm had constructed & cached a bad path to the ruleset. Once I specified the correct path in the settings and restarted, the custom ruleset worked fine.
Sorry for missing previous update from you. Glad this is working now!