mirror of
https://github.com/XAMPPRocky/tokei
synced 2024-08-27 19:29:27 +00:00
Fix all feasible clippy issues (#687)
And the ones not deemed feasible were officialy allowed so folks running `cargo clippy` should see no warnings.
This commit is contained in:
parent
8fdee94601
commit
0751e3bb83
|
@ -242,7 +242,7 @@ impl<W: Write> Printer<W> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_code_stats<'a, 'b>(
|
fn print_code_stats(
|
||||||
&mut self,
|
&mut self,
|
||||||
language_type: LanguageType,
|
language_type: LanguageType,
|
||||||
stats: &[CodeStats],
|
stats: &[CodeStats],
|
||||||
|
@ -283,7 +283,7 @@ impl<W: Write> Printer<W> {
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
let mut subtotal = tokei::Report::new(format!("(Total)").into());
|
let mut subtotal = tokei::Report::new("(Total)".into());
|
||||||
let summary = parent.summarise();
|
let summary = parent.summarise();
|
||||||
subtotal.stats.code += summary.code;
|
subtotal.stats.code += summary.code;
|
||||||
subtotal.stats.comments += summary.comments;
|
subtotal.stats.comments += summary.comments;
|
||||||
|
@ -394,7 +394,7 @@ impl<W: Write> Printer<W> {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut subtotal = tokei::Report::new(format!("|- (Total)").into());
|
let mut subtotal = tokei::Report::new("|- (Total)".into());
|
||||||
subtotal.stats.code += report.stats.code;
|
subtotal.stats.code += report.stats.code;
|
||||||
subtotal.stats.comments += report.stats.comments;
|
subtotal.stats.comments += report.stats.comments;
|
||||||
subtotal.stats.blanks += report.stats.blanks;
|
subtotal.stats.blanks += report.stats.blanks;
|
||||||
|
|
|
@ -97,6 +97,7 @@ impl Config {
|
||||||
.and_then(Self::get_config)
|
.and_then(Self::get_config)
|
||||||
.unwrap_or_else(Self::default);
|
.unwrap_or_else(Self::default);
|
||||||
|
|
||||||
|
#[allow(clippy::or_fun_call)]
|
||||||
Config {
|
Config {
|
||||||
columns: current_dir
|
columns: current_dir
|
||||||
.columns
|
.columns
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl LanguageType {
|
||||||
// Get the position of the last line before the important
|
// Get the position of the last line before the important
|
||||||
// syntax.
|
// syntax.
|
||||||
text[..=m.start()]
|
text[..=m.start()]
|
||||||
.into_iter()
|
.iter()
|
||||||
.rev()
|
.rev()
|
||||||
.position(|&c| c == b'\n')
|
.position(|&c| c == b'\n')
|
||||||
.filter(|&p| p != 0)
|
.filter(|&p| p != 0)
|
||||||
|
|
|
@ -316,6 +316,7 @@ impl SyntaxCounter {
|
||||||
};
|
};
|
||||||
|
|
||||||
// `Some(true)` in order to respect the current configuration.
|
// `Some(true)` in order to respect the current configuration.
|
||||||
|
#[allow(clippy::if_same_then_else)]
|
||||||
if self.quote.is_some() {
|
if self.quote.is_some() {
|
||||||
if self.quote_is_doc_quote && config.treat_doc_strings_as_comments == Some(true) {
|
if self.quote_is_doc_quote && config.treat_doc_strings_as_comments == Some(true) {
|
||||||
self.quote.map_or(false, |q| line.starts_with(q.as_bytes()))
|
self.quote.map_or(false, |q| line.starts_with(q.as_bytes()))
|
||||||
|
@ -335,10 +336,8 @@ impl SyntaxCounter {
|
||||||
true
|
true
|
||||||
} else if started_in_comments {
|
} else if started_in_comments {
|
||||||
true
|
true
|
||||||
} else if (starts_with_comment)() {
|
|
||||||
true
|
|
||||||
} else {
|
} else {
|
||||||
false
|
(starts_with_comment)()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,6 +436,7 @@ impl SyntaxCounter {
|
||||||
doc_block,
|
doc_block,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
#[allow(clippy::trivial_regex)]
|
||||||
LanguageType::Html
|
LanguageType::Html
|
||||||
| LanguageType::RubyHtml
|
| LanguageType::RubyHtml
|
||||||
| LanguageType::Svelte
|
| LanguageType::Svelte
|
||||||
|
|
|
@ -103,7 +103,7 @@ pub fn get_all_files<A: AsRef<Path>>(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(types) = config.types.as_ref().map(|v| &**v) {
|
if let Some(types) = config.types.as_deref() {
|
||||||
rx_iter.filter(|(_, l)| types.contains(l)).for_each(process)
|
rx_iter.filter(|(_, l)| types.contains(l)).for_each(process)
|
||||||
} else {
|
} else {
|
||||||
rx_iter.for_each(process)
|
rx_iter.for_each(process)
|
||||||
|
|
Loading…
Reference in a new issue