function writeReport () { var formatted = formatter.format(reports); if (check.isUnemptyString(cli.output)) { fs.writeFile(cli.output, formatted, 'utf8', function (err) { if (err) { error('writeReport', err); } }); } else { console.log(formatted); } }
function parseCommandLine () { cli. usage('[options] <file...>'). option( '-o, --output <file>', 'specify an output file for the report' ). option( '-f, --format <format>', 'specify the output format of the report' ). option( '-a, --allfiles', 'include hidden files in the report' ). option( '-p, --filepattern <pattern>', 'specify the files to process using a regular expression to match against file names' ). option( '-x, --maxfiles <number>', 'specify the maximum number of files to have open at any point', parseInt ). option( '-m, --maxmi <maintainability>', 'specify the per-module maintainability index threshold', parseFloat ). option( '-c, --maxcc <complexity>', 'specify the per-function cyclomatic complexity threshold', parseInt ). option( '-d, --maxhd <difficulty>', 'specify the per-function Halstead difficulty threshold', parseFloat ). option( '-v, --maxhv <volume>', 'specify the per-function Halstead volume threshold', parseFloat ). option( '-e, --maxhe <effort>', 'specify the per-function Halstead effort threshold', parseFloat ). option( '-s, --silent', 'don\'t write any output to the console' ). option( '-l, --logicalor', 'disregard operator || as source of cyclomatic complexity' ). option( '-w, --switchcase', 'disregard switch statements as source of cyclomatic complexity' ). option( '-i, --forin', 'treat for...in statements as source of cyclomatic complexity' ). option( '-t, --trycatch', 'treat catch clauses as source of cyclomatic complexity' ). option( '-n, --newmi', 'use the Microsoft-variant maintainability index (scale of 0 to 100)' ); cli.parse(process.argv); options = { logicalor: !cli.logicalor, switchcase: !cli.switchcase, forin: cli.forin || false, trycatch: cli.trycatch || false, newmi: cli.newmi || false }; if (check.isUnemptyString(cli.format) === false) { cli.format = 'plain'; } if (check.isUnemptyString(cli.filepattern) === false) { cli.filepattern = '\\.js$'; } cli.filepattern = new RegExp(cli.filepattern); if (check.isNumber(cli.maxfiles) === false) { cli.maxfiles = 1024; } try { formatter = require('./formats/' + cli.format); } catch (error) { formatter = require(cli.format); } }
function parseCommandLine () { cli. usage('[options] <file...>'). option( '-o, --output <file>', 'specify an output file for the report' ). option( '-f, --format <format>', 'specify the output format of the report' ). option( '-m, --maxmi <maintainability>', 'specify the per-module maintainability index threshold', parseFloat ). option( '-c, --maxcc <complexity>', 'specify the per-function cyclomatic complexity threshold', parseInt ). option( '-d, --maxhd <difficulty>', 'specify the per-function Halstead difficulty threshold', parseFloat ). option( '-v, --maxhv <volume>', 'specify the per-function Halstead volume threshold', parseFloat ). option( '-e, --maxhe <effort>', 'specify the per-function Halstead effort threshold', parseFloat ). option( '-s, --silent', 'don\'t write any output to the console' ). option( '-l, --logicalor', 'disregard operator || as source of cyclomatic complexity' ). option( '-w, --switchcase', 'disregard switch statements as source of cyclomatic complexity' ). option( '-i, --forin', 'treat for...in statements as source of cyclomatic complexity' ). option( '-t, --trycatch', 'treat catch clauses as source of cyclomatic complexity' ). option( '-n, --newmi', 'use the Microsoft-variant maintainability index (scale of 0 to 100)' ); cli.parse(process.argv); options = { logicalor: !cli.logicalor, switchcase: !cli.switchcase, forin: cli.forin || false, trycatch: cli.trycatch || false, newmi: cli.newmi || false }; if (check.isUnemptyString(cli.format) === false) { cli.format = 'plain'; } formatter = require('./formats/' + cli.format); }