Add Mago as task#1216
Conversation
veewee
left a comment
There was a problem hiding this comment.
Thanks for the PR.
I think this task in current state is not in line with other tasks. I've added some remarks inline in the code. Feel free to stat a discussion.
|
Hey @veewee, Thanks for taking the time to review the PR and share your feedback. To be fully transparent, after opening the PR I had already started reworking it to introduce 4 commands. I’ll update the PR this week with those changes; it should end up closer to how the SecurityChecker tasks are structured, which should resolve the three threads. If you have any additional feedback, feel free to share it so I can address everything at once. |
|
Hey, I just pushed a refactor splitting the The Happy to hear any feedback — whether on the option coverage, naming, documentation, or anything else that could be improved. |
|
Thanks for the changes. |
|
No worries |
|
Hi @veewee, Thanks for all your feedback! I'm working through it bit by bit. I'll push a new version this weekend that incorporates your comments, and I'll also include answers to your questions. Talk to you soon. |
|
Hi, here is a summary of all the changes made based on your feedback.
|
Drop the abstract Mago base class in favour of four fully standalone tasks. The abstraction shared argument-building behaviour across all commands, but Mago only shares flags between lint/analyze, which forced guard and format through a fix/dry-run flow they don't support. - mago_lint / mago_analyze: dry-run detection, offer fix on failure by mutating the same arguments in the FixableProcessResultProvider closure (matching PhpCsFixer); fix aggressiveness via fix-mode. - mago_guard: no fix flow (guard auto-fix is a no-op in Mago) and no --staged (unsupported); structural/perimeter modelled as a single mutually-exclusive `mode` option (null = both). - mago_format: --staged is write-only, so pre-commit scopes via explicit staged files; run context checks the whole project via --dry-run. All emitted flags verified against the mago 1.30.0 CLI. Unit tests cover every option per task and assert the generated fix commands (including fix-mode). Adds a mago.md overview, updates per-task docs and fixes the tasks.yml indentation.
|
Hey @johnatas-x, Rather than going back and forth on the open threads another dozen times, I pushed a version of how I think the Mago tasks could look. Easier to react to something concrete than to keep describing it. The biggest change: I dropped the abstract While I was in there I lined the tasks up with how the rest of GrumPHP behaves (dry-run by default, offer to fix when it makes sense) and with what Mago actually supports. I went through every flag against the real Tests cover each option per task and the fix commands they generate, and the docs are updated to match. Could you pull it and try it on a real project, especially the pre-commit runs? Want to make sure it behaves the way you'd expect on a setup more complete than mine. If it feels right to you, I'll get it merged. |
|
Hi @veewee, Thank you for the effort you've put into this. I'm going to review your changes to better understand the approach and improve my own work going forward. I'll test the branch on three real projects during the course of next week and will get back to you with feedback based on those tests. |
This PR adds a Mago task
Mago is a recent tool that includes a formatter (like phpcs), a linter (like phpmd), and a static analyzer (like phpstan).
It is known for its performance and is starting to be increasingly adopted (for example, in Drupal).
Its integration into GrumPHP seems valuable.
New Task Checklist:
run()method readable?run()method using the configuration correctly?