-
Hi everyone! I'm relatively new to phpcs since in the past, I only relied on php-cs-fixer, but now, our team wants more detailed linting (even for non automatically fixable issues). Working with php-cs-fixer, you can specify specific files to fix (alongside an intersection argument to make sure you only fix files that match your config). This is really handy for targeted linting/fixing, such as pre-push (or pre-commit) hooks and pull request pipelines (only lint files that are part of the PR). Now I tried to look around PHP CodeSniffer docs to try and find the same feature, but to no avail. It seems like the most popular approach is oriented towards file/directory exclusion rather than inclusion/intersection. Does this "lint only the specified files" feature exist on PHP CodeSniffer? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi, while I've not tried many of them, it seems that there are various alternatives to be able to effectively define the exact files to be checked. The https://github.com/phpcsstandards/PHP_CodeSniffer/wiki/Usage
I imagine that with some of those alternatives, maybe together with Hope it helps, as commented above I haven't used much any of those alternatives, but they look like viable alternatives. Ciao :-) PS: What we use to do in our CI jobs (don't know if that's your case) is to proceed to remove all the unmodified files, only keeping the modified files corresponding to the branch being checked ( |
Beta Was this translation helpful? Give feedback.
-
FYI: While it doesn't directly address this issue, PR #447 is a proposal to improve the help screens, including improved information on the help screen about how to specify which files should be scanned. Reviews and testing of that PR would be appreciated. |
Beta Was this translation helpful? Give feedback.
Hi,
while I've not tried many of them, it seems that there are various alternatives to be able to effectively define the exact files to be checked. The
--help
shows a bunch of them:https://github.com/phpcsstandards/PHP_CodeSniffer/wiki/Usage
phpcs /path/to/this.php /path/to/that/dir ...
).phpcs --file-list=/path/to/file_list.txt
).phpcs --filter=/path/to/filter/class
).I imagine that with some of those alternatives, maybe together with
--ignore
, you can accurately define the exact files/dirs to be checked without to…