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:
Sebastian Thiel 2020-12-30 16:25:07 +08:00 committed by GitHub
parent 8fdee94601
commit 0751e3bb83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 8 deletions

View file

@ -242,7 +242,7 @@ impl<W: Write> Printer<W> {
Ok(())
}
fn print_code_stats<'a, 'b>(
fn print_code_stats(
&mut self,
language_type: LanguageType,
stats: &[CodeStats],
@ -283,7 +283,7 @@ impl<W: Write> Printer<W> {
.collect::<Vec<_>>(),
)?;
}
let mut subtotal = tokei::Report::new(format!("(Total)").into());
let mut subtotal = tokei::Report::new("(Total)".into());
let summary = parent.summarise();
subtotal.stats.code += summary.code;
subtotal.stats.comments += summary.comments;
@ -394,7 +394,7 @@ impl<W: Write> Printer<W> {
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.comments += report.stats.comments;
subtotal.stats.blanks += report.stats.blanks;

View file

@ -97,6 +97,7 @@ impl Config {
.and_then(Self::get_config)
.unwrap_or_else(Self::default);
#[allow(clippy::or_fun_call)]
Config {
columns: current_dir
.columns

View file

@ -72,7 +72,7 @@ impl LanguageType {
// Get the position of the last line before the important
// syntax.
text[..=m.start()]
.into_iter()
.iter()
.rev()
.position(|&c| c == b'\n')
.filter(|&p| p != 0)

View file

@ -316,6 +316,7 @@ impl SyntaxCounter {
};
// `Some(true)` in order to respect the current configuration.
#[allow(clippy::if_same_then_else)]
if self.quote.is_some() {
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()))
@ -335,10 +336,8 @@ impl SyntaxCounter {
true
} else if started_in_comments {
true
} else if (starts_with_comment)() {
true
} else {
false
(starts_with_comment)()
}
}
@ -437,6 +436,7 @@ impl SyntaxCounter {
doc_block,
))
}
#[allow(clippy::trivial_regex)]
LanguageType::Html
| LanguageType::RubyHtml
| LanguageType::Svelte

View file

@ -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)
} else {
rx_iter.for_each(process)