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 = "nan_default", with = "non_finite")]
270 pub sloc_average: f64,
271 #[serde(default = "nan_default", with = "non_finite")]
273 pub ploc_average: f64,
274 #[serde(default = "nan_default", with = "non_finite")]
276 pub lloc_average: f64,
277 #[serde(default = "nan_default", with = "non_finite")]
279 pub cloc_average: f64,
280 #[serde(default = "nan_default", with = "non_finite")]
282 pub blank_average: f64,
283 pub sloc_min: u64,
285 pub sloc_max: u64,
287 pub cloc_min: u64,
289 pub cloc_max: u64,
291 pub ploc_min: u64,
293 pub ploc_max: u64,
295 pub lloc_min: u64,
297 pub lloc_max: u64,
299 pub blank_min: u64,
301 pub blank_max: u64,
303}
304
305impl From<&loc::Stats> for Loc {
306 fn from(s: &loc::Stats) -> Self {
307 Self {
308 sloc: s.sloc(),
309 ploc: s.ploc(),
310 lloc: s.lloc(),
311 cloc: s.cloc(),
312 blank: s.blank(),
313 sloc_average: s.sloc_average(),
314 ploc_average: s.ploc_average(),
315 lloc_average: s.lloc_average(),
316 cloc_average: s.cloc_average(),
317 blank_average: s.blank_average(),
318 sloc_min: s.sloc_min(),
319 sloc_max: s.sloc_max(),
320 cloc_min: s.cloc_min(),
321 cloc_max: s.cloc_max(),
322 ploc_min: s.ploc_min(),
323 ploc_max: s.ploc_max(),
324 lloc_min: s.lloc_min(),
325 lloc_max: s.lloc_max(),
326 blank_min: s.blank_min(),
327 blank_max: s.blank_max(),
328 }
329 }
330}
331
332#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
334pub struct Mi {
335 #[serde(default = "nan_default", with = "non_finite")]
337 pub original: f64,
338 #[serde(default = "nan_default", with = "non_finite")]
340 pub sei: f64,
341 #[serde(default = "nan_default", with = "non_finite")]
343 pub visual_studio: f64,
344}
345
346impl From<&mi::Stats> for Mi {
347 fn from(s: &mi::Stats) -> Self {
348 Self {
349 original: s.original(),
350 sei: s.sei(),
351 visual_studio: s.visual_studio(),
352 }
353 }
354}
355
356#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
358pub struct Nargs {
359 pub function_args: u64,
361 pub closure_args: u64,
363 #[serde(default = "nan_default", with = "non_finite")]
365 pub function_args_average: f64,
366 #[serde(default = "nan_default", with = "non_finite")]
368 pub closure_args_average: f64,
369 pub total: u64,
371 #[serde(default)]
381 pub value: u64,
382 #[serde(default = "nan_default", with = "non_finite")]
384 pub average: f64,
385 pub function_args_min: u64,
387 pub function_args_max: u64,
389 pub closure_args_min: u64,
391 pub closure_args_max: u64,
393}
394
395impl From<&nargs::Stats> for Nargs {
396 fn from(s: &nargs::Stats) -> Self {
397 Self {
398 function_args: s.function_args_sum(),
399 closure_args: s.closure_args_sum(),
400 function_args_average: s.function_args_average(),
401 closure_args_average: s.closure_args_average(),
402 total: s.total(),
403 value: s.own_args(),
404 average: s.average(),
405 function_args_min: s.function_args_min(),
406 function_args_max: s.function_args_max(),
407 closure_args_min: s.closure_args_min(),
408 closure_args_max: s.closure_args_max(),
409 }
410 }
411}
412
413#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
415pub struct Nom {
416 pub functions: u64,
418 pub closures: u64,
420 #[serde(default = "nan_default", with = "non_finite")]
422 pub functions_average: f64,
423 #[serde(default = "nan_default", with = "non_finite")]
425 pub closures_average: f64,
426 pub total: u64,
428 #[serde(default = "nan_default", with = "non_finite")]
430 pub average: f64,
431 pub functions_min: u64,
433 pub functions_max: u64,
435 pub closures_min: u64,
437 pub closures_max: u64,
439}
440
441impl From<&nom::Stats> for Nom {
442 fn from(s: &nom::Stats) -> Self {
443 Self {
444 functions: s.functions_sum(),
445 closures: s.closures_sum(),
446 functions_average: s.functions_average(),
447 closures_average: s.closures_average(),
448 total: s.total(),
449 average: s.average(),
450 functions_min: s.functions_min(),
451 functions_max: s.functions_max(),
452 closures_min: s.closures_min(),
453 closures_max: s.closures_max(),
454 }
455 }
456}
457
458#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
460pub struct Npa {
461 pub class_npa_sum: u64,
463 pub interface_npa_sum: u64,
465 pub class_attributes: u64,
467 pub interface_attributes: u64,
469 #[serde(default = "nan_default", with = "non_finite")]
471 pub class_cda: f64,
472 #[serde(default = "nan_default", with = "non_finite")]
474 pub interface_cda: f64,
475 pub total: u64,
477 pub total_attributes: u64,
479 #[serde(default = "nan_default", with = "non_finite")]
481 pub cda: f64,
482}
483
484impl From<&npa::Stats> for Npa {
485 fn from(s: &npa::Stats) -> Self {
486 Self {
487 class_npa_sum: s.class_npa_sum(),
488 interface_npa_sum: s.interface_npa_sum(),
489 class_attributes: s.class_na_sum(),
490 interface_attributes: s.interface_na_sum(),
491 class_cda: s.class_cda(),
492 interface_cda: s.interface_cda(),
493 total: s.total_npa(),
494 total_attributes: s.total_na(),
495 cda: s.total_cda(),
496 }
497 }
498}
499
500#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
502pub struct Npm {
503 pub class_npm_sum: u64,
505 pub interface_npm_sum: u64,
507 pub class_methods: u64,
509 pub interface_methods: u64,
511 #[serde(default = "nan_default", with = "non_finite")]
513 pub class_coa: f64,
514 #[serde(default = "nan_default", with = "non_finite")]
516 pub interface_coa: f64,
517 pub total: u64,
519 pub total_methods: u64,
521 #[serde(default = "nan_default", with = "non_finite")]
523 pub coa: f64,
524}
525
526impl From<&npm::Stats> for Npm {
527 fn from(s: &npm::Stats) -> Self {
528 Self {
529 class_npm_sum: s.class_npm_sum(),
530 interface_npm_sum: s.interface_npm_sum(),
531 class_methods: s.class_nm_sum(),
532 interface_methods: s.interface_nm_sum(),
533 class_coa: s.class_coa(),
534 interface_coa: s.interface_coa(),
535 total: s.total_npm(),
536 total_methods: s.total_nm(),
537 coa: s.total_coa(),
538 }
539 }
540}
541
542#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
544pub struct Tokens {
545 pub tokens: u64,
547 #[serde(default = "nan_default", with = "non_finite")]
549 pub average: f64,
550 pub min: u64,
552 pub max: u64,
554}
555
556impl From<&tokens::Stats> for Tokens {
557 fn from(s: &tokens::Stats) -> Self {
558 Self {
559 tokens: s.tokens_sum(),
560 average: s.tokens_average(),
561 min: s.tokens_min(),
562 max: s.tokens_max(),
563 }
564 }
565}
566
567#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
569pub struct Wmc {
570 pub class_wmc_sum: u64,
572 pub interface_wmc_sum: u64,
574 pub total: u64,
576}
577
578impl From<&wmc::Stats> for Wmc {
579 fn from(s: &wmc::Stats) -> Self {
580 Self {
581 class_wmc_sum: s.class_wmc_sum(),
582 interface_wmc_sum: s.interface_wmc_sum(),
583 total: s.total_wmc(),
584 }
585 }
586}