The Wiki on GitHub suggests that I can make phpcs not account for warnings in the process' exit code. This is suggested with
$ phpcs --config-set ignore_warnings_on_exit 1
However, this makes a change in myproject/vendor/squizlabs/php_codesniffer/CodeSniffer.conf. This file is not under source control and will not be shared by the team, and (if I understand correctly) the preferred way to write configurations is phpcs.xml.
Is it possible to make this and similar other configurations in phpcs.xml? If so, apologies if I missed to see where in the docs this has been written down.
This discussion is indirectly related to https://github.com/squizlabs/PHP_CodeSniffer/issues/2062
Based on your question, I'd say you have a couple of options:
--runtime-set ... instead. This will ignore the warnings for the exit code _for that particular run only_ and no changes are made to the CodeSniffer.conf file..travis.yml script - which is under version control -.scripts section of the composer.json file with the precise command you want your team to use. The team could then call, for instance, composer check-cs and be assured everyone will use the same command-line parameters and as composer.json is (or at least should be) under version control, that side of things is covered too.config variables in your [.]phpcs.xml[.dist] file:xml
<config name="ignore_warnings_on_exit" value="1"/>
-n option. And yes, that can also be set in the custom ruleset.Does this help ?
Thanks! Both --runtime-set plus CI, and <config name="ignore_warnings_on_exit" value="1"/> can achieve what I was looking for.
I found the --runtime-set option earlier with just phpcs -h, but <config/> wasn't as obvious to me.
Most helpful comment
Based on your question, I'd say you have a couple of options:
--runtime-set ...instead. This will ignore the warnings for the exit code _for that particular run only_ and no changes are made to theCodeSniffer.conffile.Exit codes are generally only used by CI processes and such to determine whether to pass/fail a build, so you would only have that addition in the command you have in, for instance, your
.travis.ymlscript - which is under version control -.scriptssection of thecomposer.jsonfile with the precise command you want your team to use. The team could then call, for instance,composer check-csand be assured everyone will use the same command-line parameters and ascomposer.jsonis (or at least should be) under version control, that side of things is covered too.configvariables in your[.]phpcs.xml[.dist]file:xml <config name="ignore_warnings_on_exit" value="1"/>See: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset
-noption. And yes, that can also be set in the custom ruleset.Does this help ?