complexity-report
Advanced tools
Comparing version 1.2.0 to 1.3.0
{ | ||
"name": "complexity-report", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Software complexity analysis for JavaScript projects", | ||
@@ -29,2 +29,4 @@ "homepage": "https://github.com/philbooth/complexity-report", | ||
"escomplex-js": "1.1.0", | ||
"escomplex-coffee": "0.2.0", | ||
"escomplex": "1.1.0", | ||
"check-types": "2.1.x", | ||
@@ -31,0 +33,0 @@ "commander": "2.0.x" |
@@ -171,2 +171,3 @@ # complexity-report | ||
-n, --newmi use the Microsoft-variant maintainability index (scale of 0 to 100) | ||
-T, --coffeescript include coffee-script files | ||
``` | ||
@@ -173,0 +174,0 @@ |
@@ -13,2 +13,4 @@ #!/usr/bin/env node | ||
js = require('escomplex-js'), | ||
coffee = require('escomplex-coffee'), | ||
escomplex = require('escomplex'), | ||
check = require('check-types'); | ||
@@ -21,3 +23,6 @@ | ||
openFileCount: 0, | ||
source: [], | ||
sources: { | ||
js: [], | ||
coffee: [] | ||
}, | ||
tooComplex: false, | ||
@@ -38,2 +43,3 @@ failingModules: [] | ||
option('-f, --format <format>', 'specify the output format of the report'). | ||
option('-e, --ignoreerrors', 'ignore parser errors'). | ||
option('-a, --allfiles', 'include hidden files in the report'). | ||
@@ -43,3 +49,2 @@ option('-p, --filepattern <pattern>', 'specify the files to process using a regular expression to match against file names'). | ||
option('-x, --excludepattern <pattern>', 'specify the the directories to exclude using a regular expression to match against directory names'). | ||
option('-e, --ignoreerrors', 'ignore any files that fail to parsed into an AST'). | ||
option('-m, --maxfiles <number>', 'specify the maximum number of files to have open at any point', parseInt). | ||
@@ -61,2 +66,3 @@ option('-F, --maxfod <first-order density>', 'specify the per-project first-order density threshold', parseFloat). | ||
option('-n, --newmi', 'use the Microsoft-variant maintainability index (scale of 0 to 100)'). | ||
option('-T, --coffeescript', 'include coffee-script files'). | ||
parse(process.argv); | ||
@@ -86,3 +92,7 @@ | ||
if (check.unemptyString(cli.filepattern) === false) { | ||
cli.filepattern = '\\.js$'; | ||
if (cli.coffeescript) { | ||
cli.filepattern = '\\.(js|coffee)$'; | ||
} else { | ||
cli.filepattern = '\\.js$'; | ||
} | ||
} | ||
@@ -214,3 +224,4 @@ cli.filepattern = new RegExp(cli.filepattern); | ||
function setSource (modulePath, source) { | ||
state.source.push({ | ||
var type = getType(modulePath); | ||
state.sources[type].push({ | ||
path: modulePath, | ||
@@ -225,7 +236,15 @@ code: source | ||
function getType(modulePath) { | ||
return path.extname(modulePath).replace('.', ''); | ||
} | ||
function getReports () { | ||
var result, failingModules; | ||
var jsResult, coffeeResult, result, failingModules; | ||
try { | ||
result = js.analyse(state.source, options); | ||
jsResult = js.analyse(state.sources.js, options); | ||
if (cli.coffeescript) { | ||
coffeeResult = coffee.analyse(state.sources.coffee, options); | ||
} | ||
result = mergeResults(jsResult, coffeeResult); | ||
@@ -249,2 +268,10 @@ if (!cli.silent) { | ||
// merge the array of reports together and rerun through the code to compute aggregates | ||
function mergeResults(jsRes, coffeeRes) { | ||
jsRes.reports = jsRes.reports.concat(coffeeRes.reports); | ||
return escomplex.processResults(jsRes); | ||
} | ||
function writeReports (result) { | ||
@@ -251,0 +278,0 @@ var formatted = formatter.format(result); |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
58140
609
254
5
1
+ Addedescomplex@1.1.0
+ Addedescomplex-coffee@0.2.0
+ Addedcoffee-script@1.12.7(transitive)
+ Addedescomplex@1.1.0(transitive)
+ Addedescomplex-coffee@0.2.0(transitive)