@@ -114,57 +114,174 @@ function findMeasuresF77(componentName) {
114
114
} ) ;
115
115
}
116
116
117
+ function findMeasuresF90 ( componentName ) {
118
+ return new Promise ( function ( resolve , reject ) {
119
+
120
+ let metricKeys = metricKeysTabF90 . reduce ( ( accumulator , currentValue ) => accumulator + ',' + currentValue ) ;
121
+
122
+ let measure_component = getJSON ( '/api/measures/component' , {
123
+ metricKeys :metricKeys ,
124
+ component :componentName
125
+ } ) . then ( function ( measure_component ) {
126
+ console . log ( measure_component ) ;
127
+
128
+ // Build map 'metric:value'
129
+ let allMetrics = new Map ( ) ;
130
+ measure_component . component . measures . forEach ( element => {
131
+ for ( let index = 0 ; index < metricKeysTabF90 . length ; index ++ ) {
132
+ const key = metricKeysTabF90 [ index ] ;
133
+ if ( element . metric === key ) {
134
+ allMetrics . set ( element . metric , element . value ) ;
135
+ }
136
+ }
137
+ } ) ;
138
+ console . log ( allMetrics ) ;
139
+
140
+ // Build result table
141
+ let res = [
142
+ { name :'Nesting' ,
143
+ total : '-' ,
144
+ min : allMetrics . get ( 'icode-f90-nesting-min' ) ,
145
+ mean : allMetrics . get ( 'icode-f90-nesting-mean' ) ,
146
+ max : allMetrics . get ( 'icode-f90-nesting-max' )
147
+ } ,
148
+ { name :'Ratio Comment' ,
149
+ total : '-' ,
150
+ min : allMetrics . get ( 'icode-f90-ratio-comment-min' ) ,
151
+ mean : allMetrics . get ( 'icode-f90-ratio-comment-mean' ) ,
152
+ max : allMetrics . get ( 'icode-f90-ratio-comment-max' )
153
+ } ,
154
+ { name :'Complexity Simplified' ,
155
+ total : '-' ,
156
+ min : allMetrics . get ( 'icode-f90-cyclomatic-complexity-min' ) ,
157
+ mean : allMetrics . get ( 'icode-f90-cyclomatic-complexity-mean' ) ,
158
+ max : allMetrics . get ( 'icode-f90-cyclomatic-complexity-max' )
159
+ } ,
160
+ { name :'Line Of Code' ,
161
+ total : allMetrics . get ( 'icode-f90-loc' ) ,
162
+ min : allMetrics . get ( 'icode-f90-loc-min' ) ,
163
+ mean : allMetrics . get ( 'icode-f90-loc-mean' ) ,
164
+ max : allMetrics . get ( 'icode-f90-loc-max' )
165
+ }
166
+ ] ;
167
+ console . log ( res ) ;
168
+
169
+ resolve ( res ) ;
170
+ } ) . catch ( function ( error ) {
171
+ console . log ( 'No measures found: ' + error . message ) ;
172
+ reject ( null ) ;
173
+ } ) ;
174
+ } ) ;
175
+ }
176
+
177
+ function findMeasuresShell ( componentName ) {
178
+ return new Promise ( function ( resolve , reject ) {
179
+
180
+ let metricKeys = metricKeysTabShell . reduce ( ( accumulator , currentValue ) => accumulator + ',' + currentValue ) ;
181
+
182
+ let measure_component = getJSON ( '/api/measures/component' , {
183
+ metricKeys :metricKeys ,
184
+ component :componentName
185
+ } ) . then ( function ( measure_component ) {
186
+ console . log ( measure_component ) ;
187
+
188
+ // Build map 'metric:value'
189
+ let allMetrics = new Map ( ) ;
190
+ measure_component . component . measures . forEach ( element => {
191
+ for ( let index = 0 ; index < metricKeysTabShell . length ; index ++ ) {
192
+ const key = metricKeysTabShell [ index ] ;
193
+ if ( element . metric === key ) {
194
+ allMetrics . set ( element . metric , element . value ) ;
195
+ }
196
+ }
197
+ } ) ;
198
+ console . log ( allMetrics ) ;
199
+
200
+ // Build result table
201
+ let res = [
202
+ { name :'Nesting' ,
203
+ total : '-' ,
204
+ min : allMetrics . get ( 'icode-shell-nesting-min' ) ,
205
+ mean : allMetrics . get ( 'icode-shell-nesting-mean' ) ,
206
+ max : allMetrics . get ( 'icode-shell-nesting-max' )
207
+ } ,
208
+ { name :'Ratio Comment' ,
209
+ total : '-' ,
210
+ min : allMetrics . get ( 'icode-shell-ratio-comment-min' ) ,
211
+ mean : allMetrics . get ( 'icode-shell-ratio-comment-mean' ) ,
212
+ max : allMetrics . get ( 'icode-shell-ratio-comment-max' )
213
+ } ,
214
+ { name :'Complexity Simplified' ,
215
+ total : '-' ,
216
+ min : allMetrics . get ( 'icode-shell-cyclomatic-complexity-min' ) ,
217
+ mean : allMetrics . get ( 'icode-shell-cyclomatic-complexity-mean' ) ,
218
+ max : allMetrics . get ( 'icode-shell-cyclomatic-complexity-max' )
219
+ } ,
220
+ { name :'Line Of Code' ,
221
+ total : allMetrics . get ( 'icode-shell-loc' ) ,
222
+ min : allMetrics . get ( 'icode-shell-loc-min' ) ,
223
+ mean : allMetrics . get ( 'icode-shell-loc-mean' ) ,
224
+ max : allMetrics . get ( 'icode-shell-loc-max' )
225
+ }
226
+ ] ;
227
+ console . log ( res ) ;
228
+
229
+ resolve ( res ) ;
230
+ } ) . catch ( function ( error ) {
231
+ console . log ( 'No measures found: ' + error . message ) ;
232
+ reject ( null ) ;
233
+ } ) ;
234
+ } ) ;
235
+ }
236
+
237
+
117
238
class MetricsSummaryTab extends React . Component {
118
239
119
240
state = {
120
241
dataF77 : [ ] ,
121
242
dataF90 : [ ] ,
122
- dataSH : [ ] ,
123
- data :[ ]
243
+ dataSH : [ ]
124
244
} ;
245
+
246
+ this . setState ( {
247
+ dataF77 : [
248
+ { name : 'Nesting' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
249
+ { name : 'Ratio Comment' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
250
+ { name : 'Complexity Simplified' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
251
+ { name : 'Line Of Code' , total : '-' , min : '-' , mean : '-' , max : '-' } ] ,
252
+ dataF90 : [
253
+ { name : 'Nesting' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
254
+ { name : 'Ratio Comment' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
255
+ { name : 'Complexity Simplified' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
256
+ { name : 'Line Of Code' , total : '-' , min : '-' , mean : '-' , max : '-' }
257
+ ] ,
258
+ dataSH : [
259
+ { name : 'Nesting' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
260
+ { name : 'Ratio Comment' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
261
+ { name : 'Complexity Simplified' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
262
+ { name : 'Line Of Code' , total : '-' , min : '-' , mean : '-' , max : '-' }
263
+ ]
264
+ } ) ;
125
265
126
266
componentDidMount ( ) {
127
267
128
- findMeasuresF77 ( this . props . project . key ) . then ( ( item ) => {
268
+ findMeasuresF77 . then ( ( item ) => {
129
269
this . setState ( {
130
270
dataF77 : item
131
271
} ) ;
132
272
} ) ;
133
- }
134
-
135
- constructor ( ) {
136
- super ( ) ;
137
- this . findMeasures = this . findMeasures . bind ( this ) ;
138
- }
139
-
140
- componentDidMount ( ) {
141
-
142
- this . findMeasures ( ) . then ( ( valuesReturnedByAPI ) => {
143
- this . setState ( {
144
- data : valuesReturnedByAPI
145
- } ) ;
146
- } ) ;
147
-
148
- this . setState ( {
149
- /* dataF77: [
150
- { name: 'Nesting', total: '-', min: 5, mean: 5.2, max: 6 },
151
- { name: 'Ratio Comment', total: '-', min: 18.6, mean: 29.8, max: 38.9 },
152
- { name: 'Complexity Simplified', total: '-', min: 26, mean: 33.6, max: 58 },
153
- { name: 'Line Of Code', total: 601, min: 101, mean: 110.2, max: 182 }
154
- ],*/
155
- dataF90 : [
156
- { name : 'Nesting' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
157
- { name : 'Ratio Comment' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
158
- { name : 'Complexity Simplified' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
159
- { name : 'Line Of Code' , total : '-' , min : '-' , mean : '-' , max : '-' }
160
- ] ,
161
- dataSH : [
162
- { name : 'Nesting' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
163
- { name : 'Ratio Comment' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
164
- { name : 'Complexity Simplified' , total : '-' , min : '-' , mean : '-' , max : '-' } ,
165
- { name : 'Line Of Code' , total : '-' , min : '-' , mean : '-' , max : '-' }
166
- ]
167
- } ) ;
273
+
274
+ findMeasuresF90 . then ( ( item ) => {
275
+ this . setState ( {
276
+ dataF90 : item
277
+ } ) ;
278
+ } ) ;
279
+
280
+ findMeasuresShell . then ( ( item ) => {
281
+ this . setState ( {
282
+ dataSH : item
283
+ } ) ;
284
+ } ) ;
168
285
}
169
286
170
287
render ( ) {
@@ -194,4 +311,4 @@ class MetricsSummaryTab extends React.Component {
194
311
} ;
195
312
}
196
313
197
- export default MetricsSummaryTab ;
314
+ export default MetricsSummaryTab ;
0 commit comments