-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Commit pre-hook misbehaving #1404
Comments
Maybe to add For this file:
It say "PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY", but can not (here). |
I have tried a combination of phpcs & phpcbf, with results along the lines you show. It seems to me that phpcs/cbf are getting confused with the braced nesting of arrays in this particular test class, and giving up. There were another 18 classes that were "fixed" without question. |
I have found a single method in each of the "offending" classes that can be commented out to force a "pass"... RouterTest:testMatchedRouteOptions() and RouteColelctionTest::testRoutesOptions(). |
An anomaly that might be affecting things? |
Workaround for RouterTest is to declare the options before adding a new rule to the route collection.
This is a workaround, not a solution, and smells bad :( |
Another example of a suspect configuration inside PHPCBF ... it is inappropriately aligning subesquent assignment statements on the = sign, violating any reasonable line length rule. Example:
|
Good points - and something that needs to be addressed in the CodeIgniter4-Standard repo. I think the last one is in our code style guide, but in situations like that it can cause issues. I tried the other day to go through and run the fix on everything in the system, which caused a few errors but, unfortunately, haven't had the time to go back and see what was causing it. Something in the database libs. Should we revert the auto-fix on this for the time being? |
I have no problem with autofix being on or off - it will get sorted out in the long run, by touching everythng and letting it do its thing. I do like the idea of clean code being forced for commits - we just need to make sure that the "cleanliness" is correct :) I see two problems to address:
Even if PHPCBF's syntax checking doesn't get fixed (re #1), as long as we know about it, we can work around that. We might need some directions in the admin or contributor docs about working around such issues, but that feels like overkill. Bottom line, after a long-winded think - I would leave the autofix on. I think it is something that contributors should get used to, and we will need to work on updating or tweaking the standard (not a top priority). |
Punting this over to the coding-standard repo as two bugs |
The recently added PHPCBF pre-commit hook is great to a point, and then it isn't.
Sample output:
You will notice the clear indication of just what needs fixing? Me neither :(
I encounter this issue with mods made to tests/system/Router/RouterTest.php.
I can comment out everything, and then uncomment it one method at a time, and all goes well until the next attempt at a commit, and the above re-appears.
PHPCBF is re-formatting the code, and not per our guidelines, as far as arrays go. I can live with that, sorta, but I can't live without the ability to commit.
Anyone else seen this?
The code reformatted by PHPCBF that produces the above is attached.
RouterTest.php.zip
The text was updated successfully, but these errors were encountered: