phpro / grumphp

A PHP code-quality tool
MIT License
4.15k stars 431 forks source link

Possibility to override the error message on tasks #752

Closed Taluu closed 3 years ago

Taluu commented 4 years ago
Q A
Version latest one ?
Bug? no
New feature? yes
Question? no
Documentation? no

For each tasks, instead of having a default error message (e.g the branch naming for example), having the possibility to define a custom error message would be awesome. Soething along these lines :

parameters:
  tasks:
    git_commit_message:
      blacklist:
        - my
        - list
      whitelist:
        - my
        - whitelist
      message: "Overriding, you do not have a correct branch name. We are following the pattern [....]"

Could try a PR for that. Thoughts ?

R2c commented 4 years ago

maybe a message_error enable for all tasks?

Taluu commented 4 years ago

Not sure having a global message_error would be pertinent, as it would best IMO to have a specific message for each tasks.

Buuut we could have a message parameter that is displayed if any tasks fail to be printed below the report or something ?

veewee commented 4 years ago

Hello @Taluu,

Thanks for the suggestion. I am not sure I fully grasp the concept. In most cases you do want the output of the executed command to know what went wrong right?

I am currently working on a new task runner system (quite big!) https://github.com/phpro/grumphp/pull/741 Once that system is in place, we can do this kind of things in an easier way as we can do it in the current codebase. For example by adding metadata to the task. So about providing a PR : maybe better to wait a while :)

Taluu commented 4 years ago

Not the output of the command, just the ability to override the error message. If I take back my example for the brnch name. We currently have the first "Version" (a custom git hook), where we print a nice message if the branch is not up to our standard)

image

So instead of printing the whitelist pattern which can get pretty big and unreadable, to print the nice message we have when using the custom hook.

And ok to wait for the PR to be done first. :}

veewee commented 4 years ago

Just wanted to let you know that I finished #741, so you can build on top of that!