-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phpcs option for auto fixing or prompt to fix #663
Comments
Hi @hkirsman, Thanks for reporting. Please check: I suggest you run phpcbf once on the complete codebase if you want to fix the code style everywhere. |
@veewee I understand the philosophy but this particular feature would only run the command if you would say yes. Then you would need to still git add and review the changes. How is that different from adding command at the end of the report that you can copy/paste and fix the code? :) |
Haven't thought about it that way. Fixing code AFTER all validations ran might be a nice addition. |
I think current way of printing out command to auto fix is a bit cumbersome:
Instead for example I have bash script that prompts for y/n if Codesniffer finds issues and in the output it says that some of the issues can be fixed automatically. If you press y, then phpcbf is ran with the same rules as was phpcs.
Other option would be to add some parameter in the config to always automatically fix the issues if possible.
We have really legacy code and it has too many issues. Copy pasting is an extra step if know we want to run phpcbf always.
Could we implement something like that?
Here's part of the code to do that:
PHP equivalent package is here: https://github.com/hkirsman/code-quality-phpcs/blob/master/bin/phpcs_phpcbf
This unfortunately does not work if another scripts calls it as prompt will just continue without waiting for input. I think this could work if GrumpPHP would execute prompt in main thread.
My configuration
phpcs.xml (just because it's in my setup, nothing important related to the issue):
The text was updated successfully, but these errors were encountered: