cr2checkstyle
Advanced tools
Comparing version 0.0.1 to 0.0.2
14
index.js
@@ -9,6 +9,12 @@ #!/usr/bin/env node | ||
require('./src/index.js')(process.stdin, process.stdout, { | ||
maintainability: argv.maintainability, | ||
cyclomatic: argv.cyclomatic, | ||
halsteadDifficulty: argv.halsteadDifficulty | ||
require('./src/cr2checkstyle')(process.stdin, process.stdout, { | ||
module: { | ||
maintainability: argv['module-maintainability'], | ||
cyclomatic: argv['module-cyclomatic-complexity'], | ||
halsteadDifficulty: argv['module-halstead-difficulty'] | ||
}, | ||
function: { | ||
cyclomatic: argv['function-cyclomatic-complexity'], | ||
halsteadDifficulty: argv['function-halstead-difficulty'] | ||
} | ||
}); |
{ | ||
"name": "cr2checkstyle", | ||
"version": "0.0.1", | ||
"description": "", | ||
"version": "0.0.2", | ||
"description": "Convert complexity-report data to Checkstyle XML", | ||
"main": "index.js", | ||
@@ -13,3 +13,6 @@ "bin": { | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "npm run lint && npm run mocha && npm run test-end2end", | ||
"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 -" | ||
}, | ||
@@ -26,3 +29,12 @@ "author": { | ||
"yargs": "4.7.0" | ||
}, | ||
"devDependencies": { | ||
"bluebird": "3.3.5", | ||
"chai": "3.5.0", | ||
"complexity-report": "2.0.0-alpha", | ||
"eslint": "2.9.0", | ||
"libxmljs": "0.17.1", | ||
"mocha": "2.4.5", | ||
"stream-buffers": "3.0.0" | ||
} | ||
} |
@@ -9,2 +9,10 @@ /** | ||
*/ | ||
cr2cs.Message; | ||
cr2cs.Message; | ||
/** | ||
* @typedef {{ | ||
* module: Object.<string, Array.<number>>, | ||
* function: Object.<string, Array.<number>> | ||
* }} | ||
*/ | ||
cr2cs.Thresholds; |
'use strict'; | ||
const fs = require('fs'); | ||
const yargs = require('yargs'); | ||
const OPTIONS = { | ||
'maintainability': { | ||
'module-maintainability': { | ||
type: 'string', | ||
@@ -13,3 +14,3 @@ requiresArg: true, | ||
}, | ||
'cyclomatic': { | ||
'function-cyclomatic-complexity': { | ||
type: 'string', | ||
@@ -21,8 +22,22 @@ requiresArg: true, | ||
}, | ||
'halsteadDifficulty': { | ||
'module-cyclomatic-complexity': { | ||
type: 'string', | ||
requiresArg: true, | ||
describe: 'Thresholds for the per-module cyclomatic complexity', | ||
default: null, | ||
defaultDescription: 'disabled' | ||
}, | ||
'function-halstead-difficulty': { | ||
type: 'string', | ||
requiresArg: true, | ||
describe: 'Thresholds for the per-function Halstead difficulty', | ||
default: null, | ||
defaultDescription: 'disabled' | ||
}, | ||
'module-halstead-difficulty': { | ||
type: 'string', | ||
requiresArg: true, | ||
describe: 'Thresholds for the per-module Halstead difficulty', | ||
default: null, | ||
defaultDescription: 'disabled' | ||
} | ||
@@ -38,7 +53,10 @@ }; | ||
if (typeof value === 'string' && !/^(\d+),(\d+)$/.test(value)) { | ||
throw new Error(`Invalid value for options "${name}"`); | ||
if (typeof value === 'string') { | ||
if (!/^(\d+),(\d+)$/.test(value)) { | ||
throw new Error(`Invalid value for option "${name}"`); | ||
} | ||
argv[name] = JSON.parse(`[${value}]`); | ||
} else if (value !== null) { | ||
throw new Error(`Invalid value for option "${name}"`); | ||
} | ||
argv[name] = value === null ? null : JSON.parse(`[${value}]`); | ||
} | ||
@@ -50,2 +68,3 @@ | ||
.env('CR2CS') | ||
.wrap(yargs.terminalWidth()) | ||
.detectLocale(false) | ||
@@ -56,8 +75,12 @@ .version() | ||
.config('config', path => JSON.parse(fs.readFileSync(path))) | ||
.group(['module-maintainability', 'module-halstead-difficulty', 'module-cyclomatic-complexity'], 'Per-module metrics') | ||
.group(['function-halstead-difficulty', 'function-cyclomatic-complexity'], 'Per-function metrics') | ||
.check(function (argv, options) { | ||
parse(argv, 'cyclomatic'); | ||
parse(argv, 'halsteadDifficulty'); | ||
parse(argv, 'maintainability'); | ||
parse(argv, 'module-maintainability'); | ||
parse(argv, 'module-cyclomatic-complexity'); | ||
parse(argv, 'function-cyclomatic-complexity'); | ||
parse(argv, 'module-halstead-difficulty'); | ||
parse(argv, 'function-halstead-difficulty'); | ||
return true; | ||
}) | ||
.strict(); |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
51849
15
1268
2
1
41
7
3
1