Runner: allow suppressing "No files were checked" error
Description
Fixes https://github.com/squizlabs/PHP_CodeSniffer/issues/3556
Suggested changelog entry
Added --allow-empty-file-list argument to suppress "No files were checked error".
Related issues/external references
Fixes https://github.com/squizlabs/PHP_CodeSniffer/issues/3556
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] This change is only breaking for integrators, not for external standards or end-users.
- [ ] Documentation improvement
PR checklist
- [x] I have checked there is no other PR open for the same change.
- [x] I have read the Contribution Guidelines.
- [x] I grant the project the right to include and distribute the code under the BSD-3-Clause license (and I have the right to grant these rights).
- [x] I have added tests to cover my changes.
- [x] I have verified that the code complies with the projects coding standards.
- [ ] [Required for new sniffs] I have added XML documentation for the sniff.
- [ ] I have opened a sister-PR in the documentation repository to update the Wiki.
@schlndh Thanks for this PR.
Some feedback:
- Please include what you are trying to fix in the PR description. Your arguments in https://github.com/squizlabs/PHP_CodeSniffer/issues/3556#issuecomment-3393265341 make some sense, but should be included in the commit message.
- I'm not keen on adding this as a full-on CLI option. I believe this should be handled via a config option, same as other flags which influence the exit code. Can you explain why you added a CLI option instead of a config option ?
@jrfnl
Can you explain why you added a CLI option instead of a config option ?
I plan to use it as a config option via <arg name="allow-empty-file-list"/> (mainly because of Phpstorm). But IMO having it as a configuration option only seems a bit inflexible. The default behavior makes sense if you run phpcs manually. So I can imagine someone adding --allow-empty-file-list to CI scripts, git hooks, ... but keeping the default behavior otherwise.
I plan to use it as a config option via
<arg name="allow-empty-file-list"/>(mainly because of Phpstorm). But IMO having it as a configuration option only seems a bit inflexible. The default behavior makes sense if you run phpcs manually. So I can imagine someone adding--allow-empty-file-listto CI scripts, git hooks, ... but keeping the default behavior otherwise.
And that's perfectly possible with a config flag, just as well as with a CLI option, so I don't see why that would be a reason to have a CLI option.
For reference for anyone coming across this PR and wanting to understand the larger context:
- https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Version-4.0-User-Upgrade-Guide#my-scans-are-failing-on-a-no-files-were-checked-error
- https://github.com/squizlabs/PHP_CodeSniffer/issues/1595
- https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/1023