@@ -23,49 +23,39 @@ const {
23
23
mergeOptions
24
24
} = require ( './lib/options-manager' ) ;
25
25
26
+ /** Merge multiple reports into a single report */
26
27
const mergeReports = reports => {
27
- // Merge multiple reports into a single report
28
- let results = [ ] ;
29
- let errorCount = 0 ;
30
- let warningCount = 0 ;
31
-
32
- for ( const report of reports ) {
33
- results = results . concat ( report . results ) ;
34
- errorCount += report . errorCount ;
35
- warningCount += report . warningCount ;
28
+ const report = {
29
+ results : [ ] ,
30
+ errorCount : 0 ,
31
+ warningCount : 0
32
+ } ;
33
+
34
+ for ( const currentReport of reports ) {
35
+ report . results . push ( ...currentReport . results ) ;
36
+ report . errorCount += currentReport . errorCount ;
37
+ report . warningCount += currentReport . warningCount ;
36
38
}
37
39
38
- return {
39
- errorCount,
40
- warningCount,
41
- results
42
- } ;
40
+ return report ;
43
41
} ;
44
42
45
43
const getReportStatistics = results => {
46
- let errorCount = 0 ;
47
- let warningCount = 0 ;
48
- let fixableErrorCount = 0 ;
49
- let fixableWarningCount = 0 ;
50
-
51
- for ( const {
52
- errorCount : currentErrorCount ,
53
- warningCount : currentWarningCount ,
54
- fixableErrorCount : currentFixableErrorCount ,
55
- fixableWarningCount : currentFixableWarningCount
56
- } of results ) {
57
- errorCount += currentErrorCount ;
58
- warningCount += currentWarningCount ;
59
- fixableErrorCount += currentFixableErrorCount ;
60
- fixableWarningCount += currentFixableWarningCount ;
44
+ const statistics = {
45
+ errorCount : 0 ,
46
+ warningCount : 0 ,
47
+ fixableErrorCount : 0 ,
48
+ fixableWarningCount : 0
49
+ } ;
50
+
51
+ for ( const result of results ) {
52
+ statistics . errorCount += result . errorCount ;
53
+ statistics . warningCount += result . warningCount ;
54
+ statistics . fixableErrorCount += result . fixableErrorCount ;
55
+ statistics . fixableWarningCount += result . fixableWarningCount ;
61
56
}
62
57
63
- return {
64
- errorCount,
65
- warningCount,
66
- fixableErrorCount,
67
- fixableWarningCount
68
- } ;
58
+ return statistics ;
69
59
} ;
70
60
71
61
const processReport = ( report , { isQuiet = false } = { } ) => {
0 commit comments