New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

complexity-report

Package Overview
Dependencies
Maintainers
3
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

complexity-report - npm Package Compare versions

Comparing version

to
2.0.0-alpha

src/config.js

9

CONTRIBUTING.md

@@ -19,6 +19,5 @@ # Contribution guidelines

[readme]: https://github.com/philbooth/complexity-report/blob/master/README.md
[authors]: https://github.com/philbooth/complexity-report/blob/master/AUTHORS
[newissue]: https://github.com/philbooth/complexity-report/issues/new
[issues]: https://github.com/philbooth/complexity-report/issues
[readme]: https://github.com/jared-stilwell/complexity-report/blob/master/README.md
[authors]: https://github.com/jared-stilwell/complexity-report/blob/master/AUTHORS
[newissue]: https://github.com/jared-stilwell/complexity-report/issues/new
[issues]: https://github.com/jared-stilwell/complexity-report/issues
{
"name": "complexity-report",
"version": "1.4.1",
"version": "2.0.0-alpha",
"description": "Software complexity analysis for JavaScript projects",
"homepage": "https://github.com/philbooth/complexity-report",
"bugs": "https://github.com/philbooth/complexity-report/issues",
"homepage": "https://github.com/jared-stilwell/complexity-report",
"bugs": "https://github.com/jared-stilwell/complexity-report/issues",
"license": "MIT",

@@ -14,4 +14,11 @@ "author": "Phil Booth <pmbooth@gmail.com>",

"type": "git",
"url": "https://github.com/philbooth/complexity-report.git"
"url": "https://github.com/jared-stilwell/complexity-report.git"
},
"maintainers": [
{
"name": "Jared Stilwell",
"email": "jared.k.stilwell@gmail.com",
"url": "https://github.com/jared-stilwell"
}
],
"keywords": [

@@ -29,18 +36,25 @@ "complexity",

"dependencies": {
"async": "^0.9.0",
"check-types": "2.1.x",
"commander": "2.0.x",
"escomplex": "1.2.x",
"escomplex-coffee": "0.3.x",
"escomplex-js": "1.2.x"
"async": "^1.4.2",
"check-types": "^4.2.0",
"commander": "^2.9.0",
"escomplex": "2.0.0-alpha",
"esprima": "^2.7.2"
},
"devDependencies": {
"jshint": "2.1.x",
"mocha": "1.13.x",
"chai": "1.8.x"
"chai": "^3.4.0",
"eslint": "^2.2.0",
"mocha": "^2.3.3"
},
"scripts": {
"lint": "./node_modules/jshint/bin/jshint src --config config/jshint.json",
"test": "./node_modules/mocha/bin/mocha --ui tdd --reporter spec --colors test"
"lint": "eslint test src",
"test": "mocha --ui tdd --reporter spec --colors"
},
"eslintConfig": {
"extends": "eslint:recommended",
"parser": "esprima",
"env": {
"node": true,
"mocha": true
}
}
}
# complexity-report
[![Dependency Status](https://david-dm.org/jared-stilwell/complexity-report.svg)](https://david-dm.org/jared-stilwell/complexity-report) [![devDependency Status](https://david-dm.org/jared-stilwell/complexity-report/dev-status.svg)](https://david-dm.org/jared-stilwell/complexity-report#info=devDependencies)
Software complexity analysis for JavaScript projects.

@@ -171,3 +173,2 @@ Command-line front-end for [escomplex].

-n, --newmi use the Microsoft-variant maintainability index (scale of 0 to 100)
-T, --coffeescript include coffee-script files
```

@@ -240,16 +241,15 @@

[ci-image]: https://secure.travis-ci.org/philbooth/complexity-report.png?branch=master
[ci-status]: http://travis-ci.org/#!/philbooth/complexity-report
[escomplex]: https://github.com/philbooth/escomplex
[ci-image]: https://secure.travis-ci.org/jared-stilwell/complexity-report.png?branch=master
[ci-status]: http://travis-ci.org/#!/jared-stilwell/complexity-report
[escomplex]: https://github.com/jared-stilwell/escomplex
[jscomplexity]: http://jscomplexity.org/
[node]: http://nodejs.org/
[esprima]: http://esprima.org/
[eg]: https://github.com/philbooth/complexity-report/blob/master/EXAMPLE.md
[metrics]: https://github.com/philbooth/escomplex/blob/master/README.md#metrics
[eg]: https://github.com/jared-stilwell/complexity-report/blob/master/EXAMPLE.md
[metrics]: https://github.com/jared-stilwell/escomplex/blob/master/README.md#metrics
[nodeinstall]: http://nodejs.org/download
[egconfig]: https://github.com/philbooth/complexity-report/blob/master/.complexrc.example
[format]: https://github.com/philbooth/escomplex/blob/master/README.md#result
[plain]: https://github.com/philbooth/complexity-report/blob/master/src/formats/plain.js
[contributions]: https://github.com/philbooth/complexity-report/blob/master/CONTRIBUTING.md
[license]: https://github.com/philbooth/complexity-report/blob/master/COPYING
[egconfig]: https://github.com/jared-stilwell/complexity-report/blob/master/.complexrc.example
[format]: https://github.com/jared-stilwell/escomplex/blob/master/README.md#result
[plain]: https://github.com/jared-stilwell/complexity-report/blob/master/src/formats/plain.js
[contributions]: https://github.com/jared-stilwell/complexity-report/blob/master/CONTRIBUTING.md
[license]: https://github.com/jared-stilwell/complexity-report/blob/master/COPYING

@@ -10,6 +10,5 @@ #!/usr/bin/env node

cli = require('commander'),
config = require('./config'),
fs = require('fs'),
path = require('path'),
js = require('escomplex-js'),
coffee = require('escomplex-coffee'),
escomplex = require('escomplex'),

@@ -28,5 +27,4 @@ check = require('check-types'),

sources: {
js: [],
coffee: []
},
js: []
}
};

@@ -68,3 +66,2 @@

option('-n, --newmi', 'use the Microsoft-variant maintainability index (scale of 0 to 100)').
option('-T, --coffeescript', 'include coffee-script files').
option('-Q, --nocoresize', 'don\'t calculate core size or visibility matrix').

@@ -91,20 +88,16 @@ parse(process.argv);

if (check.unemptyString(cli.format) === false) {
if (check.nonEmptyString(cli.format) === false) {
cli.format = 'plain';
}
if (check.unemptyString(cli.filepattern) === false) {
if (cli.coffeescript) {
cli.filepattern = '\\.(js|coffee)$';
} else {
cli.filepattern = '\\.js$';
}
if (check.nonEmptyString(cli.filepattern) === false) {
cli.filepattern = '\\.js$';
}
cli.filepattern = new RegExp(cli.filepattern);
if (check.unemptyString(cli.dirpattern)) {
if (check.nonEmptyString(cli.dirpattern)) {
cli.dirpattern = new RegExp(cli.dirpattern);
}
if (check.unemptyString(cli.excludepattern)) {
if (check.nonEmptyString(cli.excludepattern)) {
cli.excludepattern = new RegExp(cli.excludepattern);

@@ -128,3 +121,3 @@ }

try {
if (check.not.unemptyString(configPath)) {
if (check.not.nonEmptyString(configPath)) {
configPath = path.join(process.cwd(), '.complexrc');

@@ -219,3 +212,3 @@ }

function fail (message) {
console.log(message);
console.log(message); // eslint-disable-line no-console
process.exitCode = 2;

@@ -245,15 +238,6 @@ }

function getReports () {
var jsResult, coffeeResult, result, failingModules;
var result, failingModules;
try {
if (cli.coffeescript) {
// if we have coffeescript,
// we will be merning results
// and recalculating all the values.
// skipping the calculation here saves on computation
options.skipCalculation = true;
coffeeResult = coffee.analyse(state.sources.coffee, options);
}
jsResult = js.analyse(state.sources.js, options);
result = mergeResults(jsResult, coffeeResult);
result = escomplex.analyse(state.sources.js, options);

@@ -269,3 +253,3 @@ if (!cli.silent) {

if (isProjectComplexityThresholdSet() && isProjectTooComplex(result)) {
if (config.isProjectComplexityThresholdSet(cli) && isProjectTooComplex(result)) {
fail('Warning: Project complexity threshold breached!');

@@ -278,17 +262,6 @@ }

// merge the array of reports together and rerun through the code to compute aggregates
function mergeResults(jsRes, coffeeRes) {
if (!coffeeRes) {
return jsRes;
}
jsRes.reports = jsRes.reports.concat(coffeeRes.reports);
return escomplex.processResults(jsRes, cli.nocoresize || false);
}
function writeReports (result) {
var formatted = formatter.format(result);
if (check.unemptyString(cli.output)) {
if (check.nonEmptyString(cli.output)) {
fs.writeFile(cli.output, formatted, 'utf8', function (err) {

@@ -300,3 +273,3 @@ if (err) {

} else {
console.log(formatted);
console.log(formatted); // eslint-disable-line no-console
}

@@ -308,4 +281,4 @@ }

if (
(isModuleComplexityThresholdSet() && isModuleTooComplex(report)) ||
(isFunctionComplexityThresholdSet() && isFunctionTooComplex(report))
(config.isModuleComplexityThresholdSet(cli) && isModuleTooComplex(report)) ||
(config.isFunctionComplexityThresholdSet(cli) && isFunctionTooComplex(report))
) {

@@ -319,12 +292,3 @@ return failingModules.concat(report.path);

function isModuleComplexityThresholdSet () {
return check.number(cli.minmi);
}
function isModuleTooComplex (report) {
if (isThresholdBreached(cli.minmi, report.maintainability, true)) {
return true;
}
}
function isThresholdBreached (threshold, metric, inverse) {

@@ -338,6 +302,2 @@ if (!inverse) {

function isFunctionComplexityThresholdSet () {
return check.number(cli.maxcyc) || check.number(cli.maxcycden) || check.number(cli.maxhd) || check.number(cli.maxhv) || check.number(cli.maxhe);
}
function isFunctionTooComplex (report) {

@@ -371,4 +331,6 @@ var i;

function isProjectComplexityThresholdSet () {
return check.number(cli.maxfod) || check.number(cli.maxcost) || check.number(cli.maxsize);
function isModuleTooComplex (report) {
if (isThresholdBreached(cli.minmi, report.maintainability, true)) {
return true;
}
}

@@ -391,2 +353,1 @@

}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet