I've set up PHP Storm to use phpcs and show me in the IDE when I've violated a style.
However, I'd like to disable this for view files -- they often contain bits of PHP mixed with HTML that don't match the style guide, and I don't care in a view file.
In the options, I see a list of excluded files in the phpcs settings, but it only has buttons to remove a file or clear the whole list, but no way to ADD files to it.
Am I missing it somewhere?
With the following comments you can ignore whatever part of a file you would like. With // phpcs:ignore and // phpcs:disable you can also specify which messages, sniffs, categories or standards you would like to disable, for example: // phpcs:ignore Squiz.
In the Settings dialog, go to Editor > Inspections. From the inspections screen, expand the PHP | Quality tools node and enable “PHP CodeSniffer validation”. In the configuration pane that is now enabled, select “Custom” from the “Coding standard” dropdown, locate the ruleset configuration ( phpcs.
Code Sniffer is a static test that uses static code analysis to detect violations of the Magento Coding Standard to prevent common coding errors.
Code Sniffer (as well as Mess Detector) integration is implemented in form of an Inspection which can be configured to be ON or OFF based on scope. Therefore:
Settings | Scopes
-- create new custom scope and include all unwanted files/folders
Settings | Inspections | PHP | PHP Code Sniffer validation
-- right click on it and choose Add Scope
Now configure this inspection: turn OFF (uncheck) for that scope and leave ON for "Everywhere else" entry.
P.S. PhpStorm v8 has Inspections settings screen a bit redesigned; therefore steps are tiny bit different, but still the same overall (now it's easier for user to discover "scopes" functionality).
This has been tested for PHPStorm 2017.*
Settings/Preferences | Keymap
find Add to PHPCS ignore list key and add Keyboard Shortcut
Go to the file, which one you want to add as ignored and use the shortcut
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With