1use super::*;
6
7#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9pub struct Abc {
10 pub assignments: u64,
12 pub branches: u64,
14 pub conditions: u64,
16 #[serde(default = "nan_default", with = "non_finite")]
19 pub magnitude: f64,
20 #[serde(default = "nan_default", with = "non_finite")]
27 pub value: f64,
28 #[serde(default = "nan_default", with = "non_finite")]
30 pub assignments_average: f64,
31 #[serde(default = "nan_default", with = "non_finite")]
33 pub branches_average: f64,
34 #[serde(default = "nan_default", with = "non_finite")]
36 pub conditions_average: f64,
37 pub assignments_min: u64,
39 pub assignments_max: u64,
41 pub branches_min: u64,
43 pub branches_max: u64,
45 pub conditions_min: u64,
47 pub conditions_max: u64,
49}
50
51impl From<&abc::Stats> for Abc {
52 fn from(s: &abc::Stats) -> Self {
53 Self {
54 assignments: s.assignments_sum(),
55 branches: s.branches_sum(),
56 conditions: s.conditions_sum(),
57 magnitude: s.magnitude_sum(),
58 value: s.magnitude(),
59 assignments_average: s.assignments_average(),
60 branches_average: s.branches_average(),
61 conditions_average: s.conditions_average(),
62 assignments_min: s.assignments_min(),
63 assignments_max: s.assignments_max(),
64 branches_min: s.branches_min(),
65 branches_max: s.branches_max(),
66 conditions_min: s.conditions_min(),
67 conditions_max: s.conditions_max(),
68 }
69 }
70}
71
72#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
74pub struct Cognitive {
75 pub sum: u64,
77 #[serde(default)]
86 pub value: u64,
87 #[serde(default = "nan_default", with = "non_finite")]
89 pub average: f64,
90 pub min: u64,
92 pub max: u64,
94}
95
96impl From<&cognitive::Stats> for Cognitive {
97 fn from(s: &cognitive::Stats) -> Self {
98 Self {
99 sum: s.cognitive_sum(),
100 value: s.cognitive(),
101 average: s.cognitive_average(),
102 min: s.cognitive_min(),
103 max: s.cognitive_max(),
104 }
105 }
106}
107
108#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
110pub struct CyclomaticModified {
111 pub sum: u64,
113 #[serde(default)]
116 pub value: u64,
117 #[serde(default = "nan_default", with = "non_finite")]
119 pub average: f64,
120 pub min: u64,
122 pub max: u64,
124}
125
126#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
128pub struct Cyclomatic {
129 pub sum: u64,
131 #[serde(default)]
137 pub value: u64,
138 #[serde(default = "nan_default", with = "non_finite")]
140 pub average: f64,
141 pub min: u64,
143 pub max: u64,
145 pub modified: CyclomaticModified,
147}
148
149impl From<&cyclomatic::Stats> for Cyclomatic {
150 fn from(s: &cyclomatic::Stats) -> Self {
151 Self {
152 sum: s.cyclomatic_sum(),
153 value: s.cyclomatic(),
154 average: s.cyclomatic_average(),
155 min: s.cyclomatic_min(),
156 max: s.cyclomatic_max(),
157 modified: CyclomaticModified {
158 sum: s.cyclomatic_modified_sum(),
159 value: s.cyclomatic_modified(),
160 average: s.cyclomatic_modified_average(),
161 min: s.cyclomatic_modified_min(),
162 max: s.cyclomatic_modified_max(),
163 },
164 }
165 }
166}
167
168#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
170pub struct Nexits {
171 pub sum: u64,
173 #[serde(default = "nan_default", with = "non_finite")]
175 pub average: f64,
176 pub min: u64,
178 pub max: u64,
180}
181
182impl From<&nexits::Stats> for Nexits {
183 fn from(s: &nexits::Stats) -> Self {
184 Self {
185 sum: s.nexits_sum(),
186 average: s.nexits_average(),
187 min: s.nexits_min(),
188 max: s.nexits_max(),
189 }
190 }
191}
192
193#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
195pub struct Halstead {
196 pub unique_operators: u64,
198 pub total_operators: u64,
200 pub unique_operands: u64,
202 pub total_operands: u64,
204 pub length: u64,
206 #[serde(default = "nan_default", with = "non_finite")]
208 pub estimated_program_length: f64,
209 #[serde(default = "nan_default", with = "non_finite")]
211 pub purity_ratio: f64,
212 pub vocabulary: u64,
214 #[serde(default = "nan_default", with = "non_finite")]
216 pub volume: f64,
217 #[serde(default = "nan_default", with = "non_finite")]
219 pub difficulty: f64,
220 #[serde(default = "nan_default", with = "non_finite")]
222 pub level: f64,
223 #[serde(default = "nan_default", with = "non_finite")]
225 pub effort: f64,
226 #[serde(default = "nan_default", with = "non_finite")]
228 pub time: f64,
229 #[serde(default = "nan_default", with = "non_finite")]
231 pub bugs: f64,
232}
233
234impl From<&halstead::Stats> for Halstead {
235 fn from(s: &halstead::Stats) -> Self {
236 Self {
237 unique_operators: s.unique_operators(),
238 total_operators: s.total_operators(),
239 unique_operands: s.unique_operands(),
240 total_operands: s.total_operands(),
241 length: s.length(),
242 estimated_program_length: s.estimated_program_length(),
243 purity_ratio: s.purity_ratio(),
244 vocabulary: s.vocabulary(),
245 volume: s.volume(),
246 difficulty: s.difficulty(),
247 level: s.level(),
248 effort: s.effort(),
249 time: s.time(),
250 bugs: s.bugs(),
251 }
252 }
253}
254
255#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
257pub struct Loc {
258 pub sloc: u64,
260 pub ploc: u64,
262 pub lloc: u64,
264 pub cloc: u64,
266 pub blank: u64,
268 #[serde(default)]
272 pub dloc: u64,
273 #[serde(default = "nan_default", with = "non_finite")]
275 pub sloc_average: f64,
276 #[serde(default = "nan_default", with = "non_finite")]
278 pub ploc_average: f64,
279 #[serde(default = "nan_default", with = "non_finite")]
281 pub lloc_average: f64,
282 #[serde(default = "nan_default", with = "non_finite")]
284 pub cloc_average: f64,
285 #[serde(default = "nan_default", with = "non_finite")]
287 pub blank_average: f64,
288 #[serde(default = "nan_default", with = "non_finite")]
290 pub dloc_average: f64,
291 pub sloc_min: u64,
293 pub sloc_max: u64,
295 pub cloc_min: u64,
297 pub cloc_max: u64,
299 pub ploc_min: u64,
301 pub ploc_max: u64,
303 pub lloc_min: u64,
305 pub lloc_max: u64,
307 pub blank_min: u64,
309 pub blank_max: u64,
311 #[serde(default)]
313 pub dloc_min: u64,
314 #[serde(default)]
316 pub dloc_max: u64,
317}
318
319impl From<&loc::Stats> for Loc {
320 fn from(s: &loc::Stats) -> Self {
321 Self {
322 sloc: s.sloc(),
323 ploc: s.ploc(),
324 lloc: s.lloc(),
325 cloc: s.cloc(),
326 blank: s.blank(),
327 dloc: s.dloc(),
328 sloc_average: s.sloc_average(),
329 ploc_average: s.ploc_average(),
330 lloc_average: s.lloc_average(),
331 cloc_average: s.cloc_average(),
332 blank_average: s.blank_average(),
333 dloc_average: s.dloc_average(),
334 sloc_min: s.sloc_min(),
335 sloc_max: s.sloc_max(),
336 cloc_min: s.cloc_min(),
337 cloc_max: s.cloc_max(),
338 ploc_min: s.ploc_min(),
339 ploc_max: s.ploc_max(),
340 lloc_min: s.lloc_min(),
341 lloc_max: s.lloc_max(),
342 blank_min: s.blank_min(),
343 blank_max: s.blank_max(),
344 dloc_min: s.dloc_min(),
345 dloc_max: s.dloc_max(),
346 }
347 }
348}
349
350#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
352pub struct Mi {
353 #[serde(default = "nan_default", with = "non_finite")]
355 pub original: f64,
356 #[serde(default = "nan_default", with = "non_finite")]
358 pub sei: f64,
359 #[serde(default = "nan_default", with = "non_finite")]
361 pub visual_studio: f64,
362}
363
364impl From<&mi::Stats> for Mi {
365 fn from(s: &mi::Stats) -> Self {
366 Self {
367 original: s.original(),
368 sei: s.sei(),
369 visual_studio: s.visual_studio(),
370 }
371 }
372}
373
374#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
376pub struct Nargs {
377 pub function_args: u64,
379 pub closure_args: u64,
381 #[serde(default = "nan_default", with = "non_finite")]
383 pub function_args_average: f64,
384 #[serde(default = "nan_default", with = "non_finite")]
386 pub closure_args_average: f64,
387 pub total: u64,
389 #[serde(default)]
399 pub value: u64,
400 #[serde(default = "nan_default", with = "non_finite")]
402 pub average: f64,
403 pub function_args_min: u64,
405 pub function_args_max: u64,
407 pub closure_args_min: u64,
409 pub closure_args_max: u64,
411}
412
413impl From<&nargs::Stats> for Nargs {
414 fn from(s: &nargs::Stats) -> Self {
415 Self {
416 function_args: s.function_args_sum(),
417 closure_args: s.closure_args_sum(),
418 function_args_average: s.function_args_average(),
419 closure_args_average: s.closure_args_average(),
420 total: s.total(),
421 value: s.own_args(),
422 average: s.average(),
423 function_args_min: s.function_args_min(),
424 function_args_max: s.function_args_max(),
425 closure_args_min: s.closure_args_min(),
426 closure_args_max: s.closure_args_max(),
427 }
428 }
429}
430
431#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
433pub struct Nom {
434 pub functions: u64,
436 pub closures: u64,
438 #[serde(default = "nan_default", with = "non_finite")]
440 pub functions_average: f64,
441 #[serde(default = "nan_default", with = "non_finite")]
443 pub closures_average: f64,
444 pub total: u64,
446 #[serde(default = "nan_default", with = "non_finite")]
448 pub average: f64,
449 pub functions_min: u64,
451 pub functions_max: u64,
453 pub closures_min: u64,
455 pub closures_max: u64,
457}
458
459impl From<&nom::Stats> for Nom {
460 fn from(s: &nom::Stats) -> Self {
461 Self {
462 functions: s.functions_sum(),
463 closures: s.closures_sum(),
464 functions_average: s.functions_average(),
465 closures_average: s.closures_average(),
466 total: s.total(),
467 average: s.average(),
468 functions_min: s.functions_min(),
469 functions_max: s.functions_max(),
470 closures_min: s.closures_min(),
471 closures_max: s.closures_max(),
472 }
473 }
474}
475
476#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
478pub struct Npa {
479 pub class_npa_sum: u64,
481 pub interface_npa_sum: u64,
483 pub class_attributes: u64,
485 pub interface_attributes: u64,
487 #[serde(default = "nan_default", with = "non_finite")]
489 pub class_cda: f64,
490 #[serde(default = "nan_default", with = "non_finite")]
492 pub interface_cda: f64,
493 pub total: u64,
495 pub total_attributes: u64,
497 #[serde(default = "nan_default", with = "non_finite")]
499 pub cda: f64,
500}
501
502impl From<&npa::Stats> for Npa {
503 fn from(s: &npa::Stats) -> Self {
504 Self {
505 class_npa_sum: s.class_npa_sum(),
506 interface_npa_sum: s.interface_npa_sum(),
507 class_attributes: s.class_na_sum(),
508 interface_attributes: s.interface_na_sum(),
509 class_cda: s.class_cda(),
510 interface_cda: s.interface_cda(),
511 total: s.total_npa(),
512 total_attributes: s.total_na(),
513 cda: s.total_cda(),
514 }
515 }
516}
517
518#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
520pub struct Npm {
521 pub class_npm_sum: u64,
523 pub interface_npm_sum: u64,
525 pub class_methods: u64,
527 pub interface_methods: u64,
529 #[serde(default = "nan_default", with = "non_finite")]
531 pub class_coa: f64,
532 #[serde(default = "nan_default", with = "non_finite")]
534 pub interface_coa: f64,
535 pub total: u64,
537 pub total_methods: u64,
539 #[serde(default = "nan_default", with = "non_finite")]
541 pub coa: f64,
542}
543
544impl From<&npm::Stats> for Npm {
545 fn from(s: &npm::Stats) -> Self {
546 Self {
547 class_npm_sum: s.class_npm_sum(),
548 interface_npm_sum: s.interface_npm_sum(),
549 class_methods: s.class_nm_sum(),
550 interface_methods: s.interface_nm_sum(),
551 class_coa: s.class_coa(),
552 interface_coa: s.interface_coa(),
553 total: s.total_npm(),
554 total_methods: s.total_nm(),
555 coa: s.total_coa(),
556 }
557 }
558}
559
560#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
562pub struct Tokens {
563 pub tokens: u64,
565 #[serde(default = "nan_default", with = "non_finite")]
567 pub average: f64,
568 pub min: u64,
570 pub max: u64,
572}
573
574impl From<&tokens::Stats> for Tokens {
575 fn from(s: &tokens::Stats) -> Self {
576 Self {
577 tokens: s.tokens_sum(),
578 average: s.tokens_average(),
579 min: s.tokens_min(),
580 max: s.tokens_max(),
581 }
582 }
583}
584
585#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
587pub struct Wmc {
588 pub class_wmc_sum: u64,
590 pub interface_wmc_sum: u64,
592 pub total: u64,
594}
595
596impl From<&wmc::Stats> for Wmc {
597 fn from(s: &wmc::Stats) -> Self {
598 Self {
599 class_wmc_sum: s.class_wmc_sum(),
600 interface_wmc_sum: s.interface_wmc_sum(),
601 total: s.total_wmc(),
602 }
603 }
604}