nunomaduro / phpinsights

🔰 Instant PHP quality checks from your console
https://phpinsights.com
MIT License
5.28k stars 281 forks source link

Run phpinsights, returning a boolean value (true/false) if all checks pass #681

Open kirkbushell opened 4 months ago

kirkbushell commented 4 months ago
Q A
Bug report? no
Feature request? yes
Library version 2.11.0

We're looking to run phpinsights on a git commit prehook, so that if there are issues with a file about to be committed, the commit is prevented. This is currently not possible, so ideally adding an additional format could be a way of doing this - adding a new format called "boolean" which when run in the console and exits with an error. This can then be picked up in scripts and prevent the commit from occurring.

It is our view that this is quite important in order to prevent issues before they even reach the codebase. --fix is not an option here, as we're also looking to help educate our team, not just sweep any issues under the rug (it would also be quite odd for engineers to see that their code had changed once they viewed it on github).

kirkbushell commented 4 months ago

Or better yet, just have a parameter that allows the code to exit with an error if a check doesn't pass minimum requirements.

fkandus commented 4 months ago

@kirkbushell I think this is already possible. I'm using the following parameters:

--no-interaction --min-quality=$min_quality --min-complexity=$min_complexity --min-architecture=$min_architecture --min-style=$min_style

kirkbushell commented 4 months ago

@fkandus oooh, okay I'll give that a go - ty! :)