Search code examples
phpphpcs

PHPCS exit code based on threshold


Im trying to implement PHPCS in my project which has an huge technical depth. I have for example one module with 378 sniffs (both errors and warnings combined). However the fact is that i also have like 29 modules which makes it nearly impossible to finish this technical depth in a short period of time.

What i want is to keep it at least stable so that one of the teams can keep developing where the other can clean up some mess on the spot. The question is how can i enable PHPCS scans but for example let if only fail when it hits more than 378 hits in this case on that module. This way i can ensure that my depth stays the same and a long the way i can ensure that it will be lowered.

As far as i can see the only way with PHPCS itself is to set the severity levels and let it break on there but i'd rather stay as close as possible to the default coding standards and keep it as strict as possible.

Thanks a lot

Pim


Solution

  • I build an own script like Greg above also mentioned that checks the outcome of the --report=summary via a regex. The regex outcome then determines the exit code 0 or 1 from there.

    Would be helpfull if PHPCS could do something like that itself but its not there