configuration file
Hello,
in the moment i test PhpMetrics. I use PhpStorm with the PhpMetrics - Plugin. I will write my own config file for PhpMetrics. For example i have a ' .phpmetrics.yml ' file under the document root of my project.
I will change the measure for the maintainability index. --------------------- .phpmetrics.yml ----
default: rules: cyclomaticComplexity: [ 10, 6, 2 ] maintainabilityIndex: [ 0, 95, 99 ]
failure: average.maintainabilityIndex < 50 or sum.loc > 10000
path:
directory: src
extensions: php
exclude: features|tests
logging:
report:
xml: ./_log/phpmetrics.xml
html: ./_log/phpmetrics.html
csv: ./_log/phpmetrics.csv
violations:
xml: ./_log/violations.xml
chart:
bubbles: ./_log/bubbles.svg
It does not work !
Where can I find the default settings?
Your sincerly
Stephan
Hi,
v2 does not support configuration files yet. Do you use PhpMetrics v2 ?
Hi Halleck,
Same problem here, i want to block a CI if class / method are too complex, and .phpmetrics respond well for this job :) did you know when we can use this feature for v2 ? :)
Thanks for all your awesome job :+1:
Added support for passing configuration options via config files instead of command line for now in #303
so the ".phpmetrics.yml" is not valid anymore? Is there a example for a ".phpmetrics.json" config?
I don't know if this config is 100% correct, but this is what I have found in the code: ".phpmetrics.json"
{
"extensions": [
"php"
],
"exclude": [
"infra",
"tests",
"composer",
"archiv",
"vendor",
"thirdparty",
"generated",
"tmp"
],
"report-xml": "./build/report/phpmetrics.xml",
"report-html": "./build/report/phpmetrics.html",
"report-csv": "./build/report/phpmetrics.csv"
}
phpmetrics.phar --config="build/.phpmetrics.json" src/bar,src/foo
Examples are in the commit: https://github.com/phpmetrics/PhpMetrics/pull/303/commits/7bebaba683dad4710b720f4f63ed52c971cc06cb#diff-713f164f2a0941b2e1b0bff3a95b0256
@FractalizeR but in this example I see "exclude" as string but in the code it will expect an array (https://github.com/phpmetrics/PhpMetrics/blob/master/src/Hal/Component/File/Finder.php#L55) ... also in the example there is only the html- and the exclude-option, are this the only valid options?
ok, if some finds this e.g. via google (phpmetrics +exclude)
-> this is working: https://github.com/phpmetrics/PhpMetrics/blob/1a3c100891fe60e401fb0b2c136a689eecb398c3/src/Hal/Application/Config/Validator.php#L33
{
"extensions": [
"php"
],
"exclude": "infra,tests,composer,archiv,vendor,thirdparty,generated,tmp",
"report-xml": "./build/report/phpmetrics.xml",
"report-html": "./build/report/phpmetrics.html",
"report-csv": "./build/report/phpmetrics.csv"
}
What about failure configuration? I want to stop jenkins when a specific metric fails, i didnt find nothing about it in .json configuration files, only in yml. It is still possible?
What about failure configuration? I want to stop jenkins when a specific metric fails, i didnt find nothing about it in .json configuration files, only in yml. It is still possible?
There is now a way to to that.
For instance, this configuration makes fail PhpMetrics in case of any class having a too low Maintainability Index (60, for instance):
{
"searches": {
"Unacceptable Maintainability Index": {
"type": "class",
"mi": "<60",
"failIfFound": true
}
}
}
Tested on v3.0.0-rc4 and working as expected.
I'm closing the issue as original question was irrelevant (asking for a configuration file when PhpMetrics wasn't able to manage some yet) and derivated questions are now answered. If you want to ask something new related, please open a new issue.