-
-
Couldn't load subscription status.
- Fork 89
-
Hi,
We have pretty big and old project and we want to start using phpcs to somehow control formatting. The problem is that there are a LOT of violations and fixing it in one go is impossible :/
Is there a feature something similar to this one https://phpstan.org/user-guide/baseline ? I can see that the original project had
squizlabs/PHP_CodeSniffer#3387.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
@salacr No, as nobody has come up with a good design for such a feature. Also see #137.
Keep in mind that PHPCS includes a fixer and in most codebases, over 80% of violations can be auto-fixed in one go by running phpcbf over the codebase.
If the "LOT of violations" bit is about non-auto-fixable issues, there are still a couple of things you could do to get started without blocking builds:
- You could use the
--file-list=...feature - this allows you to scan a subset of the code base, so you can clean up files one by one until the whole codebase is clean. - You could start with the errors and ignore warnings completely for the time being by passing the
-nflag. Then once the errors are fixed, enable warnings. - You could choose to still show errors/warnings, but not let them influence the exit code of PHPCS.
- You could add a pre-commit hook for a project using the
--filter=GitStagedfeature. That way you force files which are actively being worked on to be cleaned up, while being tolerant about files which haven't been touched.
The Wiki contains more information about these options.
Hope this helps.
Beta Was this translation helpful? Give feedback.
All reactions
-
Got it thanks!
Beta Was this translation helpful? Give feedback.