JS cyclomatic complexity report generator


JS cyclomatic complexity report generator.

Command-line tool and module to generate a complexity report on file tree Javascript files. It is based on escomplex module results. Report stands in a .html file containing graphical representation of file tree when used from command-line.

npm install -g jscomplexity

var jscomplexity = require('jscomplexity');
// jscomplexity() returns a promise (using bluebird) 
jscomplexity('/glob/pattern/to/js/*' [, globOptions]).then(console.log);
// you can also use CPS style 
jscomplexity('/glob/pattern/to/js/*', {}, function(errresult){
  if(err) {
    return console.log(err);
Usage: jscomplexity [options]
    -h, --help                 output usage information
    -V, --version              output the version number
    -p, --pattern <pattern>    glob pattern - default is current directory
    -o, --output <filename>    (optional) customize html report filename - default is 'jscomplexity-report.html'
    -r, --reporter <reporter>  (optional) specify a reporter: 'terminal', 'html' or 'all' - default is 'all'
    -v, --verbose              (optional) outputs analysisis logs

⚠️ Linux/OSX compliant only (I haven't tested it on Windows).

Example : jscomplexity -p '{./src/*.js,./src/**/*.js}'

See grunt-jscomplexity-threshold module.