PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

PHPCS exclusion list

Open truls1502 opened this issue 7 years ago • 5 comments

It might be a duplicate of #1884 - but I am looking for a way to tell my PHPCS that they can ignore exactly same what it is listed on .gitignore. It will save a lot of time. Also, I would like to have a file which I can tell import .gitignore, and we can also add more in the list which is not filled on .gitignore.

What do you think?

truls1502 avatar Nov 24 '18 16:11 truls1502

An option in the ruleset XML format to import a list of files/directories to exclude, which would allow you to specify your .gitignore file, might work. I don't think I'd want a dedicated CLI option to do this though.

gsherwood avatar Nov 25 '18 21:11 gsherwood

@gsherwood, the option sounds a good idea. Do you have an example about how to import a list of file/directories to exclude in the ruleset XML format?

truls1502 avatar Nov 26 '18 11:11 truls1502

Do you have an example about how to import a list of file/directories to exclude in the ruleset XML format?

Nothing currently exists in PHPCS to do this.

gsherwood avatar Nov 27 '18 02:11 gsherwood

We would need something like this exactly in Drupal also. Did some digging and maybe if the excluded list of directories could be also specified in the CodeSniffer.conf file (https://github.com/squizlabs/PHP_CodeSniffer/blob/3.4.2/CodeSniffer.conf.dist) then a composer-plugin could automatically registers exclusion paths in a project from various sources, for example .gitignore(s), environment variables, etc.

https://github.com/Dealerdirect/phpcodesniffer-composer-installer plugin uses this file to auto-register available PHPCS configurations. The suggested composer plugin could also do the same with excluded paths.

mxr576 avatar Jul 29 '19 06:07 mxr576