diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9c8cebf3a2..35a63cedee 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -82,7 +82,7 @@ jobs: ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- ${{ runner.os }}- - - run: cargo clippy --workspace --all-targets --all-features -- -D warnings + - run: cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::pedantic cargo_test: name: "cargo test" diff --git a/benches/source_code_locator.rs b/benches/source_code_locator.rs index e2e1359e86..73811d87e6 100644 --- a/benches/source_code_locator.rs +++ b/benches/source_code_locator.rs @@ -10,7 +10,7 @@ fn criterion_benchmark(c: &mut Criterion) { b.iter(|| { let rope = Rope::from_str(black_box(&contents)); rope.line_to_char(black_box(4)); - }) + }); }); } diff --git a/flake8_to_ruff/src/converter.rs b/flake8_to_ruff/src/converter.rs index 39b9da20b2..59db74177a 100644 --- a/flake8_to_ruff/src/converter.rs +++ b/flake8_to_ruff/src/converter.rs @@ -110,7 +110,7 @@ pub fn convert( match parser::parse_files_to_codes_mapping(value.as_ref()) { Ok(per_file_ignores) => { options.per_file_ignores = - Some(parser::collect_per_file_ignores(per_file_ignores)) + Some(parser::collect_per_file_ignores(per_file_ignores)); } Err(e) => eprintln!("Unable to parse '{key}' property: {e}"), } @@ -181,7 +181,7 @@ pub fn convert( "ban-relative-imports" | "ban_relative_imports" => match value.trim() { "true" => flake8_tidy_imports.ban_relative_imports = Some(Strictness::All), "parents" => { - flake8_tidy_imports.ban_relative_imports = Some(Strictness::Parents) + flake8_tidy_imports.ban_relative_imports = Some(Strictness::Parents); } _ => eprintln!("Unexpected '{key}' value: {value}"), }, diff --git a/flake8_to_ruff/src/lib.rs b/flake8_to_ruff/src/lib.rs index 8c093722a1..a13d73a2df 100644 --- a/flake8_to_ruff/src/lib.rs +++ b/flake8_to_ruff/src/lib.rs @@ -1,4 +1,15 @@ -#![allow(clippy::collapsible_if, clippy::collapsible_else_if)] +#![allow( + clippy::collapsible_else_if, + clippy::collapsible_if, + clippy::implicit_hasher, + clippy::match_same_arms, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions, + clippy::must_use_candidate, + clippy::similar_names, + clippy::too_many_lines +)] pub mod converter; mod parser; diff --git a/flake8_to_ruff/src/main.rs b/flake8_to_ruff/src/main.rs index 879a1aabe3..0140a94b7d 100644 --- a/flake8_to_ruff/src/main.rs +++ b/flake8_to_ruff/src/main.rs @@ -1,4 +1,16 @@ //! Utility to generate Ruff's pyproject.toml section from a Flake8 INI file. +#![allow( + clippy::collapsible_else_if, + clippy::collapsible_if, + clippy::implicit_hasher, + clippy::match_same_arms, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions, + clippy::must_use_candidate, + clippy::similar_names, + clippy::too_many_lines +)] use std::path::PathBuf; diff --git a/ruff_dev/src/lib.rs b/ruff_dev/src/lib.rs index da10cfc7d0..fb2947d51d 100644 --- a/ruff_dev/src/lib.rs +++ b/ruff_dev/src/lib.rs @@ -1,3 +1,16 @@ +#![allow( + clippy::collapsible_else_if, + clippy::collapsible_if, + clippy::implicit_hasher, + clippy::match_same_arms, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions, + clippy::must_use_candidate, + clippy::similar_names, + clippy::too_many_lines +)] + pub mod generate_check_code_prefix; pub mod generate_rules_table; pub mod generate_source_code; diff --git a/ruff_dev/src/main.rs b/ruff_dev/src/main.rs index 630b0a6dd7..0304c9ec0c 100644 --- a/ruff_dev/src/main.rs +++ b/ruff_dev/src/main.rs @@ -1,3 +1,16 @@ +#![allow( + clippy::collapsible_else_if, + clippy::collapsible_if, + clippy::implicit_hasher, + clippy::match_same_arms, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions, + clippy::must_use_candidate, + clippy::similar_names, + clippy::too_many_lines +)] + use anyhow::Result; use clap::{Parser, Subcommand}; use ruff_dev::{ diff --git a/src/ast/operations.rs b/src/ast/operations.rs index 98383afd58..a6d3d4f9af 100644 --- a/src/ast/operations.rs +++ b/src/ast/operations.rs @@ -11,7 +11,7 @@ pub fn extract_all_names(stmt: &Stmt, scope: &Scope) -> Vec { .. } = &elt.node { - names.push(value.to_string()) + names.push(value.to_string()); } } } @@ -35,7 +35,7 @@ pub fn extract_all_names(stmt: &Stmt, scope: &Scope) -> Vec { } { match &value.node { ExprKind::List { elts, .. } | ExprKind::Tuple { elts, .. } => { - add_to_names(&mut names, elts) + add_to_names(&mut names, elts); } ExprKind::BinOp { left, right, .. } => { let mut current_left = left; diff --git a/src/ast/visitor.rs b/src/ast/visitor.rs index d1e480d66f..d79c4a4d70 100644 --- a/src/ast/visitor.rs +++ b/src/ast/visitor.rs @@ -249,7 +249,7 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) { visitor.visit_stmt(stmt); } for excepthandler in handlers { - visitor.visit_excepthandler(excepthandler) + visitor.visit_excepthandler(excepthandler); } for stmt in orelse { visitor.visit_stmt(stmt); @@ -447,7 +447,7 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) { pub fn walk_constant<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, constant: &'a Constant) { if let Constant::Tuple(constants) = constant { for constant in constants { - visitor.visit_constant(constant) + visitor.visit_constant(constant); } } } diff --git a/src/autofix/fixer.rs b/src/autofix/fixer.rs index b2ef8910fb..c03c5d697b 100644 --- a/src/autofix/fixer.rs +++ b/src/autofix/fixer.rs @@ -100,7 +100,6 @@ fn apply_fixes<'a>( #[cfg(test)] mod tests { - use anyhow::Result; use rustpython_parser::ast::Location; use crate::autofix::fixer::apply_fixes; @@ -108,18 +107,16 @@ mod tests { use crate::SourceCodeLocator; #[test] - fn empty_file() -> Result<()> { + fn empty_file() { let fixes = vec![]; let locator = SourceCodeLocator::new(r#""#); let (contents, fixed) = apply_fixes(fixes.iter(), &locator); assert_eq!(contents, ""); assert_eq!(fixed, 0); - - Ok(()) } #[test] - fn apply_single_replacement() -> Result<()> { + fn apply_single_replacement() { let fixes = vec![Fix { patch: Patch { content: "Bar".to_string(), @@ -144,12 +141,10 @@ class A(Bar): .trim(), ); assert_eq!(fixed, 1); - - Ok(()) } #[test] - fn apply_single_removal() -> Result<()> { + fn apply_single_removal() { let fixes = vec![Fix { patch: Patch { content: String::new(), @@ -174,12 +169,10 @@ class A: .trim() ); assert_eq!(fixed, 1); - - Ok(()) } #[test] - fn apply_double_removal() -> Result<()> { + fn apply_double_removal() { let fixes = vec![ Fix { patch: Patch { @@ -214,12 +207,10 @@ class A: .trim() ); assert_eq!(fixed, 2); - - Ok(()) } #[test] - fn ignore_overlapping_fixes() -> Result<()> { + fn ignore_overlapping_fixes() { let fixes = vec![ Fix { patch: Patch { @@ -253,7 +244,5 @@ class A: .trim(), ); assert_eq!(fixed, 1); - - Ok(()) } } diff --git a/src/cache.rs b/src/cache.rs index d4043d451e..776136a00e 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -178,6 +178,6 @@ pub fn set( cache_key(path, settings, autofix), &bincode::serialize(&check_result).unwrap(), ) { - error!("Failed to write to cache: {e:?}") + error!("Failed to write to cache: {e:?}"); } } diff --git a/src/check_ast.rs b/src/check_ast.rs index 9aef374d78..f32d8b26da 100644 --- a/src/check_ast.rs +++ b/src/check_ast.rs @@ -534,20 +534,20 @@ where self.check_builtin_shadowing(name, Range::from_located(stmt), false); for expr in bases { - self.visit_expr(expr) + self.visit_expr(expr); } for keyword in keywords { - self.visit_keyword(keyword) + self.visit_keyword(keyword); } for expr in decorator_list { - self.visit_expr(expr) + self.visit_expr(expr); } self.push_scope(Scope::new(ScopeKind::Class(ClassScope { name, bases, keywords, decorator_list, - }))) + }))); } StmtKind::Import { names } => { if self.settings.enabled.contains(&CheckCode::E402) { @@ -576,7 +576,7 @@ where used: None, range: Range::from_located(stmt), }, - ) + ); } else { if let Some(asname) = &alias.node.asname { self.check_builtin_shadowing(asname, Range::from_located(stmt), false); @@ -616,7 +616,7 @@ where }, range: Range::from_located(stmt), }, - ) + ); } if let Some(asname) = &alias.node.asname { @@ -692,7 +692,7 @@ where .iter() .filter(|alias| alias.node.asname.is_none()) .map(|alias| alias.node.name.as_str()), - ) + ); } for alias in names { if let Some(asname) = &alias.node.asname { @@ -835,7 +835,7 @@ where }, range: Range::from_located(stmt), }, - ) + ); } if self.settings.enabled.contains(&CheckCode::I252) { @@ -979,7 +979,7 @@ where StmtKind::Assign { targets, value, .. } => { if self.settings.enabled.contains(&CheckCode::E731) { if let [target] = &targets[..] { - pycodestyle::plugins::do_not_assign_lambda(self, target, value, stmt) + pycodestyle::plugins::do_not_assign_lambda(self, target, value, stmt); } } if self.settings.enabled.contains(&CheckCode::U001) { @@ -1016,7 +1016,7 @@ where StmtKind::Delete { .. } => {} StmtKind::Expr { value, .. } => { if self.settings.enabled.contains(&CheckCode::B015) { - flake8_bugbear::plugins::useless_comparison(self, value) + flake8_bugbear::plugins::useless_comparison(self, value); } } _ => {} @@ -1081,7 +1081,7 @@ where } self.except_handlers.pop(); for excepthandler in handlers { - self.visit_excepthandler(excepthandler) + self.visit_excepthandler(excepthandler); } for stmt in orelse { self.visit_stmt(stmt); @@ -1620,7 +1620,7 @@ where comparators, check_none_comparisons, check_true_false_comparisons, - ) + ); } if self.settings.enabled.contains(&CheckCode::F632) { @@ -1717,7 +1717,7 @@ where for expr in &args.defaults { self.visit_expr(expr); } - self.push_scope(Scope::new(ScopeKind::Lambda)) + self.push_scope(Scope::new(ScopeKind::Lambda)); } ExprKind::ListComp { elt, generators } | ExprKind::SetComp { elt, generators } => { if self.settings.enabled.contains(&CheckCode::C416) { @@ -1732,10 +1732,10 @@ where self.add_check(check); }; } - self.push_scope(Scope::new(ScopeKind::Generator)) + self.push_scope(Scope::new(ScopeKind::Generator)); } ExprKind::GeneratorExp { .. } | ExprKind::DictComp { .. } => { - self.push_scope(Scope::new(ScopeKind::Generator)) + self.push_scope(Scope::new(ScopeKind::Generator)); } _ => {} }; @@ -1894,7 +1894,7 @@ where error!( "Found non-ExprKind::Tuple argument to PEP 593 \ Annotation." - ) + ); } } } @@ -2014,10 +2014,10 @@ where .extend(pyflakes::checks::duplicate_arguments(arguments)); } if self.settings.enabled.contains(&CheckCode::B006) { - flake8_bugbear::plugins::mutable_argument_default(self, arguments) + flake8_bugbear::plugins::mutable_argument_default(self, arguments); } if self.settings.enabled.contains(&CheckCode::B008) { - flake8_bugbear::plugins::function_call_argument_default(self, arguments) + flake8_bugbear::plugins::function_call_argument_default(self, arguments); } // flake8-boolean-trap @@ -2310,7 +2310,7 @@ impl<'a> Checker<'a> { self.add_check(Check::new( CheckKind::UndefinedName(id.clone()), Range::from_located(expr), - )) + )); } } } @@ -2339,20 +2339,22 @@ impl<'a> Checker<'a> { .get(id) .map_or(false, |binding| matches!(binding.kind, BindingKind::Global)) { - pep8_naming::plugins::non_lowercase_variable_in_function(self, expr, parent, id) + pep8_naming::plugins::non_lowercase_variable_in_function( + self, expr, parent, id, + ); } } } if self.settings.enabled.contains(&CheckCode::N815) { if matches!(self.current_scope().kind, ScopeKind::Class(..)) { - pep8_naming::plugins::mixed_case_variable_in_class_scope(self, expr, parent, id) + pep8_naming::plugins::mixed_case_variable_in_class_scope(self, expr, parent, id); } } if self.settings.enabled.contains(&CheckCode::N816) { if matches!(self.current_scope().kind, ScopeKind::Module) { - pep8_naming::plugins::mixed_case_variable_in_global_scope(self, expr, parent, id) + pep8_naming::plugins::mixed_case_variable_in_global_scope(self, expr, parent, id); } } @@ -2448,7 +2450,7 @@ impl<'a> Checker<'a> { self.add_check(Check::new( CheckKind::UndefinedName(id.to_string()), Range::from_located(expr), - )) + )); } } } diff --git a/src/check_lines.rs b/src/check_lines.rs index 6e2aff3809..f135fe80ae 100644 --- a/src/check_lines.rs +++ b/src/check_lines.rs @@ -101,7 +101,7 @@ pub fn check_lines( match noqa { (Directive::All(..), matches) => { matches.push(check.kind.code().as_ref()); - ignored.push(index) + ignored.push(index); } (Directive::Codes(.., codes), matches) => { if codes.contains(&check.kind.code().as_ref()) { diff --git a/src/checks.rs b/src/checks.rs index c58876ab39..ee426e718c 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -2155,13 +2155,12 @@ impl Check { mod tests { use std::str::FromStr; - use anyhow::Result; use strum::IntoEnumIterator; use crate::checks::CheckCode; #[test] - fn check_code_serialization() -> Result<()> { + fn check_code_serialization() { for check_code in CheckCode::iter() { assert!( CheckCode::from_str(check_code.as_ref()).is_ok(), @@ -2169,6 +2168,5 @@ mod tests { check_code ); } - Ok(()) } } diff --git a/src/code_gen.rs b/src/code_gen.rs index 86ce334dfb..87d3728838 100644 --- a/src/code_gen.rs +++ b/src/code_gen.rs @@ -254,7 +254,7 @@ impl SourceGenerator { }); self.p("= "); self.unparse_expr(value, precedence::EXPR); - }) + }); } StmtKind::AnnAssign { target, @@ -273,7 +273,7 @@ impl SourceGenerator { self.p(" = "); self.unparse_expr(value, precedence::EXPR); } - }) + }); } StmtKind::For { target, @@ -440,7 +440,7 @@ impl SourceGenerator { self.p(", "); self.unparse_expr(msg, precedence::TEST); } - }) + }); } StmtKind::Import { names } => { statement!({ @@ -471,7 +471,7 @@ impl SourceGenerator { self.p_delim(&mut first, ", "); self.unparse_alias(alias); } - }) + }); } StmtKind::Global { names } => { statement!({ @@ -566,14 +566,14 @@ impl SourceGenerator { self.p_delim(&mut first, op); self.unparse_expr(val, prec + 1); } - }) + }); } ExprKind::NamedExpr { target, value } => { group_if!(precedence::TUPLE, { self.unparse_expr(target, precedence::ATOM); self.p(" := "); self.unparse_expr(value, precedence::ATOM); - }) + }); } ExprKind::BinOp { left, op, right } => { let rassoc = matches!(op, Operator::Pow); @@ -599,7 +599,7 @@ impl SourceGenerator { self.unparse_expr(left, prec + u8::from(rassoc)); self.p(op); self.unparse_expr(right, prec + u8::from(!rassoc)); - }) + }); } ExprKind::UnaryOp { op, operand } => { let (op, prec) = opprec!( @@ -614,7 +614,7 @@ impl SourceGenerator { group_if!(prec, { self.p(op); self.unparse_expr(operand, prec); - }) + }); } ExprKind::Lambda { args, body } => { group_if!(precedence::TEST, { @@ -622,7 +622,7 @@ impl SourceGenerator { self.p(if npos > 0 { "lambda " } else { "lambda" }); self.unparse_args(args); write!(self, ": {}", **body); - }) + }); } ExprKind::IfExp { test, body, orelse } => { group_if!(precedence::TEST, { @@ -631,7 +631,7 @@ impl SourceGenerator { self.unparse_expr(test, precedence::TEST + 1); self.p(" else "); self.unparse_expr(orelse, precedence::TEST); - }) + }); } ExprKind::Dict { keys, values } => { self.p("{"); @@ -694,7 +694,7 @@ impl SourceGenerator { group_if!(precedence::AWAIT, { self.p("await "); self.unparse_expr(value, precedence::ATOM); - }) + }); } ExprKind::Yield { value } => { if let Some(value) = value { @@ -730,7 +730,7 @@ impl SourceGenerator { self.p(op); self.unparse_expr(cmp, new_lvl); } - }) + }); } ExprKind::Call { func, @@ -813,7 +813,7 @@ impl SourceGenerator { .iter() .any(|expr| matches!(expr.node, ExprKind::Starred { .. })) { - lvl += 1 + lvl += 1; } } self.p("["); @@ -845,7 +845,7 @@ impl SourceGenerator { self.unparse_expr(elt, precedence::TEST); } self.p_if(elts.len() == 1, ","); - }) + }); } } ExprKind::Slice { lower, upper, step } => { @@ -962,7 +962,7 @@ impl SourceGenerator { match &expr.node { ExprKind::Constant { value, .. } => { if let Constant::Str(s) = value { - self.unparse_fstring_str(s) + self.unparse_fstring_str(s); } else { unreachable!() } diff --git a/src/directives.rs b/src/directives.rs index 90e11fcdf1..087f997807 100644 --- a/src/directives.rs +++ b/src/directives.rs @@ -113,6 +113,7 @@ pub fn extract_isort_exclusions(lxr: &[LexResult], locator: &SourceCodeLocator) #[cfg(test)] mod tests { + use nohash_hasher::IntMap; use rustpython_parser::lexer; use rustpython_parser::lexer::LexResult; diff --git a/src/flake8_bugbear/plugins/duplicate_exceptions.rs b/src/flake8_bugbear/plugins/duplicate_exceptions.rs index 9877f517f2..1e960a0af0 100644 --- a/src/flake8_bugbear/plugins/duplicate_exceptions.rs +++ b/src/flake8_bugbear/plugins/duplicate_exceptions.rs @@ -65,7 +65,7 @@ fn duplicate_handler_exceptions<'a>( content, expr.location, expr.end_location.unwrap(), - )) + )); } } checker.add_check(check); diff --git a/src/flake8_bugbear/plugins/function_call_argument_default.rs b/src/flake8_bugbear/plugins/function_call_argument_default.rs index 9bbe585665..39ff078e33 100644 --- a/src/flake8_bugbear/plugins/function_call_argument_default.rs +++ b/src/flake8_bugbear/plugins/function_call_argument_default.rs @@ -60,9 +60,9 @@ where self.checks.push(( CheckKind::FunctionCallArgumentDefault(compose_call_path(expr)), Range::from_located(expr), - )) + )); } - visitor::walk_expr(self, expr) + visitor::walk_expr(self, expr); } ExprKind::Lambda { .. } => {} _ => visitor::walk_expr(self, expr), diff --git a/src/flake8_bugbear/plugins/redundant_tuple_in_exception_handler.rs b/src/flake8_bugbear/plugins/redundant_tuple_in_exception_handler.rs index 5105169bac..735eb0274f 100644 --- a/src/flake8_bugbear/plugins/redundant_tuple_in_exception_handler.rs +++ b/src/flake8_bugbear/plugins/redundant_tuple_in_exception_handler.rs @@ -78,7 +78,7 @@ pub fn redundant_tuple_in_exception_handler(checker: &mut Checker, handlers: &[E } } } - checker.add_check(check) + checker.add_check(check); } } } diff --git a/src/flake8_bugbear/plugins/setattr_with_constant.rs b/src/flake8_bugbear/plugins/setattr_with_constant.rs index 24226368bc..bb7210da63 100644 --- a/src/flake8_bugbear/plugins/setattr_with_constant.rs +++ b/src/flake8_bugbear/plugins/setattr_with_constant.rs @@ -30,7 +30,7 @@ fn assignment(obj: &Expr, name: &str, value: &Expr) -> Result { ); let mut generator = SourceGenerator::new(); generator.unparse_stmt(&stmt); - generator.generate().map_err(|e| e.into()) + generator.generate().map_err(std::convert::Into::into) } /// B010 diff --git a/src/flake8_bugbear/plugins/unary_prefix_increment.rs b/src/flake8_bugbear/plugins/unary_prefix_increment.rs index 16e22a1cfe..d942db2414 100644 --- a/src/flake8_bugbear/plugins/unary_prefix_increment.rs +++ b/src/flake8_bugbear/plugins/unary_prefix_increment.rs @@ -12,7 +12,7 @@ pub fn unary_prefix_increment(checker: &mut Checker, expr: &Expr, op: &Unaryop, checker.add_check(Check::new( CheckKind::UnaryPrefixIncrement, Range::from_located(expr), - )) + )); } } } diff --git a/src/flake8_bugbear/plugins/unused_loop_control_variable.rs b/src/flake8_bugbear/plugins/unused_loop_control_variable.rs index 759c1dc40f..8afb98c387 100644 --- a/src/flake8_bugbear/plugins/unused_loop_control_variable.rs +++ b/src/flake8_bugbear/plugins/unused_loop_control_variable.rs @@ -71,7 +71,7 @@ pub fn unused_loop_control_variable(checker: &mut Checker, target: &Expr, body: format!("_{name}"), expr.location, expr.end_location.unwrap(), - )) + )); } checker.add_check(check); } diff --git a/src/flake8_comprehensions/fixes.rs b/src/flake8_comprehensions/fixes.rs index fdf199a18f..499d0bde75 100644 --- a/src/flake8_comprehensions/fixes.rs +++ b/src/flake8_comprehensions/fixes.rs @@ -722,7 +722,7 @@ pub fn fix_unnecessary_call_around_sorted( rpar: inner_call.rpar.clone(), whitespace_after_func: inner_call.whitespace_after_func.clone(), whitespace_before_args: inner_call.whitespace_before_args.clone(), - })) + })); } } @@ -766,7 +766,7 @@ pub fn fix_unnecessary_comprehension( rpar: vec![], whitespace_after_func: ParenthesizableWhitespace::default(), whitespace_before_args: ParenthesizableWhitespace::default(), - })) + })); } Expression::SetComp(inner) => { body.value = Expression::Call(Box::new(Call { @@ -788,7 +788,7 @@ pub fn fix_unnecessary_comprehension( rpar: vec![], whitespace_after_func: ParenthesizableWhitespace::default(), whitespace_before_args: ParenthesizableWhitespace::default(), - })) + })); } _ => { return Err(anyhow::anyhow!( diff --git a/src/flake8_print/plugins/print_call.rs b/src/flake8_print/plugins/print_call.rs index e9f9cbda39..f32f18c2e1 100644 --- a/src/flake8_print/plugins/print_call.rs +++ b/src/flake8_print/plugins/print_call.rs @@ -35,7 +35,7 @@ pub fn print_call(checker: &mut Checker, expr: &Expr, func: &Expr) { if fix.patch.content.is_empty() || fix.patch.content == "pass" { checker.deletions.insert(context.defined_by); } - check.amend(fix) + check.amend(fix); } Err(e) => error!("Failed to remove print call: {}", e), } diff --git a/src/isort/mod.rs b/src/isort/mod.rs index b363382a17..d55ccc49a0 100644 --- a/src/isort/mod.rs +++ b/src/isort/mod.rs @@ -128,7 +128,7 @@ fn annotate_imports<'a>( asname: alias.node.asname.as_ref(), atop: alias_atop, inline: alias_inline, - }) + }); } annotated.push(AnnotatedImport::ImportFrom { diff --git a/src/isort/track.rs b/src/isort/track.rs index a815becde7..d68c2d0395 100644 --- a/src/isort/track.rs +++ b/src/isort/track.rs @@ -142,7 +142,7 @@ where finalbody, } => { for excepthandler in handlers { - self.visit_excepthandler(excepthandler) + self.visit_excepthandler(excepthandler); } for stmt in body { diff --git a/src/lib.rs b/src/lib.rs index 7cf1aeba06..5a1e76dbf8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,15 @@ -#![allow(clippy::collapsible_if, clippy::collapsible_else_if)] +#![allow( + clippy::collapsible_else_if, + clippy::collapsible_if, + clippy::implicit_hasher, + clippy::match_same_arms, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions, + clippy::must_use_candidate, + clippy::similar_names, + clippy::too_many_lines +)] use std::path::Path; diff --git a/src/linter.rs b/src/linter.rs index 268b379732..b3d7f3c171 100644 --- a/src/linter.rs +++ b/src/linter.rs @@ -100,7 +100,7 @@ pub(crate) fn check_path( location: parse_error.location, end_location: parse_error.location, }, - )) + )); } } } diff --git a/src/logging.rs b/src/logging.rs index 48c714d0da..52fb7411ec 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -53,7 +53,7 @@ pub fn set_up_logging(level: &LogLevel) -> Result<()> { record.target(), record.level(), message - )) + )); }) .level(level.level_filter()) .chain(std::io::stdout()) diff --git a/src/main.rs b/src/main.rs index dbac2bed81..49c35a9fa3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,16 @@ +#![allow( + clippy::collapsible_else_if, + clippy::collapsible_if, + clippy::implicit_hasher, + clippy::match_same_arms, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions, + clippy::must_use_candidate, + clippy::similar_names, + clippy::too_many_lines +)] + use std::io::{self, Read}; use std::path::{Path, PathBuf}; use std::process::ExitCode; diff --git a/src/noqa.rs b/src/noqa.rs index c8b4eda218..e8558ecc19 100644 --- a/src/noqa.rs +++ b/src/noqa.rs @@ -120,6 +120,7 @@ fn add_noqa_inner( #[cfg(test)] mod tests { + use nohash_hasher::IntMap; use rustpython_parser::ast::Location; diff --git a/src/printer.rs b/src/printer.rs index 54c76f3296..ea80bc3a8d 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -70,7 +70,7 @@ impl<'a> Printer<'a> { }) .collect::>() )? - ) + ); } SerializationFormat::Text => { if self.log_level >= &LogLevel::Default { @@ -79,19 +79,19 @@ impl<'a> Printer<'a> { "Found {} error(s) ({} fixed).", diagnostics.messages.len(), diagnostics.fixed, - ) + ); } else if !diagnostics.messages.is_empty() { - println!("Found {} error(s).", diagnostics.messages.len()) + println!("Found {} error(s).", diagnostics.messages.len()); } } for message in &diagnostics.messages { - println!("{message}") + println!("{message}"); } if self.log_level >= &LogLevel::Default { if num_fixable > 0 { - println!("{num_fixable} potentially fixable with the --fix option.") + println!("{num_fixable} potentially fixable with the --fix option."); } } } @@ -117,7 +117,7 @@ impl<'a> Printer<'a> { println!(); } for message in &diagnostics.messages { - println!("{message}") + println!("{message}"); } } diff --git a/src/pycodestyle/checks.rs b/src/pycodestyle/checks.rs index 31bc6c2c0f..8d7b040bfd 100644 --- a/src/pycodestyle/checks.rs +++ b/src/pycodestyle/checks.rs @@ -157,7 +157,7 @@ pub fn invalid_escape_sequence( location, end_location, }, - )) + )); } } } diff --git a/src/pydocstyle/plugins.rs b/src/pydocstyle/plugins.rs index 4f0932799c..630f61416b 100644 --- a/src/pydocstyle/plugins.rs +++ b/src/pydocstyle/plugins.rs @@ -1190,7 +1190,7 @@ fn common_section( docstring.location.row() + context.original_index, section_name_start + section_name_length, ), - )) + )); } } checker.add_check(check); @@ -1284,7 +1284,7 @@ fn common_section( Location::new(docstring.location.row() + context.original_index, 0), )); } - checker.add_check(check) + checker.add_check(check); } } @@ -1388,7 +1388,7 @@ fn args_section(checker: &mut Checker, definition: &Definition, context: &Sectio }, ) .collect(), - ) + ); } fn parameters_section(checker: &mut Checker, definition: &Definition, context: &SectionContext) { @@ -1458,7 +1458,7 @@ fn numpy_section(checker: &mut Checker, definition: &Definition, context: &Secti )); } } - checker.add_check(check) + checker.add_check(check); } } diff --git a/src/pyflakes/checks.rs b/src/pyflakes/checks.rs index 9df447b809..7dcea16ce9 100644 --- a/src/pyflakes/checks.rs +++ b/src/pyflakes/checks.rs @@ -164,7 +164,7 @@ pub fn repeated_keys( checks.push(Check::new( CheckKind::MultiValueRepeatedKeyLiteral, Range::from_located(k2), - )) + )); } } (Some(DictionaryKey::Variable(v1)), Some(DictionaryKey::Variable(v2))) => { @@ -172,7 +172,7 @@ pub fn repeated_keys( checks.push(Check::new( CheckKind::MultiValueRepeatedKeyVariable((*v2).to_string()), Range::from_located(k2), - )) + )); } } _ => {} diff --git a/src/pyflakes/plugins/raise_not_implemented.rs b/src/pyflakes/plugins/raise_not_implemented.rs index c367f307c8..f9db1a98b3 100644 --- a/src/pyflakes/plugins/raise_not_implemented.rs +++ b/src/pyflakes/plugins/raise_not_implemented.rs @@ -33,7 +33,7 @@ pub fn raise_not_implemented(checker: &mut Checker, expr: &Expr) { "NotImplementedError".to_string(), expr.location, expr.end_location.unwrap(), - )) + )); } checker.add_check(check); } diff --git a/src/pyupgrade/plugins/redundant_open_modes.rs b/src/pyupgrade/plugins/redundant_open_modes.rs index 7e4f3a809f..f5d95391cd 100644 --- a/src/pyupgrade/plugins/redundant_open_modes.rs +++ b/src/pyupgrade/plugins/redundant_open_modes.rs @@ -81,7 +81,7 @@ fn create_check( content, mode_param.location, mode_param.end_location.unwrap(), - )) + )); } else { match create_remove_param_fix(locator, expr, mode_param) { Ok(fix) => check.amend(fix), diff --git a/src/pyupgrade/plugins/super_call_with_parameters.rs b/src/pyupgrade/plugins/super_call_with_parameters.rs index c6490d3104..6990b3ad42 100644 --- a/src/pyupgrade/plugins/super_call_with_parameters.rs +++ b/src/pyupgrade/plugins/super_call_with_parameters.rs @@ -22,7 +22,7 @@ pub fn super_call_with_parameters(checker: &mut Checker, expr: &Expr, func: &Exp check.amend(fix); } } - checker.add_check(check) + checker.add_check(check); } } } diff --git a/src/pyupgrade/plugins/unnecessary_encode_utf8.rs b/src/pyupgrade/plugins/unnecessary_encode_utf8.rs index cd1e6f57c1..77aa65ed83 100644 --- a/src/pyupgrade/plugins/unnecessary_encode_utf8.rs +++ b/src/pyupgrade/plugins/unnecessary_encode_utf8.rs @@ -96,7 +96,7 @@ fn replace_with_bytes_literal( content, expr.location, expr.end_location.unwrap(), - )) + )); } check } diff --git a/src/pyupgrade/plugins/use_pep604_annotation.rs b/src/pyupgrade/plugins/use_pep604_annotation.rs index 0ac82e40e0..2eea07c0dc 100644 --- a/src/pyupgrade/plugins/use_pep604_annotation.rs +++ b/src/pyupgrade/plugins/use_pep604_annotation.rs @@ -72,7 +72,7 @@ pub fn use_pep604_annotation(checker: &mut Checker, expr: &Expr, value: &Expr, s content, expr.location, expr.end_location.unwrap(), - )) + )); } } checker.add_check(check); @@ -91,7 +91,7 @@ pub fn use_pep604_annotation(checker: &mut Checker, expr: &Expr, value: &Expr, s content, expr.location, expr.end_location.unwrap(), - )) + )); } } _ => { diff --git a/src/pyupgrade/plugins/useless_metaclass_type.rs b/src/pyupgrade/plugins/useless_metaclass_type.rs index b751a78c95..121b30a4dd 100644 --- a/src/pyupgrade/plugins/useless_metaclass_type.rs +++ b/src/pyupgrade/plugins/useless_metaclass_type.rs @@ -28,7 +28,7 @@ pub fn useless_metaclass_type(checker: &mut Checker, stmt: &Stmt, value: &Expr, if fix.patch.content.is_empty() || fix.patch.content == "pass" { checker.deletions.insert(context.defined_by); } - check.amend(fix) + check.amend(fix); } Err(e) => error!("Failed to fix remove metaclass type: {}", e), } diff --git a/src/rules/plugins/convert_exit_to_sys_exit.rs b/src/rules/plugins/convert_exit_to_sys_exit.rs index 173d22a8b7..e8c6d8f8c5 100644 --- a/src/rules/plugins/convert_exit_to_sys_exit.rs +++ b/src/rules/plugins/convert_exit_to_sys_exit.rs @@ -82,7 +82,7 @@ pub fn convert_exit_to_sys_exit(checker: &mut Checker, func: &Expr) { content, func.location, func.end_location.unwrap(), - )) + )); } } checker.add_check(check);