Socket
Socket
Sign inDemoInstall

cr2checkstyle

Package Overview
Dependencies
66
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.0.2

.eslintignore

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();
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc