PHP_CodeSniffer: Report warnings but return a zero exit code
I want to report to console/checkstyle any warnings, but I do not want the exit code to be > 0. Currently warnings are returning a 1.
All I could find was suppressing but this means nothing is output.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 20 (11 by maintainers)
Commits related to this issue
- PHPCS can now exit with 0 if only warnings were found (request #262) — committed to squizlabs/PHP_CodeSniffer by gsherwood 10 years ago
I’ve committed this feature now. It’s only in the 2.x version because it changes the return value of the main printReport() method, which is a bit risky.
To use it, run PHPCS like this:
phpcs --runtime-set ignore_warnings_on_exit true /path/to/codeAdding a comment because this issue came up in google before the wiki page. The option for this is now set using --config-set instead of --runtime-set as mentioned in this issue. The wiki has the correct commands listed, but it took me a bit to realize it was different:
Here are the current correct flags:
Thats fine for errors, but I dont want it to happen with warnings
Another note to fellow search engine users –
ignore_warnings_on_exitandignore_errors_on_exitare only supported byphpcs, notphpcbf. (More specifically, the options are still parsed and result inRunner::run()returning 0, butRunner::runPHPCBF()ignores the return value ofRunner::run()and instead returns exit codes based on the number of fixed/fixable errors in$this->reporter.)