mirror of
https://github.com/oppiliappan/statix.git
synced 2024-09-11 09:15:45 +03:00
apply clippy lints
This commit is contained in:
parent
90ea9335b5
commit
831bd7e91d
@ -154,7 +154,7 @@ mod dirs {
|
||||
}
|
||||
|
||||
fn parse_line_col(src: &str) -> Result<(usize, usize), ConfigErr> {
|
||||
let parts = src.split(",");
|
||||
let parts = src.split(',');
|
||||
match parts.collect::<Vec<_>>().as_slice() {
|
||||
[line, col] => {
|
||||
let l = line
|
||||
@ -173,7 +173,7 @@ fn parse_warning_code(src: &str) -> Result<u32, ConfigErr> {
|
||||
let mut char_stream = src.chars();
|
||||
let severity = char_stream
|
||||
.next()
|
||||
.ok_or(ConfigErr::InvalidWarningCode(src.to_owned()))?
|
||||
.ok_or_else(|| ConfigErr::InvalidWarningCode(src.to_owned()))?
|
||||
.to_ascii_lowercase();
|
||||
match severity {
|
||||
'w' => char_stream
|
||||
@ -187,7 +187,7 @@ fn parse_warning_code(src: &str) -> Result<u32, ConfigErr> {
|
||||
fn build_ignore_set(ignores: &[String]) -> Result<GlobSet, GlobError> {
|
||||
let mut set = GlobSetBuilder::new();
|
||||
for pattern in ignores {
|
||||
let glob = GlobBuilder::new(&pattern).build()?;
|
||||
let glob = GlobBuilder::new(pattern).build()?;
|
||||
set.add(glob);
|
||||
}
|
||||
set.build()
|
||||
|
@ -40,8 +40,7 @@ fn find(offset: TextSize, src: &str) -> Result<Report, SingleFixErr> {
|
||||
rules
|
||||
.iter()
|
||||
.filter_map(|rule| rule.validate(&child))
|
||||
.filter(|report| report.total_suggestion_range().is_some())
|
||||
.next()
|
||||
.find(|report| report.total_suggestion_range().is_some())
|
||||
}),
|
||||
_ => None,
|
||||
})
|
||||
|
@ -16,7 +16,7 @@ pub fn lint(vfs_entry: VfsEntry) -> LintResult {
|
||||
let error_reports = parsed
|
||||
.errors()
|
||||
.into_iter()
|
||||
.map(|e| Report::from_parse_err(e));
|
||||
.map(Report::from_parse_err);
|
||||
|
||||
let reports = parsed
|
||||
.node()
|
||||
|
@ -71,7 +71,7 @@ fn _main() -> Result<(), StatixErr> {
|
||||
let single_fix_result = fix::single(line, col, &src)?;
|
||||
if single_config.diff_only {
|
||||
let text_diff = TextDiff::from_lines(src.as_str(), &single_fix_result.src);
|
||||
let old_file = format!("{}", path_id);
|
||||
let old_file = path_id.to_string();
|
||||
let new_file = format!("{} [fixed]", path_id);
|
||||
println!(
|
||||
"{}",
|
||||
@ -96,8 +96,7 @@ fn _main() -> Result<(), StatixErr> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
match _main() {
|
||||
Err(e) => eprintln!("{}", e),
|
||||
_ => (),
|
||||
if let Err(e) = _main() {
|
||||
eprintln!("{}", e);
|
||||
}
|
||||
}
|
||||
|
@ -101,8 +101,8 @@ fn write_errfmt<T: Write>(
|
||||
let path = vfs.file_path(file_id);
|
||||
for report in lint_result.reports.iter() {
|
||||
for diagnostic in report.diagnostics.iter() {
|
||||
let line = line(diagnostic.at.start(), &src);
|
||||
let col = column(diagnostic.at.start(), &src);
|
||||
let line = line(diagnostic.at.start(), src);
|
||||
let col = column(diagnostic.at.start(), src);
|
||||
writeln!(
|
||||
writer,
|
||||
"{filename}>{linenumber}:{columnnumber}:{errortype}:{errornumber}:{errormessage}",
|
||||
@ -131,7 +131,6 @@ mod json {
|
||||
use lib::Severity;
|
||||
use rnix::TextRange;
|
||||
use serde::Serialize;
|
||||
use serde_json;
|
||||
use vfs::ReadOnlyVfs;
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -67,7 +67,7 @@ impl Rule for EtaReduction {
|
||||
let message =
|
||||
format!(
|
||||
"Found eta-reduction: `{}`",
|
||||
replacement.text().to_string()
|
||||
replacement.text()
|
||||
);
|
||||
Some(self.report().suggest(at, message, Suggestion::new(at, replacement)))
|
||||
} else {
|
||||
@ -81,6 +81,6 @@ fn mentions_ident(ident: &Ident, node: &SyntaxNode) -> bool {
|
||||
if let Some(node_ident) = Ident::cast(node.clone()) {
|
||||
node_ident.as_str() == ident.as_str()
|
||||
} else {
|
||||
node.children().any(|child| mentions_ident(&ident, &child))
|
||||
node.children().any(|child| mentions_ident(ident, &child))
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ impl Rule for UnquotedSplice {
|
||||
if Dynamic::cast(node.clone()).is_some();
|
||||
then {
|
||||
let at = node.text_range();
|
||||
let replacement = make::quote(&node).node().clone();
|
||||
let replacement = make::quote(node).node().clone();
|
||||
let message = "Consider quoting this splice expression";
|
||||
Some(self.report().suggest(at, message, Suggestion::new(at, replacement)))
|
||||
} else {
|
||||
|
@ -156,7 +156,7 @@ impl<'μ> LintMeta<'μ> {
|
||||
}
|
||||
|
||||
pub fn generate_meta_impl(struct_name: &Ident, meta: &RawLintMeta) -> TokenStream2 {
|
||||
let not_raw = LintMeta::from_raw(&meta);
|
||||
let not_raw = LintMeta::from_raw(meta);
|
||||
let name_fn = not_raw.generate_name_fn();
|
||||
let note_fn = not_raw.generate_note_fn();
|
||||
let code_fn = not_raw.generate_code_fn();
|
||||
|
Loading…
Reference in New Issue
Block a user