Problem/Motivation

When Coder is installed locally (using a fork of GitHub, or via download) then Composer install is run, we get a vendor directory, as expected. However, this means that running the simple phpcs . from the coder root folder includes all files in and beneath the vendor directory. This not only slows down the process but returns hundreds of coding standards messages that the developer is not interested in, and masks the few important ones that are of interest.

Proposed resolution

Exclude the vendor directory by adding <exclude-pattern>/vendor/</exclude-pattern> to phpcs.xml.dist

CommentFileSizeAuthor
#2 3168068-2.exclude-vendor.patch635 bytesjonathan1055

Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

Status: Active » Needs review
StatusFileSize
new635 bytes

Patch to do this. I also added <arg value="s"/> to automatically display the full sniff name (which is very helpful when developing Coder).

I can make a PR for this if required.

arkener’s picture

Coder uses an inclusion list based setup to ensure that we only check the actual rules and test files. This list can be used by using the phpcs command (or ./vendor/bin/phpcs if PHPCS isn't installed globally) omitting the . argument. This way the vendor directory should already be excluded from the sniff results.

The issue with adding default arguments via the xml file is that there is no way to override these arguments when using the command line (except for color, which can be disabled by adding --no-colors). An easy way to apply these arguments to your development environment would be by copying the phpcs.xml.dist file to phpcs.xml and adding the arguments there.

jonathan1055’s picture

Thanks Arkener, that's helpful. I did not realise that if I run just phpcs without the . then the files to check are limited by what is specified in the phpcs.xml.dist - I don't know why I did not realise that. It works perfectly.

For the default parameters, yes I totally get your point about not adding to the file, that's fine. So now I have my own phpcs.xml file, but instead of duplicating the .dist file what I am trying to do is use <xinclude> to include all info from the .dist file, then add my own custom parameters. But it is not working.

So I have just made an alias in my profile for alias pcs='phpcs -s --colors' which does the trick.

klausi’s picture

Status: Needs review » Closed (works as designed)

Perfect, totally agree with you both and I think Jonathan has found an acceptable solution for his workflow.