mirror of
https://github.com/Hopiu/annotate-esprima.git
synced 2026-03-17 00:10:23 +00:00
18 lines
592 B
JavaScript
Executable file
18 lines
592 B
JavaScript
Executable file
var cr = require('complexity-report'),
|
|
content = require('fs').readFileSync('esprima.js', 'utf-8'),
|
|
opt = { logicalor: false, switchcase: false },
|
|
list = [];
|
|
|
|
cr.run(content, opt).functions.forEach(function (entry) {
|
|
var name = (entry.name === '<anonymous>') ? (':' + entry.line) : entry.name;
|
|
list.push({ name: name, value: entry.complexity.cyclomatic });
|
|
});
|
|
|
|
list.sort(function (x, y) {
|
|
return y.value - x.value;
|
|
});
|
|
|
|
console.log('Most cyclomatic-complex functions:');
|
|
list.slice(0, 6).forEach(function (entry) {
|
|
console.log(' ', entry.name, entry.value);
|
|
});
|