Sean
Sean

Reputation: 1678

How do I make phpcs ignore some files in PHP Storm?

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?

Upvotes: 19

Views: 8356

Answers (5)

frankfurt-laravel
frankfurt-laravel

Reputation: 4131

Update, as of November, 2019 ... now you can completely ignore files.

Settings > Inspections > PHP > Quality Tools > PHP Code Sniffer

then

Check files with extensions: Remove unnecessary like js, inc

Upvotes: 3

Fonant
Fonant

Reputation: 397

You can customise the toolbar to include a button for the "Add to PHPCS ignore list" action.

  1. View > Toolbar to display the toolbar if it's hidden.
  2. Mouse-right on toolbar, then "Customise Menus and Toolbars".
  3. Select "Main Toolbar" and add the action as a button.

Or customise the Editor Tab Popup Menu and add "Add to PHPCS ignore list" there (It'll be hidden for files already on the list).

Upvotes: 1

Hayk
Hayk

Reputation: 459

This has been tested for PHPStorm 2017.*

  1. Settings/Preferences | Keymap

    find Add to PHPCS ignore list key and add Keyboard Shortcut enter image description here

  2. Go to the file, which one you want to add as ignored and use the shortcut enter image description here

Upvotes: 6

Gregoire
Gregoire

Reputation: 3775

With PHPStorm 8, you can find the Code Sniffer settings panel in:

Settings | Languages and Frameworks | PHP | Code Sniffer

In this panel, you will find a list of ignored files.

Edit: with PHPStorm 2016.x, this list is read only, you can't add ignore files this way.

Upvotes: 3

LazyOne
LazyOne

Reputation: 165168

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:

  1. Settings | Scopes -- create new custom scope and include all unwanted files/folders

  2. Settings | Inspections | PHP | PHP Code Sniffer validation -- right click on it and choose Add Scope

  3. 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).

Upvotes: 26

Related Questions