cr2checkstyle
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"env": { | ||
"browser": false, | ||
"node": true, | ||
"commonjs": true, | ||
"es6": true | ||
"commonjs": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"rules": { | ||
"max-len": [ | ||
"error", | ||
{ | ||
"code": 120 | ||
} | ||
], | ||
"indent": [ | ||
"error", | ||
4 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
2, | ||
"single", | ||
{ | ||
"allowTemplateLiterals": true | ||
} | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
], | ||
"no-unused-vars": [ | ||
2, | ||
{ | ||
"args": "none" | ||
} | ||
] | ||
} | ||
} | ||
"extends": "eslint-config-four66" | ||
} |
@@ -19,2 +19,2 @@ #!/usr/bin/env node | ||
} | ||
}); | ||
}); |
{ | ||
"name": "cr2checkstyle", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Convert complexity-report data to Checkstyle XML", | ||
"main": "index.js", | ||
"homepage": "https://github.com/Finanzchef24-GmbH/cr2checkstyle", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Finanzchef24-GmbH/cr2checkstyle.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Finanzchef24-GmbH/cr2checkstyle/issues" | ||
}, | ||
"bin": { | ||
@@ -10,9 +18,10 @@ "cr2checkstyle": "./index.js" | ||
"engines": { | ||
"node": "4" | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "npm run lint && npm run mocha && npm run test-end2end", | ||
"test": "npm run lint && npm run mocha && npm run test-end2end && npm run nsp", | ||
"lint": "eslint .", | ||
"mocha": "mocha test/\\*\\*/\\*.spec.js", | ||
"test-end2end": "node index.js --module-maintainability 80,100 --module-halstead-difficulty 2,4 --module-cyclomatic-complexity 2,4 --function-halstead-difficulty 5,10 --function-cyclomatic-complexity 4,8 < test/integration/report.json | sdiff --text test/integration/output.xml -" | ||
"test-end2end": "node index.js --module-maintainability 80,100 --module-halstead-difficulty 2,4 --module-cyclomatic-complexity 2,4 --function-halstead-difficulty 5,10 --function-cyclomatic-complexity 4,8 < test/integration/report.json | sdiff --suppress-common-lines --text test/integration/output.xml -", | ||
"nsp": "nsp check" | ||
}, | ||
@@ -25,16 +34,18 @@ "author": { | ||
"dependencies": { | ||
"JSONStream": "1.1.1", | ||
"event-stream": "3.3.2", | ||
"JSONStream": "1.1.2", | ||
"event-stream": "3.3.3", | ||
"xml-escape": "1.1.0", | ||
"yargs": "4.7.0" | ||
"yargs": "4.7.1" | ||
}, | ||
"devDependencies": { | ||
"bluebird": "3.3.5", | ||
"bluebird": "3.4.1", | ||
"chai": "3.5.0", | ||
"complexity-report": "2.0.0-alpha", | ||
"eslint": "2.9.0", | ||
"libxmljs": "0.17.1", | ||
"mocha": "2.4.5", | ||
"eslint": "2.13.1", | ||
"eslint-config-four66": "1.0.0", | ||
"libxmljs": "0.18.0", | ||
"mocha": "2.5.3", | ||
"nsp": "2.4.0", | ||
"stream-buffers": "3.0.0" | ||
} | ||
} |
@@ -27,4 +27,10 @@ # cr2checkstyle | ||
## Configuration | ||
By default, cr2checkstyle has no thresholds set so it will not generate any warnings or errors. Currently supported metrics are [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity), [halstead difficulty](https://en.wikipedia.org/wiki/Halstead_complexity_measures) and the maintainability index. | ||
By default, cr2checkstyle has no thresholds set so it will not generate any warnings or errors. Currently supported metrics are [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity), [halstead difficulty](https://en.wikipedia.org/wiki/Halstead_complexity_measures) and the maintainability index. The corresponding command line options are: | ||
- `module-maintainability` | ||
- `module-cyclomatic-complexity` | ||
- `function-cyclomatic-complexity` | ||
- `module-halstead-difficulty` | ||
- `function-halstead-difficulty` | ||
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): | ||
@@ -42,2 +48,2 @@ | ||
Internally, parameters are parsed with [yargs](http://yargs.js.org/docs/#methods-envprefix) so you can also use environment variables (e.g., `CR2CS_FUNCTION_HALSTEAD_DIFFICULTY=3,6`) and the `cr2checkstyle`-property in your `package.json`. | ||
Internally, parameters are parsed with [yargs](http://yargs.js.org/docs/#methods-envprefix) so you can also use environment variables (e.g., `CR2CS_FUNCTION_HALSTEAD_DIFFICULTY=3,6`) and the `cr2checkstyle`-property in your `package.json`. |
@@ -55,2 +55,3 @@ 'use strict'; | ||
const qualifier = levels.maintainability === LEVEL.ERROR ? 'too low' : 'low'; | ||
messages.push({ | ||
@@ -65,2 +66,3 @@ line: 0, | ||
const qualifier = levels.cyclomatic === LEVEL.ERROR ? 'too high' : 'high'; | ||
messages.push({ | ||
@@ -75,2 +77,3 @@ line: 0, | ||
const qualifier = levels.halsteadDifficulty === LEVEL.ERROR ? 'too high' : 'high'; | ||
messages.push({ | ||
@@ -102,2 +105,3 @@ line: 0, | ||
const qualifier = levels.cyclomatic === LEVEL.ERROR ? 'too high' : 'high'; | ||
messages.push({ | ||
@@ -112,2 +116,3 @@ line: fnReport.line, | ||
const qualifier = levels.halsteadDifficulty === LEVEL.ERROR ? 'too high' : 'high'; | ||
messages.push({ | ||
@@ -133,2 +138,3 @@ line: fnReport.line, | ||
const fnMessages = getMessagesForFunction(fnReport, thresholds.function || {}); | ||
Array.prototype.push.apply(messages, fnMessages); | ||
@@ -138,3 +144,6 @@ }); | ||
// Returning undefined makes es.map() drop the object, which is exactly what we want if there are no messages. | ||
return messages.length ? { file: report.path, messages } : undefined; | ||
return messages.length ? { | ||
file: report.path, | ||
messages | ||
} : undefined; | ||
} | ||
@@ -148,3 +157,3 @@ | ||
const attributes = Object.keys(message).reduce(function (items, name) { | ||
return items.concat(`${name}="${escape(message[name] + '')}"`); | ||
return items.concat(`${name}="${escape(String(message[name]))}"`); | ||
}, []); | ||
@@ -172,7 +181,7 @@ | ||
result.messages.map(makeErrorElement).join(EOL), | ||
` </file>` | ||
' </file>' | ||
].join(EOL); | ||
})) | ||
.pipe(es.join(EOL)) | ||
.pipe(stdout); | ||
.pipe(stdout); | ||
}; |
@@ -81,2 +81,2 @@ 'use strict'; | ||
}) | ||
.strict(); | ||
.strict(); |
{ | ||
"env": { | ||
"mocha": true | ||
}, | ||
"rules": { | ||
"no-unused-expressions": 0, | ||
"require-jsdoc": 0 | ||
} | ||
} | ||
} |
@@ -17,5 +17,3 @@ 'use strict'; | ||
cyclomatic: 10, | ||
halstead: { | ||
difficulty: 22.057142857142857 | ||
}, | ||
halstead: { difficulty: 22.057142857142857 }, | ||
line: 1 | ||
@@ -27,5 +25,3 @@ }, | ||
cyclomatic: 6, | ||
halstead: { | ||
difficulty: 14.555555555555555 | ||
}, | ||
halstead: { difficulty: 14.555555555555555 }, | ||
line: 24 | ||
@@ -36,5 +32,3 @@ }, | ||
cyclomatic: 3, | ||
halstead: { | ||
difficulty: 10 | ||
}, | ||
halstead: { difficulty: 10 }, | ||
line: 43 | ||
@@ -45,5 +39,3 @@ }, | ||
cyclomatic: 3, | ||
halstead: { | ||
difficulty: 11.11111111111111 | ||
}, | ||
halstead: { difficulty: 11.11111111111111 }, | ||
line: 55 | ||
@@ -113,2 +105,3 @@ } | ||
const errors = xml.find('/checkstyle/file/error'); | ||
expect(errors).to.have.length(1); | ||
@@ -115,0 +108,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1
1
48
2
0
51750
9
1236
+ AddedJSONStream@1.1.2(transitive)
+ Addedevent-stream@3.3.3(transitive)
+ Addedset-blocking@1.0.0(transitive)
+ Addedyargs@4.7.1(transitive)
- RemovedJSONStream@1.1.1(transitive)
- Removedcamelcase@2.1.1(transitive)
- Removedevent-stream@3.3.2(transitive)
- Removedyargs@4.7.0(transitive)
UpdatedJSONStream@1.1.2
Updatedevent-stream@3.3.3
Updatedyargs@4.7.1