Skip to content

Commit aa0412f

Browse files
committed
#966, simplify __stats_loc method
1 parent f142aa5 commit aa0412f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/info/langs/language.tera

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,13 @@ fn __loc(language_type: &tokei::LanguageType, language: &tokei::Language) -> usi
122122

123123
fn __stats_loc(language_type: &tokei::LanguageType, stats: &tokei::CodeStats) -> usize {
124124
match language_type {
125-
{% for language, attrs in languages -%}
126-
{%- set line_types = attrs.line_types | default(value=['code']) -%}
125+
{% for language, attrs in languages -%}
126+
{%- set line_types = attrs.line_types | default(value=['code']) -%}
127+
{%- if attrs.line_types -%}
127128
tokei::LanguageType::{{ language }} => stats.{{ line_types.0 }}{% for line_type in line_types | slice(start=1) %} + stats.{{ line_type }}{% endfor %},
128-
{% endfor %}
129-
_ => 0, // Tokei doesn't filter children languages according to the input config
129+
{% endif -%}
130+
{% endfor %}
131+
_ => stats.code
130132
}
131133
}
132134

src/info/langs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ mod test {
199199

200200
let loc_by_language = get_loc_by_language(&languages).unwrap();
201201

202-
assert_eq!(loc_by_language[&Language::Vue], 100);
202+
assert_eq!(loc_by_language[&Language::Vue], 110);
203203
}
204204

205205
#[test]

0 commit comments

Comments
 (0)