use super::*;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Abc {
pub assignments: u64,
pub branches: u64,
pub conditions: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub magnitude: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub value: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub assignments_average: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub branches_average: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub conditions_average: f64,
pub assignments_min: u64,
pub assignments_max: u64,
pub branches_min: u64,
pub branches_max: u64,
pub conditions_min: u64,
pub conditions_max: u64,
}
impl From<&abc::Stats> for Abc {
fn from(s: &abc::Stats) -> Self {
Self {
assignments: s.assignments_sum(),
branches: s.branches_sum(),
conditions: s.conditions_sum(),
magnitude: s.magnitude_sum(),
value: s.magnitude(),
assignments_average: s.assignments_average(),
branches_average: s.branches_average(),
conditions_average: s.conditions_average(),
assignments_min: s.assignments_min(),
assignments_max: s.assignments_max(),
branches_min: s.branches_min(),
branches_max: s.branches_max(),
conditions_min: s.conditions_min(),
conditions_max: s.conditions_max(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Cognitive {
pub sum: u64,
#[serde(default)]
pub value: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub average: f64,
pub min: u64,
pub max: u64,
}
impl From<&cognitive::Stats> for Cognitive {
fn from(s: &cognitive::Stats) -> Self {
Self {
sum: s.cognitive_sum(),
value: s.cognitive(),
average: s.cognitive_average(),
min: s.cognitive_min(),
max: s.cognitive_max(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CyclomaticModified {
pub sum: u64,
#[serde(default)]
pub value: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub average: f64,
pub min: u64,
pub max: u64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Cyclomatic {
pub sum: u64,
#[serde(default)]
pub value: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub average: f64,
pub min: u64,
pub max: u64,
pub modified: CyclomaticModified,
}
impl From<&cyclomatic::Stats> for Cyclomatic {
fn from(s: &cyclomatic::Stats) -> Self {
Self {
sum: s.cyclomatic_sum(),
value: s.cyclomatic(),
average: s.cyclomatic_average(),
min: s.cyclomatic_min(),
max: s.cyclomatic_max(),
modified: CyclomaticModified {
sum: s.cyclomatic_modified_sum(),
value: s.cyclomatic_modified(),
average: s.cyclomatic_modified_average(),
min: s.cyclomatic_modified_min(),
max: s.cyclomatic_modified_max(),
},
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Nexits {
pub sum: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub average: f64,
pub min: u64,
pub max: u64,
}
impl From<&nexits::Stats> for Nexits {
fn from(s: &nexits::Stats) -> Self {
Self {
sum: s.nexits_sum(),
average: s.nexits_average(),
min: s.nexits_min(),
max: s.nexits_max(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Halstead {
pub unique_operators: u64,
pub total_operators: u64,
pub unique_operands: u64,
pub total_operands: u64,
pub length: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub estimated_program_length: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub purity_ratio: f64,
pub vocabulary: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub volume: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub difficulty: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub level: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub effort: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub time: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub bugs: f64,
}
impl From<&halstead::Stats> for Halstead {
fn from(s: &halstead::Stats) -> Self {
Self {
unique_operators: s.unique_operators(),
total_operators: s.total_operators(),
unique_operands: s.unique_operands(),
total_operands: s.total_operands(),
length: s.length(),
estimated_program_length: s.estimated_program_length(),
purity_ratio: s.purity_ratio(),
vocabulary: s.vocabulary(),
volume: s.volume(),
difficulty: s.difficulty(),
level: s.level(),
effort: s.effort(),
time: s.time(),
bugs: s.bugs(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Loc {
pub sloc: u64,
pub ploc: u64,
pub lloc: u64,
pub cloc: u64,
pub blank: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub sloc_average: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub ploc_average: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub lloc_average: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub cloc_average: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub blank_average: f64,
pub sloc_min: u64,
pub sloc_max: u64,
pub cloc_min: u64,
pub cloc_max: u64,
pub ploc_min: u64,
pub ploc_max: u64,
pub lloc_min: u64,
pub lloc_max: u64,
pub blank_min: u64,
pub blank_max: u64,
}
impl From<&loc::Stats> for Loc {
fn from(s: &loc::Stats) -> Self {
Self {
sloc: s.sloc(),
ploc: s.ploc(),
lloc: s.lloc(),
cloc: s.cloc(),
blank: s.blank(),
sloc_average: s.sloc_average(),
ploc_average: s.ploc_average(),
lloc_average: s.lloc_average(),
cloc_average: s.cloc_average(),
blank_average: s.blank_average(),
sloc_min: s.sloc_min(),
sloc_max: s.sloc_max(),
cloc_min: s.cloc_min(),
cloc_max: s.cloc_max(),
ploc_min: s.ploc_min(),
ploc_max: s.ploc_max(),
lloc_min: s.lloc_min(),
lloc_max: s.lloc_max(),
blank_min: s.blank_min(),
blank_max: s.blank_max(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Mi {
#[serde(default = "nan_default", with = "non_finite")]
pub original: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub sei: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub visual_studio: f64,
}
impl From<&mi::Stats> for Mi {
fn from(s: &mi::Stats) -> Self {
Self {
original: s.original(),
sei: s.sei(),
visual_studio: s.visual_studio(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Nargs {
pub function_args: u64,
pub closure_args: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub function_args_average: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub closure_args_average: f64,
pub total: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub average: f64,
pub function_args_min: u64,
pub function_args_max: u64,
pub closure_args_min: u64,
pub closure_args_max: u64,
}
impl From<&nargs::Stats> for Nargs {
fn from(s: &nargs::Stats) -> Self {
Self {
function_args: s.function_args_sum(),
closure_args: s.closure_args_sum(),
function_args_average: s.function_args_average(),
closure_args_average: s.closure_args_average(),
total: s.total(),
average: s.average(),
function_args_min: s.function_args_min(),
function_args_max: s.function_args_max(),
closure_args_min: s.closure_args_min(),
closure_args_max: s.closure_args_max(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Nom {
pub functions: u64,
pub closures: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub functions_average: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub closures_average: f64,
pub total: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub average: f64,
pub functions_min: u64,
pub functions_max: u64,
pub closures_min: u64,
pub closures_max: u64,
}
impl From<&nom::Stats> for Nom {
fn from(s: &nom::Stats) -> Self {
Self {
functions: s.functions_sum(),
closures: s.closures_sum(),
functions_average: s.functions_average(),
closures_average: s.closures_average(),
total: s.total(),
average: s.average(),
functions_min: s.functions_min(),
functions_max: s.functions_max(),
closures_min: s.closures_min(),
closures_max: s.closures_max(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Npa {
pub class_npa_sum: u64,
pub interface_npa_sum: u64,
pub class_attributes: u64,
pub interface_attributes: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub class_cda: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub interface_cda: f64,
pub total: u64,
pub total_attributes: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub cda: f64,
}
impl From<&npa::Stats> for Npa {
fn from(s: &npa::Stats) -> Self {
Self {
class_npa_sum: s.class_npa_sum(),
interface_npa_sum: s.interface_npa_sum(),
class_attributes: s.class_na_sum(),
interface_attributes: s.interface_na_sum(),
class_cda: s.class_cda(),
interface_cda: s.interface_cda(),
total: s.total_npa(),
total_attributes: s.total_na(),
cda: s.total_cda(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Npm {
pub class_npm_sum: u64,
pub interface_npm_sum: u64,
pub class_methods: u64,
pub interface_methods: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub class_coa: f64,
#[serde(default = "nan_default", with = "non_finite")]
pub interface_coa: f64,
pub total: u64,
pub total_methods: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub coa: f64,
}
impl From<&npm::Stats> for Npm {
fn from(s: &npm::Stats) -> Self {
Self {
class_npm_sum: s.class_npm_sum(),
interface_npm_sum: s.interface_npm_sum(),
class_methods: s.class_nm_sum(),
interface_methods: s.interface_nm_sum(),
class_coa: s.class_coa(),
interface_coa: s.interface_coa(),
total: s.total_npm(),
total_methods: s.total_nm(),
coa: s.total_coa(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Tokens {
pub tokens: u64,
#[serde(default = "nan_default", with = "non_finite")]
pub average: f64,
pub min: u64,
pub max: u64,
}
impl From<&tokens::Stats> for Tokens {
fn from(s: &tokens::Stats) -> Self {
Self {
tokens: s.tokens_sum(),
average: s.tokens_average(),
min: s.tokens_min(),
max: s.tokens_max(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Wmc {
pub class_wmc_sum: u64,
pub interface_wmc_sum: u64,
pub total: u64,
}
impl From<&wmc::Stats> for Wmc {
fn from(s: &wmc::Stats) -> Self {
Self {
class_wmc_sum: s.class_wmc_sum(),
interface_wmc_sum: s.interface_wmc_sum(),
total: s.total_wmc(),
}
}
}