Closed kubawerlos closed 4 years ago
Sorry, I missed the notification for this issue.
You are correct, files without an extension are filtered out and the bin
directory of PHPCS is not actually checked during a test run.
There is no way to tell PHPCS to check files without an extension. Having PHPCS pick up files with no extension by default would break quite a lot of test runs, so that's not something I want to do. I think that specifying the file path directly would be fine though.
I'm going to throw this on the 4.0 roadmap because I've removed JS and CSS tokenizing support there, which lets PHPCS assume that all specified files are PHP files - as it originally did. This makes re-introducing support for files with no extension much easier.
I've changed the behaviour of PHPCS in the 4.0 branch so that files with no extension are checked if you pass in the path directly on the command line, or via a ruleset <file>
tag. I've also updated the PHPCS ruleset to specify the 2 files in the bin
dir so they are checked now.
Thanks @gsherwood
@gsherwood is there a chance this can be backported to v3? It has been 3 years since this was raised and v4 is still not out. This functionality is important to scan single-file php scripts.
I want to add a single file without extension (or with a name starting with a dot), but cannot achieve this. Neither with
<file>
in XML or with the command line.E.g. when I run
./bin/phpcs ./bin/phpcs ./src/Config.php
in this repo the output is1 / 1 (100%)
, where the1
is for the latter file.I've found this: https://github.com/squizlabs/PHP_CodeSniffer/blob/3.5.4/src/Filters/Filter.php#L168 and this implies that this line: https://github.com/squizlabs/PHP_CodeSniffer/blob/3.5.4/phpcs.xml.dist#L6 is useless, right?