cr2checkstyle
Convert complexity-report data to Checkstyle XML
This purpose of this command line tool is to convert the JSON output of complexity-report to Checkstyle-compatible XML.
Usage
cr2checkstyle reads from stdin
and writes to stdout
:
$ cr --format json --output report.json .
$ cr2checkstyle < report.json > report.xml
Or simply use piping:
$ cr --format json . | cr2checkstyle > report.xml
Configuration
By default, cr2checkstyle has no thresholds set so it will not generate any warnings or errors. Currently supported metrics are cyclomatic complexity, halstead difficulty and the maintainability index.
Thresholds are given as a low and high watermark. Values above the high watermark will cause errors, values between the low and high watermark will cause warnings (likewise for higher-is-better metrics such as the maintainability index):
$ cr2checkstyle --module-maintainability 80,90
$ cr2checkstyle --function-cyclomatic-complexity 2,4
Internally, parameters are parsed with yargs so you can also use environment variables (e.g., CR2CS_FUNCTION_HALSTEAD_DIFFICULTY=3,6
) and the cr2checkstyle
-property in your package.json
.