@@ -61,16 +61,22 @@ class Coverage extends React.Component {
61
61
const { lines, branches, functions } = history . source_files [ 0 ] ;
62
62
allBranches . push ( git . branch || git . git_branch ) ;
63
63
64
- if ( selectedBranch && selectedBranch === ( git . branch || git . git_branch ) ) {
65
- data [ 0 ] . push ( parseInt ( ( ( lines . hit / lines . found ) || 1 ) * 100 ) )
66
- data [ 1 ] . push ( parseInt ( ( ( branches . hit / branches . found ) || 1 ) * 100 ) )
67
- data [ 2 ] . push ( parseInt ( ( ( functions . hit / functions . found ) || 1 ) * 100 ) )
68
- } else if ( ! selectedBranch ) {
69
- data [ 0 ] . push ( parseInt ( ( ( lines . hit / lines . found ) || 1 ) * 100 ) )
70
- data [ 1 ] . push ( parseInt ( ( ( branches . hit / branches . found ) || 1 ) * 100 ) )
71
- data [ 2 ] . push ( parseInt ( ( ( functions . hit / functions . found ) || 1 ) * 100 ) )
64
+ if ( lines && branches && functions ) {
65
+ if ( selectedBranch && selectedBranch === ( git . branch || git . git_branch ) ) {
66
+ data [ 0 ] . push ( parseInt ( ( ( lines . hit / lines . found ) || 1 ) * 100 ) )
67
+ data [ 1 ] . push ( parseInt ( ( ( branches . hit / branches . found ) || 1 ) * 100 ) )
68
+ data [ 2 ] . push ( parseInt ( ( ( functions . hit / functions . found ) || 1 ) * 100 ) )
69
+ } else if ( ! selectedBranch ) {
70
+ data [ 0 ] . push ( parseInt ( ( ( lines . hit / lines . found ) || 1 ) * 100 ) )
71
+ data [ 1 ] . push ( parseInt ( ( ( branches . hit / branches . found ) || 1 ) * 100 ) )
72
+ data [ 2 ] . push ( parseInt ( ( ( functions . hit / functions . found ) || 1 ) * 100 ) )
73
+ } else {
74
+ // noop
75
+ }
72
76
} else {
73
- // noop
77
+ data [ 0 ] . push ( 0 )
78
+ data [ 1 ] . push ( 0 )
79
+ data [ 2 ] . push ( 0 )
74
80
}
75
81
} , [ ] ) ;
76
82
@@ -87,8 +93,10 @@ class Coverage extends React.Component {
87
93
88
94
function reduceBuilds ( build ) {
89
95
let totalCoverage = build . source_files . map ( ( f ) => {
90
- const totalFound = f . lines . found + f . branches . found + f . functions . found ;
91
- const totalHit = f . lines . hit + f . branches . hit + f . functions . hit ;
96
+ const { lines= { found : 0 , hit : 0 } , branches= { found : 0 , hit : 0 } , functions= { found : 0 , hit : 0 } } = f ;
97
+
98
+ const totalFound = lines . found + branches . found + functions . found ;
99
+ const totalHit = lines . hit + branches . hit + functions . hit ;
92
100
const totalCoverage = parseInt ( ( totalHit / totalFound ) * 100 ) ;
93
101
return totalCoverage ;
94
102
} , [ ] ) . reduce ( ( p , c , _ , a ) => p + c / a . length , 0 ) ;
@@ -107,8 +115,10 @@ class Coverage extends React.Component {
107
115
} ) ;
108
116
109
117
function reduceSourceFiles ( file ) {
110
- const totalFound = file . lines . found + file . branches . found + file . functions . found ;
111
- const totalHit = file . lines . hit + file . branches . hit + file . functions . hit ;
118
+ const { lines= { found : 0 , hit : 0 } , branches= { found : 0 , hit : 0 } , functions= { found : 0 , hit : 0 } } = file ;
119
+
120
+ const totalFound = lines . found + branches . found + functions . found ;
121
+ const totalHit = lines . hit + branches . hit + functions . hit ;
112
122
const totalCoverage = parseInt ( ( totalHit / totalFound ) * 100 ) ;
113
123
const fileName = encodeURIComponent ( file . title ) . replace ( / \. / g, '$2E' ) ;
114
124
@@ -117,9 +127,9 @@ class Coverage extends React.Component {
117
127
"File" : < a href = { `/coverage/${ source . replace ( / \. / g, '%2E' ) } /${ owner } /${ name } /${ fileName } ` } >
118
128
{ file . title }
119
129
</ a > ,
120
- "Lines" : `${ file . lines . hit } / ${ file . lines . found } ` ,
121
- "Branches" : `${ file . branches . hit } / ${ file . branches . found } ` ,
122
- "Functions" : `${ file . functions . hit } / ${ file . functions . found } `
130
+ "Lines" : `${ lines . hit } / ${ lines . found } ` ,
131
+ "Branches" : `${ branches . hit } / ${ branches . found } ` ,
132
+ "Functions" : `${ functions . hit } / ${ functions . found } `
123
133
}
124
134
}
125
135
0 commit comments