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)]
85 pub value: u64,
86 #[serde(default = "nan_default", with = "non_finite")]
88 pub average: f64,
89 pub min: u64,
91 pub max: u64,
93}
94
95impl From<&cognitive::Stats> for Cognitive {
96 fn from(s: &cognitive::Stats) -> Self {
97 Self {
98 sum: s.cognitive_sum(),
99 value: s.cognitive(),
100 average: s.cognitive_average(),
101 min: s.cognitive_min(),
102 max: s.cognitive_max(),
103 }
104 }
105}
106
107#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
109pub struct CyclomaticModified {
110 pub sum: u64,
112 #[serde(default)]
115 pub value: u64,
116 #[serde(default = "nan_default", with = "non_finite")]
118 pub average: f64,
119 pub min: u64,
121 pub max: u64,
123}
124
125#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
127pub struct Cyclomatic {
128 pub sum: u64,
130 #[serde(default)]
136 pub value: u64,
137 #[serde(default = "nan_default", with = "non_finite")]
139 pub average: f64,
140 pub min: u64,
142 pub max: u64,
144 pub modified: CyclomaticModified,
146}
147
148impl From<&cyclomatic::Stats> for Cyclomatic {
149 fn from(s: &cyclomatic::Stats) -> Self {
150 Self {
151 sum: s.cyclomatic_sum(),
152 value: s.cyclomatic(),
153 average: s.cyclomatic_average(),
154 min: s.cyclomatic_min(),
155 max: s.cyclomatic_max(),
156 modified: CyclomaticModified {
157 sum: s.cyclomatic_modified_sum(),
158 value: s.cyclomatic_modified(),
159 average: s.cyclomatic_modified_average(),
160 min: s.cyclomatic_modified_min(),
161 max: s.cyclomatic_modified_max(),
162 },
163 }
164 }
165}
166
167#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
169pub struct Nexits {
170 pub sum: u64,
172 #[serde(default = "nan_default", with = "non_finite")]
174 pub average: f64,
175 pub min: u64,
177 pub max: u64,
179}
180
181impl From<&nexits::Stats> for Nexits {
182 fn from(s: &nexits::Stats) -> Self {
183 Self {
184 sum: s.nexits_sum(),
185 average: s.nexits_average(),
186 min: s.nexits_min(),
187 max: s.nexits_max(),
188 }
189 }
190}
191
192#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
194pub struct Halstead {
195 pub unique_operators: u64,
197 pub total_operators: u64,
199 pub unique_operands: u64,
201 pub total_operands: u64,
203 pub length: u64,
205 #[serde(default = "nan_default", with = "non_finite")]
207 pub estimated_program_length: f64,
208 #[serde(default = "nan_default", with = "non_finite")]
210 pub purity_ratio: f64,
211 pub vocabulary: u64,
213 #[serde(default = "nan_default", with = "non_finite")]
215 pub volume: f64,
216 #[serde(default = "nan_default", with = "non_finite")]
218 pub difficulty: f64,
219 #[serde(default = "nan_default", with = "non_finite")]
221 pub level: f64,
222 #[serde(default = "nan_default", with = "non_finite")]
224 pub effort: f64,
225 #[serde(default = "nan_default", with = "non_finite")]
227 pub time: f64,
228 #[serde(default = "nan_default", with = "non_finite")]
230 pub bugs: f64,
231}
232
233impl From<&halstead::Stats> for Halstead {
234 fn from(s: &halstead::Stats) -> Self {
235 Self {
236 unique_operators: s.unique_operators(),
237 total_operators: s.total_operators(),
238 unique_operands: s.unique_operands(),
239 total_operands: s.total_operands(),
240 length: s.length(),
241 estimated_program_length: s.estimated_program_length(),
242 purity_ratio: s.purity_ratio(),
243 vocabulary: s.vocabulary(),
244 volume: s.volume(),
245 difficulty: s.difficulty(),
246 level: s.level(),
247 effort: s.effort(),
248 time: s.time(),
249 bugs: s.bugs(),
250 }
251 }
252}
253
254#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
256pub struct Loc {
257 pub sloc: u64,
259 pub ploc: u64,
261 pub lloc: u64,
263 pub cloc: u64,
265 pub blank: u64,
267 #[serde(default = "nan_default", with = "non_finite")]
269 pub sloc_average: f64,
270 #[serde(default = "nan_default", with = "non_finite")]
272 pub ploc_average: f64,
273 #[serde(default = "nan_default", with = "non_finite")]
275 pub lloc_average: f64,
276 #[serde(default = "nan_default", with = "non_finite")]
278 pub cloc_average: f64,
279 #[serde(default = "nan_default", with = "non_finite")]
281 pub blank_average: f64,
282 pub sloc_min: u64,
284 pub sloc_max: u64,
286 pub cloc_min: u64,
288 pub cloc_max: u64,
290 pub ploc_min: u64,
292 pub ploc_max: u64,
294 pub lloc_min: u64,
296 pub lloc_max: u64,
298 pub blank_min: u64,
300 pub blank_max: u64,
302}
303
304impl From<&loc::Stats> for Loc {
305 fn from(s: &loc::Stats) -> Self {
306 Self {
307 sloc: s.sloc(),
308 ploc: s.ploc(),
309 lloc: s.lloc(),
310 cloc: s.cloc(),
311 blank: s.blank(),
312 sloc_average: s.sloc_average(),
313 ploc_average: s.ploc_average(),
314 lloc_average: s.lloc_average(),
315 cloc_average: s.cloc_average(),
316 blank_average: s.blank_average(),
317 sloc_min: s.sloc_min(),
318 sloc_max: s.sloc_max(),
319 cloc_min: s.cloc_min(),
320 cloc_max: s.cloc_max(),
321 ploc_min: s.ploc_min(),
322 ploc_max: s.ploc_max(),
323 lloc_min: s.lloc_min(),
324 lloc_max: s.lloc_max(),
325 blank_min: s.blank_min(),
326 blank_max: s.blank_max(),
327 }
328 }
329}
330
331#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
333pub struct Mi {
334 #[serde(default = "nan_default", with = "non_finite")]
336 pub original: f64,
337 #[serde(default = "nan_default", with = "non_finite")]
339 pub sei: f64,
340 #[serde(default = "nan_default", with = "non_finite")]
342 pub visual_studio: f64,
343}
344
345impl From<&mi::Stats> for Mi {
346 fn from(s: &mi::Stats) -> Self {
347 Self {
348 original: s.original(),
349 sei: s.sei(),
350 visual_studio: s.visual_studio(),
351 }
352 }
353}
354
355#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
357pub struct Nargs {
358 pub function_args: u64,
360 pub closure_args: u64,
362 #[serde(default = "nan_default", with = "non_finite")]
364 pub function_args_average: f64,
365 #[serde(default = "nan_default", with = "non_finite")]
367 pub closure_args_average: f64,
368 pub total: u64,
370 #[serde(default = "nan_default", with = "non_finite")]
372 pub average: f64,
373 pub function_args_min: u64,
375 pub function_args_max: u64,
377 pub closure_args_min: u64,
379 pub closure_args_max: u64,
381}
382
383impl From<&nargs::Stats> for Nargs {
384 fn from(s: &nargs::Stats) -> Self {
385 Self {
386 function_args: s.function_args_sum(),
387 closure_args: s.closure_args_sum(),
388 function_args_average: s.function_args_average(),
389 closure_args_average: s.closure_args_average(),
390 total: s.total(),
391 average: s.average(),
392 function_args_min: s.function_args_min(),
393 function_args_max: s.function_args_max(),
394 closure_args_min: s.closure_args_min(),
395 closure_args_max: s.closure_args_max(),
396 }
397 }
398}
399
400#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
402pub struct Nom {
403 pub functions: u64,
405 pub closures: u64,
407 #[serde(default = "nan_default", with = "non_finite")]
409 pub functions_average: f64,
410 #[serde(default = "nan_default", with = "non_finite")]
412 pub closures_average: f64,
413 pub total: u64,
415 #[serde(default = "nan_default", with = "non_finite")]
417 pub average: f64,
418 pub functions_min: u64,
420 pub functions_max: u64,
422 pub closures_min: u64,
424 pub closures_max: u64,
426}
427
428impl From<&nom::Stats> for Nom {
429 fn from(s: &nom::Stats) -> Self {
430 Self {
431 functions: s.functions_sum(),
432 closures: s.closures_sum(),
433 functions_average: s.functions_average(),
434 closures_average: s.closures_average(),
435 total: s.total(),
436 average: s.average(),
437 functions_min: s.functions_min(),
438 functions_max: s.functions_max(),
439 closures_min: s.closures_min(),
440 closures_max: s.closures_max(),
441 }
442 }
443}
444
445#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
447pub struct Npa {
448 pub class_npa_sum: u64,
450 pub interface_npa_sum: u64,
452 pub class_attributes: u64,
454 pub interface_attributes: u64,
456 #[serde(default = "nan_default", with = "non_finite")]
458 pub class_cda: f64,
459 #[serde(default = "nan_default", with = "non_finite")]
461 pub interface_cda: f64,
462 pub total: u64,
464 pub total_attributes: u64,
466 #[serde(default = "nan_default", with = "non_finite")]
468 pub cda: f64,
469}
470
471impl From<&npa::Stats> for Npa {
472 fn from(s: &npa::Stats) -> Self {
473 Self {
474 class_npa_sum: s.class_npa_sum(),
475 interface_npa_sum: s.interface_npa_sum(),
476 class_attributes: s.class_na_sum(),
477 interface_attributes: s.interface_na_sum(),
478 class_cda: s.class_cda(),
479 interface_cda: s.interface_cda(),
480 total: s.total_npa(),
481 total_attributes: s.total_na(),
482 cda: s.total_cda(),
483 }
484 }
485}
486
487#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
489pub struct Npm {
490 pub class_npm_sum: u64,
492 pub interface_npm_sum: u64,
494 pub class_methods: u64,
496 pub interface_methods: u64,
498 #[serde(default = "nan_default", with = "non_finite")]
500 pub class_coa: f64,
501 #[serde(default = "nan_default", with = "non_finite")]
503 pub interface_coa: f64,
504 pub total: u64,
506 pub total_methods: u64,
508 #[serde(default = "nan_default", with = "non_finite")]
510 pub coa: f64,
511}
512
513impl From<&npm::Stats> for Npm {
514 fn from(s: &npm::Stats) -> Self {
515 Self {
516 class_npm_sum: s.class_npm_sum(),
517 interface_npm_sum: s.interface_npm_sum(),
518 class_methods: s.class_nm_sum(),
519 interface_methods: s.interface_nm_sum(),
520 class_coa: s.class_coa(),
521 interface_coa: s.interface_coa(),
522 total: s.total_npm(),
523 total_methods: s.total_nm(),
524 coa: s.total_coa(),
525 }
526 }
527}
528
529#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
531pub struct Tokens {
532 pub tokens: u64,
534 #[serde(default = "nan_default", with = "non_finite")]
536 pub average: f64,
537 pub min: u64,
539 pub max: u64,
541}
542
543impl From<&tokens::Stats> for Tokens {
544 fn from(s: &tokens::Stats) -> Self {
545 Self {
546 tokens: s.tokens_sum(),
547 average: s.tokens_average(),
548 min: s.tokens_min(),
549 max: s.tokens_max(),
550 }
551 }
552}
553
554#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
556pub struct Wmc {
557 pub class_wmc_sum: u64,
559 pub interface_wmc_sum: u64,
561 pub total: u64,
563}
564
565impl From<&wmc::Stats> for Wmc {
566 fn from(s: &wmc::Stats) -> Self {
567 Self {
568 class_wmc_sum: s.class_wmc_sum(),
569 interface_wmc_sum: s.interface_wmc_sum(),
570 total: s.total_wmc(),
571 }
572 }
573}