|
|
|
@ -202,32 +202,30 @@ impl InfoField for LanguagesInfo { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Counts the lines-of-code of a tokei `Language`. Takes into
|
|
|
|
|
|
|
|
/// account that a prose language's comments *are* its code.
|
|
|
|
|
|
|
|
pub fn loc(language_type: &tokei::LanguageType, language: &tokei::Language) -> usize { |
|
|
|
pub fn loc(language_type: &tokei::LanguageType, language: &tokei::Language) -> usize { |
|
|
|
__loc(language_type, language) |
|
|
|
__loc(language_type, language.code, language.comments) |
|
|
|
+ language |
|
|
|
+ language |
|
|
|
.children |
|
|
|
.children |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
|
.fold(0, |sum, (lang_type, reports)| { |
|
|
|
.fold(0, |sum, (lang_type, reports)| { |
|
|
|
sum + reports |
|
|
|
sum + reports.iter().fold(0, |sum, report| { |
|
|
|
.iter() |
|
|
|
let stats = report.stats.summarise(); |
|
|
|
.fold(0, |sum, report| sum + stats_loc(lang_type, &report.stats)) |
|
|
|
sum + __loc(lang_type, stats.code, stats.comments) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Counts the lines-of-code of a tokei `Report`. This is the child of a
|
|
|
|
fn __loc(language_type: &tokei::LanguageType, code: usize, comments: usize) -> usize { |
|
|
|
/// `tokei::CodeStats`.
|
|
|
|
match language_type { |
|
|
|
pub fn stats_loc(language_type: &tokei::LanguageType, stats: &tokei::CodeStats) -> usize { |
|
|
|
tokei::LanguageType::Markdown => code + comments, |
|
|
|
let stats = stats.summarise(); |
|
|
|
_ => code, |
|
|
|
__stats_loc(language_type, &stats) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)] |
|
|
|
#[cfg(test)] |
|
|
|
mod test { |
|
|
|
mod test { |
|
|
|
use rstest::rstest; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use super::*; |
|
|
|
use super::*; |
|
|
|
|
|
|
|
use rstest::rstest; |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn test_display_languages_info() { |
|
|
|
fn test_display_languages_info() { |
|
|
|
|