moodle-plugin-ci icon indicating copy to clipboard operation
moodle-plugin-ci copied to clipboard

RFC: Create new "codefixer" Command

Open stronk7 opened this issue 4 years ago • 1 comments

Right now we have the codechecker command that reports all the issues found by phpcs. This is useful locally and @ CIs.

Also, there is the codecbf command that also runs phpcs but in fix mode, changing as much as possible. Always exiting without error (exit code = 0). This is useful locally, but not much @ CIs.

So this is a proposal to create a new codefixer command, pretty much like the codecbf one (in fact it could end replacing it, more below) with the following features:

  • Run the phpcs fixer.
  • If there are changes performed exit with error.

So the proposal is as follows:

  1. Create new codefixer command.
  2. Make it exit with error if fixes have been applied.
  3. Allow it to always exit without error (via switch), so we can, one of: A) remove current codecbf command completely. Or B) keep it, but making it to call to the new command with appropriate switch.

That way, for people wanting to add it, it will ensure that as much as possible of phpcs detected problems have been fixed (interesting for CI) and, still, for people just wanting to run it (as part of local dev process or other automations) ignoring the exit status, there will be a switch available.

Ciao :-)

Edited: Surely will have to be done together with #74

stronk7 avatar Jan 29 '21 10:01 stronk7

Just noting that, since recently we have:

  • phpcs command, with codechecker as alias.
  • phpcbf command, with codefixer as alias.

And, at some point, the aliases will be deprecated / removed.

Not closing this, because the idea of having the phpcbf (codefixer) command having configurable exit code is still valid. Just sharing the "reserved words" (command names and aliases) that we have right now.

Ciao :-)

stronk7 avatar Mar 08 '23 22:03 stronk7