PhpMetrics
PhpMetrics copied to clipboard
Maintainability index in XML report
Hello,
I was wondering if it would be possible to include class maintainability index in the XML report. We are running phpmetrics on Jenkins CI and would like to use this information as a trigger to reject pull requests. For example, classes that have an index less than X would be considered errors, less than Y warnings etc. This would be analogous to the green/yellow/red spiral circles display on the dashboard.
Hi, thank you for using PHPmetrics ;).
This is something we can do ;). Will be done soon (as soon as I can spend some time on it).
Regards
Le 26 oct. 2017 à 14:30, Marko Kruljac [email protected] a écrit :
Hello,
I was wondering if it would be possible to include class maintainability index in the XML report. We are running phpmetrics on Jenkins CI and would like to use this information as a trigger to reject pull requests. For example, classes that have an index less than X would be considered errors, less than Y warnings etc. This would be analogous to the green/yellow/red spiral circles display on the dashboard.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hi @krukru and sorry for the very long delay.
If you're still interested in, since PhpMetrics 2.8, you can now define your how violation rules via a configuration file. You can see https://github.com/phpmetrics/PhpMetrics/blob/48039149adf0f19478846a9a22236f5e53d3c9e2/config-example.json on the section searches to get an idea on how to create your own violations.
In your case, you can give it a try with the following searches:
{
"searches": {
"Unacceptable Maintainability Index": {
"type": "class",
"mi": "<=X",
"failIfFound": true
},
"Warn about Maintainability Index": {
"type": "class",
"mi": "<=Y",
"failIfFound": false
}
}
}
(define your own values for X and Y).
Tested on v3.0.0-rc4 and working as expected.