This repository has been archived by the owner on Jun 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
/
plain.js
60 lines (52 loc) · 2.2 KB
/
plain.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*globals exports */
'use strict';
exports.format = format;
function format (result) {
return result.reports.reduce(function (formatted, report) {
return formatted + formatModule(report) + '\n\n';
}, formatProject(result));
}
function formatProject (result) {
return [
'Mean per-function logical LOC: ', result.loc, '\n',
'Mean per-function parameter count: ', result.params, '\n',
'Mean per-function cyclomatic complexity: ', result.cyclomatic, '\n',
'Mean per-function Halstead effort: ', result.effort, '\n',
'Mean per-module maintainability index: ', result.maintainability, '\n',
'First-order density: ', result.firstOrderDensity, '%\n',
'Change cost: ', result.changeCost, '%\n',
'Core size: ', result.coreSize, '%\n\n'
].join('');
}
function formatModule (report) {
return [
report.path, '\n\n',
' Physical LOC: ', report.aggregate.sloc.physical, '\n',
' Logical LOC: ', report.aggregate.sloc.logical, '\n',
' Mean parameter count: ', report.params, '\n',
' Cyclomatic complexity: ', report.aggregate.cyclomatic, '\n',
' Cyclomatic complexity density: ', report.aggregate.cyclomaticDensity, '%\n',
' Maintainability index: ', report.maintainability, '\n',
' Dependency count: ', report.dependencies.length,
formatFunctions(report.functions)
].join('');
}
function formatFunctions (report) {
return report.reduce(function (formatted, r) {
return formatted + '\n\n' + formatFunction(r);
}, '');
}
function formatFunction (report) {
return [
' Function: ', report.name, '\n',
' Line No.: ', report.line, '\n',
' Physical LOC: ', report.sloc.physical, '\n',
' Logical LOC: ', report.sloc.logical, '\n',
' Parameter count: ', report.params, '\n',
' Cyclomatic complexity: ', report.cyclomatic, '\n',
' Cyclomatic complexity density: ', report.cyclomaticDensity, '%\n',
' Halstead difficulty: ', report.halstead.difficulty, '\n',
' Halstead volume: ', report.halstead.volume, '\n',
' Halstead effort: ', report.halstead.effort
].join('');
}