monocart-coverage-reports 2.5.9 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,138 +1,138 @@
1
- const Util = require('../utils/util.js');
2
-
3
- // both css and js
4
- const getV8SummaryBytes = (item) => {
5
- const source = item.source;
6
- const total = source.length;
7
-
8
- // for empty coverage
9
- if (item.empty) {
10
- return {
11
- total,
12
- covered: 0
13
- };
14
- }
15
-
16
- const uncoveredBytes = item.data.bytes.filter((range) => range.count === 0);
17
-
18
- let uncovered = 0;
19
-
20
- let endPos = 0;
21
- uncoveredBytes.forEach((range) => {
22
- if (range.ignored) {
23
- return;
24
- }
25
-
26
- const { start, end } = range;
27
-
28
- if (start > endPos) {
29
- uncovered += end - start;
30
- endPos = end;
31
- return;
32
- }
33
-
34
- if (end <= endPos) {
35
- return;
36
- }
37
-
38
- uncovered += end - endPos;
39
- endPos = end;
40
-
41
- });
42
-
43
- const covered = total - uncovered;
44
-
45
- // console.log(item)
46
-
47
- return {
48
- total,
49
- covered
50
- };
51
- };
52
-
53
- // calculate uncovered, pct, status
54
- const calculatePctAndStatus = (item, watermarks) => {
55
- Object.keys(item).forEach((k) => {
56
- const indicateData = item[k];
57
- indicateData.uncovered = indicateData.total - indicateData.covered;
58
-
59
- let pct = '';
60
- let status = 'unknown';
61
-
62
- if (indicateData.total) {
63
- pct = Util.PNF(indicateData.covered, indicateData.total, 2);
64
- status = Util.getStatus(pct, watermarks[k]);
65
- }
66
-
67
- indicateData.pct = pct;
68
- indicateData.status = status;
69
-
70
- });
71
- };
72
-
73
- const getV8Summary = (v8list, watermarks) => {
74
-
75
- // get bytes summary
76
- v8list.forEach((entry) => {
77
- entry.summary.bytes = getV8SummaryBytes(entry);
78
- });
79
-
80
- // overall summary
81
- const summary = {
82
- bytes: {
83
- total: 0,
84
- covered: 0
85
- },
86
- statements: {
87
- total: 0,
88
- covered: 0
89
- },
90
- branches: {
91
- total: 0,
92
- covered: 0
93
- },
94
- functions: {
95
- total: 0,
96
- covered: 0
97
- },
98
- lines: {
99
- total: 0,
100
- covered: 0,
101
- blank: 0,
102
- comment: 0
103
- }
104
- };
105
-
106
- v8list.forEach((entry) => {
107
- const entrySummary = entry.summary;
108
- calculatePctAndStatus(entrySummary, watermarks);
109
-
110
- // do NOT add debug file
111
- if (entry.debug) {
112
- return;
113
- }
114
-
115
- Object.keys(entrySummary).forEach((k) => {
116
- const indicateData = entrySummary[k];
117
- if (!indicateData) {
118
- return;
119
- }
120
- summary[k].total += indicateData.total;
121
- summary[k].covered += indicateData.covered;
122
-
123
- if (k === 'lines') {
124
- summary[k].blank += indicateData.blank;
125
- summary[k].comment += indicateData.comment;
126
- }
127
- });
128
- });
129
-
130
- // calculate overall summary
131
- calculatePctAndStatus(summary, watermarks);
132
-
133
- return summary;
134
- };
135
-
136
- module.exports = {
137
- getV8Summary
138
- };
1
+ const Util = require('../utils/util.js');
2
+
3
+ // both css and js
4
+ const getV8SummaryBytes = (item) => {
5
+ const source = item.source;
6
+ const total = source.length;
7
+
8
+ // for empty coverage
9
+ if (item.empty) {
10
+ return {
11
+ total,
12
+ covered: 0
13
+ };
14
+ }
15
+
16
+ const uncoveredBytes = item.data.bytes.filter((range) => range.count === 0);
17
+
18
+ let uncovered = 0;
19
+
20
+ let endPos = 0;
21
+ uncoveredBytes.forEach((range) => {
22
+ if (range.ignored) {
23
+ return;
24
+ }
25
+
26
+ const { start, end } = range;
27
+
28
+ if (start > endPos) {
29
+ uncovered += end - start;
30
+ endPos = end;
31
+ return;
32
+ }
33
+
34
+ if (end <= endPos) {
35
+ return;
36
+ }
37
+
38
+ uncovered += end - endPos;
39
+ endPos = end;
40
+
41
+ });
42
+
43
+ const covered = total - uncovered;
44
+
45
+ // console.log(item)
46
+
47
+ return {
48
+ total,
49
+ covered
50
+ };
51
+ };
52
+
53
+ // calculate uncovered, pct, status
54
+ const calculatePctAndStatus = (item, watermarks) => {
55
+ Object.keys(item).forEach((k) => {
56
+ const indicateData = item[k];
57
+ indicateData.uncovered = indicateData.total - indicateData.covered;
58
+
59
+ let pct = '';
60
+ let status = 'unknown';
61
+
62
+ if (indicateData.total) {
63
+ pct = Util.PNF(indicateData.covered, indicateData.total, 2);
64
+ status = Util.getStatus(pct, watermarks[k]);
65
+ }
66
+
67
+ indicateData.pct = pct;
68
+ indicateData.status = status;
69
+
70
+ });
71
+ };
72
+
73
+ const getV8Summary = (v8list, watermarks) => {
74
+
75
+ // get bytes summary
76
+ v8list.forEach((entry) => {
77
+ entry.summary.bytes = getV8SummaryBytes(entry);
78
+ });
79
+
80
+ // overall summary
81
+ const summary = {
82
+ bytes: {
83
+ total: 0,
84
+ covered: 0
85
+ },
86
+ statements: {
87
+ total: 0,
88
+ covered: 0
89
+ },
90
+ branches: {
91
+ total: 0,
92
+ covered: 0
93
+ },
94
+ functions: {
95
+ total: 0,
96
+ covered: 0
97
+ },
98
+ lines: {
99
+ total: 0,
100
+ covered: 0,
101
+ blank: 0,
102
+ comment: 0
103
+ }
104
+ };
105
+
106
+ v8list.forEach((entry) => {
107
+ const entrySummary = entry.summary;
108
+ calculatePctAndStatus(entrySummary, watermarks);
109
+
110
+ // do NOT add debug file
111
+ if (entry.debug) {
112
+ return;
113
+ }
114
+
115
+ Object.keys(entrySummary).forEach((k) => {
116
+ const indicateData = entrySummary[k];
117
+ if (!indicateData) {
118
+ return;
119
+ }
120
+ summary[k].total += indicateData.total;
121
+ summary[k].covered += indicateData.covered;
122
+
123
+ if (k === 'lines') {
124
+ summary[k].blank += indicateData.blank;
125
+ summary[k].comment += indicateData.comment;
126
+ }
127
+ });
128
+ });
129
+
130
+ // calculate overall summary
131
+ calculatePctAndStatus(summary, watermarks);
132
+
133
+ return summary;
134
+ };
135
+
136
+ module.exports = {
137
+ getV8Summary
138
+ };