diff --git a/src/ast.rs b/src/ast.rs index eca70375f2..d0fc905411 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -1,4 +1,4 @@ -pub mod checks; +pub mod checkers; pub mod helpers; pub mod operations; pub mod relocate; diff --git a/src/ast/checks.rs b/src/ast/checkers.rs similarity index 95% rename from src/ast/checks.rs rename to src/ast/checkers.rs index 6bfc2997c5..b8114f51cb 100644 --- a/src/ast/checks.rs +++ b/src/ast/checkers.rs @@ -17,7 +17,7 @@ use crate::checks::{Check, CheckKind, RejectedCmpop}; use crate::python::builtins::BUILTINS; /// Check IfTuple compliance. -pub fn check_if_tuple(test: &Expr, location: Range) -> Option { +pub fn if_tuple(test: &Expr, location: Range) -> Option { if let ExprKind::Tuple { elts, .. } = &test.node { if !elts.is_empty() { return Some(Check::new(CheckKind::IfTuple, location)); @@ -27,7 +27,7 @@ pub fn check_if_tuple(test: &Expr, location: Range) -> Option { } /// Check AssertTuple compliance. -pub fn check_assert_tuple(test: &Expr, location: Range) -> Option { +pub fn assert_tuple(test: &Expr, location: Range) -> Option { if let ExprKind::Tuple { elts, .. } = &test.node { if !elts.is_empty() { return Some(Check::new(CheckKind::AssertTuple, location)); @@ -37,7 +37,7 @@ pub fn check_assert_tuple(test: &Expr, location: Range) -> Option { } /// Check NotInTest and NotIsTest compliance. -pub fn check_not_tests( +pub fn not_tests( op: &Unaryop, operand: &Expr, check_not_in: bool, @@ -76,7 +76,7 @@ pub fn check_not_tests( } /// Check UnusedVariable compliance. -pub fn check_unused_variables( +pub fn unused_variables( scope: &Scope, locator: &dyn CheckLocator, dummy_variable_rgx: &Regex, @@ -109,7 +109,7 @@ pub fn check_unused_variables( } /// Check DoNotAssignLambda compliance. -pub fn check_do_not_assign_lambda(value: &Expr, location: Range) -> Option { +pub fn do_not_assign_lambda(value: &Expr, location: Range) -> Option { if let ExprKind::Lambda { .. } = &value.node { Some(Check::new(CheckKind::DoNotAssignLambda, location)) } else { @@ -118,11 +118,7 @@ pub fn check_do_not_assign_lambda(value: &Expr, location: Range) -> Option, - value: &Expr, - location: Range, -) -> Option { +pub fn useless_metaclass_type(targets: &Vec, value: &Expr, location: Range) -> Option { if targets.len() == 1 { if let ExprKind::Name { id, .. } = targets.first().map(|expr| &expr.node).unwrap() { if id == "__metaclass__" { @@ -138,7 +134,7 @@ pub fn check_useless_metaclass_type( } /// Check UnnecessaryAbspath compliance. -pub fn check_unnecessary_abspath(func: &Expr, args: &Vec, location: Range) -> Option { +pub fn unnecessary_abspath(func: &Expr, args: &Vec, location: Range) -> Option { // Validate the arguments. if args.len() == 1 { if let ExprKind::Name { id, .. } = &args[0].node { @@ -194,7 +190,7 @@ impl Primitive { } /// Check TypeOfPrimitive compliance. -pub fn check_type_of_primitive(func: &Expr, args: &Vec, location: Range) -> Option { +pub fn type_of_primitive(func: &Expr, args: &Vec, location: Range) -> Option { // Validate the arguments. if args.len() == 1 { match &func.node { @@ -222,7 +218,7 @@ fn is_ambiguous_name(name: &str) -> bool { } /// Check AmbiguousVariableName compliance. -pub fn check_ambiguous_variable_name(name: &str, location: Range) -> Option { +pub fn ambiguous_variable_name(name: &str, location: Range) -> Option { if is_ambiguous_name(name) { Some(Check::new( CheckKind::AmbiguousVariableName(name.to_string()), @@ -234,7 +230,7 @@ pub fn check_ambiguous_variable_name(name: &str, location: Range) -> Option Option { +pub fn ambiguous_class_name(name: &str, location: Range) -> Option { if is_ambiguous_name(name) { Some(Check::new( CheckKind::AmbiguousClassName(name.to_string()), @@ -246,7 +242,7 @@ pub fn check_ambiguous_class_name(name: &str, location: Range) -> Option } /// Check AmbiguousFunctionName compliance. -pub fn check_ambiguous_function_name(name: &str, location: Range) -> Option { +pub fn ambiguous_function_name(name: &str, location: Range) -> Option { if is_ambiguous_name(name) { Some(Check::new( CheckKind::AmbiguousFunctionName(name.to_string()), @@ -258,11 +254,7 @@ pub fn check_ambiguous_function_name(name: &str, location: Range) -> Option Option { +pub fn useless_object_inheritance(name: &str, bases: &[Expr], scope: &Scope) -> Option { for expr in bases { if let ExprKind::Name { id, .. } = &expr.node { if id == "object" { @@ -287,7 +279,7 @@ pub fn check_useless_object_inheritance( } /// Check DefaultExceptNotLast compliance. -pub fn check_default_except_not_last(handlers: &Vec) -> Option { +pub fn default_except_not_last(handlers: &Vec) -> Option { for (idx, handler) in handlers.iter().enumerate() { let ExcepthandlerKind::ExceptHandler { type_, .. } = &handler.node; if type_.is_none() && idx < handlers.len() - 1 { @@ -302,7 +294,7 @@ pub fn check_default_except_not_last(handlers: &Vec) -> Option Option { +pub fn raise_not_implemented(expr: &Expr) -> Option { match &expr.node { ExprKind::Call { func, .. } => { if let ExprKind::Name { id, .. } = &func.node { @@ -329,7 +321,7 @@ pub fn check_raise_not_implemented(expr: &Expr) -> Option { } /// Check DuplicateArgumentName compliance. -pub fn check_duplicate_arguments(arguments: &Arguments) -> Vec { +pub fn duplicate_arguments(arguments: &Arguments) -> Vec { let mut checks: Vec = vec![]; // Collect all the arguments into a single vector. @@ -377,7 +369,7 @@ fn convert_to_value(expr: &Expr) -> Option { } /// Check MultiValueRepeatedKeyLiteral and MultiValueRepeatedKeyVariable compliance. -pub fn check_repeated_keys( +pub fn repeated_keys( keys: &Vec, check_repeated_literals: bool, check_repeated_variables: bool, @@ -417,7 +409,7 @@ pub fn check_repeated_keys( } /// Check TrueFalseComparison and NoneComparison compliance. -pub fn check_literal_comparisons( +pub fn literal_comparisons( left: &Expr, ops: &Vec, comparators: &Vec, @@ -548,7 +540,7 @@ fn is_constant_non_singleton(expr: &Expr) -> bool { } /// Check IsLiteral compliance. -pub fn check_is_literal( +pub fn is_literal( left: &Expr, ops: &Vec, comparators: &Vec, @@ -570,11 +562,7 @@ pub fn check_is_literal( } /// Check TypeComparison compliance. -pub fn check_type_comparison( - ops: &Vec, - comparators: &Vec, - location: Range, -) -> Vec { +pub fn type_comparison(ops: &Vec, comparators: &Vec, location: Range) -> Vec { let mut checks: Vec = vec![]; for (op, right) in izip!(ops, comparators) { @@ -610,7 +598,7 @@ pub fn check_type_comparison( } /// Check TwoStarredExpressions and TooManyExpressionsInStarredAssignment compliance. -pub fn check_starred_expressions( +pub fn starred_expressions( elts: &[Expr], check_too_many_expressions: bool, check_two_starred_expressions: bool, @@ -640,7 +628,7 @@ pub fn check_starred_expressions( } /// Check BreakOutsideLoop compliance. -pub fn check_break_outside_loop( +pub fn break_outside_loop( stmt: &Stmt, parents: &[&Stmt], parent_stack: &[usize], @@ -681,7 +669,7 @@ pub fn check_break_outside_loop( } /// Check ContinueOutsideLoop compliance. -pub fn check_continue_outside_loop( +pub fn continue_outside_loop( stmt: &Stmt, parents: &[&Stmt], parent_stack: &[usize], @@ -729,11 +717,7 @@ pub enum ShadowingType { } /// Check builtin name shadowing -pub fn check_builtin_shadowing( - name: &str, - location: Range, - node_type: ShadowingType, -) -> Option { +pub fn builtin_shadowing(name: &str, location: Range, node_type: ShadowingType) -> Option { if BUILTINS.contains(&name) { Some(Check::new( match node_type { @@ -1060,7 +1044,7 @@ pub fn unnecessary_subscript_reversal(expr: &Expr, func: &Expr, args: &[Expr]) - // flake8-super /// Check that `super()` has no args -pub fn check_super_args( +pub fn super_args( scope: &Scope, parents: &[&Stmt], expr: &Expr, @@ -1126,7 +1110,7 @@ pub fn check_super_args( // flake8-print /// Check whether a function call is a `print` or `pprint` invocation -pub fn check_print_call( +pub fn print_call( expr: &Expr, func: &Expr, check_print: bool, diff --git a/src/ast/visitor.rs b/src/ast/visitor.rs index 911e55a43a..ae73e30e82 100644 --- a/src/ast/visitor.rs +++ b/src/ast/visitor.rs @@ -1,10 +1,11 @@ -use crate::ast::helpers::match_name_or_attr; use rustpython_parser::ast::{ Alias, Arg, Arguments, Boolop, Cmpop, Comprehension, Constant, Excepthandler, ExcepthandlerKind, Expr, ExprContext, ExprKind, Keyword, MatchCase, Operator, Pattern, PatternKind, Stmt, StmtKind, Unaryop, Withitem, }; +use crate::ast::helpers::match_name_or_attr; + pub trait Visitor<'a> { fn visit_stmt(&mut self, stmt: &'a Stmt) { walk_stmt(self, stmt); diff --git a/src/check_ast.rs b/src/check_ast.rs index a5f1f2a8bd..4316a25c98 100644 --- a/src/check_ast.rs +++ b/src/check_ast.rs @@ -18,7 +18,7 @@ use crate::ast::types::{ ScopeKind, }; use crate::ast::visitor::{walk_excepthandler, Visitor}; -use crate::ast::{checks, helpers, operations, visitor}; +use crate::ast::{checkers, helpers, operations, visitor}; use crate::autofix::{fixer, fixes}; use crate::checks::{Check, CheckCode, CheckKind}; use crate::plugins; @@ -192,27 +192,24 @@ where if self.settings.enabled.contains(&CheckCode::E741) { let location = self.locate_check(Range::from_located(stmt)); self.checks.extend( - names.iter().filter_map(|name| { - checks::check_ambiguous_variable_name(name, location) - }), + names + .iter() + .filter_map(|name| checkers::ambiguous_variable_name(name, location)), ); } } StmtKind::Break => { if self.settings.enabled.contains(&CheckCode::F701) { - if let Some(check) = checks::check_break_outside_loop( - stmt, - &self.parents, - &self.parent_stack, - self, - ) { + if let Some(check) = + checkers::break_outside_loop(stmt, &self.parents, &self.parent_stack, self) + { self.checks.push(check); } } } StmtKind::Continue => { if self.settings.enabled.contains(&CheckCode::F702) { - if let Some(check) = checks::check_continue_outside_loop( + if let Some(check) = checkers::continue_outside_loop( stmt, &self.parents, &self.parent_stack, @@ -237,7 +234,7 @@ where .. } => { if self.settings.enabled.contains(&CheckCode::E743) { - if let Some(check) = checks::check_ambiguous_function_name( + if let Some(check) = checkers::ambiguous_function_name( name, self.locate_check(Range::from_located(stmt)), ) { @@ -325,7 +322,7 @@ where } if self.settings.enabled.contains(&CheckCode::E742) { - if let Some(check) = checks::check_ambiguous_class_name( + if let Some(check) = checkers::ambiguous_class_name( name, self.locate_check(Range::from_located(stmt)), ) { @@ -534,7 +531,7 @@ where StmtKind::Raise { exc, .. } => { if self.settings.enabled.contains(&CheckCode::F901) { if let Some(expr) = exc { - if let Some(check) = checks::check_raise_not_implemented(expr) { + if let Some(check) = checkers::raise_not_implemented(expr) { self.checks.push(check); } } @@ -558,7 +555,7 @@ where } StmtKind::Try { handlers, .. } => { if self.settings.enabled.contains(&CheckCode::F707) { - if let Some(check) = checks::check_default_except_not_last(handlers) { + if let Some(check) = checkers::default_except_not_last(handlers) { self.checks.push(check); } } @@ -570,7 +567,7 @@ where } StmtKind::Assign { targets, value, .. } => { if self.settings.enabled.contains(&CheckCode::E731) { - if let Some(check) = checks::check_do_not_assign_lambda( + if let Some(check) = checkers::do_not_assign_lambda( value, self.locate_check(Range::from_located(stmt)), ) { @@ -584,7 +581,7 @@ where StmtKind::AnnAssign { value, .. } => { if self.settings.enabled.contains(&CheckCode::E731) { if let Some(value) = value { - if let Some(check) = checks::check_do_not_assign_lambda( + if let Some(check) = checkers::do_not_assign_lambda( value, self.locate_check(Range::from_located(stmt)), ) { @@ -701,7 +698,7 @@ where self.settings.enabled.contains(&CheckCode::F621); let check_two_starred_expressions = self.settings.enabled.contains(&CheckCode::F622); - if let Some(check) = checks::check_starred_expressions( + if let Some(check) = checkers::starred_expressions( elts, check_too_many_expressions, check_two_starred_expressions, @@ -724,7 +721,7 @@ where } ExprContext::Store => { if self.settings.enabled.contains(&CheckCode::E741) { - if let Some(check) = checks::check_ambiguous_variable_name( + if let Some(check) = checkers::ambiguous_variable_name( id, self.locate_check(Range::from_located(expr)), ) { @@ -774,26 +771,26 @@ where // flake8-comprehensions if self.settings.enabled.contains(&CheckCode::C400) { - if let Some(check) = checks::unnecessary_generator_list(expr, func, args) { + if let Some(check) = checkers::unnecessary_generator_list(expr, func, args) { self.checks.push(check); }; } if self.settings.enabled.contains(&CheckCode::C401) { - if let Some(check) = checks::unnecessary_generator_set(expr, func, args) { + if let Some(check) = checkers::unnecessary_generator_set(expr, func, args) { self.checks.push(check); }; } if self.settings.enabled.contains(&CheckCode::C402) { - if let Some(check) = checks::unnecessary_generator_dict(expr, func, args) { + if let Some(check) = checkers::unnecessary_generator_dict(expr, func, args) { self.checks.push(check); }; } if self.settings.enabled.contains(&CheckCode::C403) { if let Some(check) = - checks::unnecessary_list_comprehension_set(expr, func, args) + checkers::unnecessary_list_comprehension_set(expr, func, args) { self.checks.push(check); }; @@ -801,27 +798,27 @@ where if self.settings.enabled.contains(&CheckCode::C404) { if let Some(check) = - checks::unnecessary_list_comprehension_dict(expr, func, args) + checkers::unnecessary_list_comprehension_dict(expr, func, args) { self.checks.push(check); }; } if self.settings.enabled.contains(&CheckCode::C405) { - if let Some(check) = checks::unnecessary_literal_set(expr, func, args) { + if let Some(check) = checkers::unnecessary_literal_set(expr, func, args) { self.checks.push(check); }; } if self.settings.enabled.contains(&CheckCode::C406) { - if let Some(check) = checks::unnecessary_literal_dict(expr, func, args) { + if let Some(check) = checkers::unnecessary_literal_dict(expr, func, args) { self.checks.push(check); }; } if self.settings.enabled.contains(&CheckCode::C408) { if let Some(check) = - checks::unnecessary_collection_call(expr, func, args, keywords) + checkers::unnecessary_collection_call(expr, func, args, keywords) { self.checks.push(check); }; @@ -829,7 +826,7 @@ where if self.settings.enabled.contains(&CheckCode::C409) { if let Some(check) = - checks::unnecessary_literal_within_tuple_call(expr, func, args) + checkers::unnecessary_literal_within_tuple_call(expr, func, args) { self.checks.push(check); }; @@ -837,13 +834,14 @@ where if self.settings.enabled.contains(&CheckCode::C410) { if let Some(check) = - checks::unnecessary_literal_within_list_call(expr, func, args) + checkers::unnecessary_literal_within_list_call(expr, func, args) { self.checks.push(check); }; } if self.settings.enabled.contains(&CheckCode::C415) { - if let Some(check) = checks::unnecessary_subscript_reversal(expr, func, args) { + if let Some(check) = checkers::unnecessary_subscript_reversal(expr, func, args) + { self.checks.push(check); }; } @@ -878,7 +876,7 @@ where let check_repeated_literals = self.settings.enabled.contains(&CheckCode::F601); let check_repeated_variables = self.settings.enabled.contains(&CheckCode::F602); if check_repeated_literals || check_repeated_variables { - self.checks.extend(checks::check_repeated_keys( + self.checks.extend(checkers::repeated_keys( keys, check_repeated_literals, check_repeated_variables, @@ -930,7 +928,7 @@ where let check_not_in = self.settings.enabled.contains(&CheckCode::E713); let check_not_is = self.settings.enabled.contains(&CheckCode::E714); if check_not_in || check_not_is { - self.checks.extend(checks::check_not_tests( + self.checks.extend(checkers::not_tests( op, operand, check_not_in, @@ -947,7 +945,7 @@ where let check_none_comparisons = self.settings.enabled.contains(&CheckCode::E711); let check_true_false_comparisons = self.settings.enabled.contains(&CheckCode::E712); if check_none_comparisons || check_true_false_comparisons { - self.checks.extend(checks::check_literal_comparisons( + self.checks.extend(checkers::literal_comparisons( left, ops, comparators, @@ -958,7 +956,7 @@ where } if self.settings.enabled.contains(&CheckCode::F632) { - self.checks.extend(checks::check_is_literal( + self.checks.extend(checkers::is_literal( left, ops, comparators, @@ -967,7 +965,7 @@ where } if self.settings.enabled.contains(&CheckCode::E721) { - self.checks.extend(checks::check_type_comparison( + self.checks.extend(checkers::type_comparison( ops, comparators, self.locate_check(Range::from_located(expr)), @@ -1194,7 +1192,7 @@ where match name { Some(name) => { if self.settings.enabled.contains(&CheckCode::E741) { - if let Some(check) = checks::check_ambiguous_variable_name( + if let Some(check) = checkers::ambiguous_variable_name( name, self.locate_check(Range::from_located(excepthandler)), ) { @@ -1262,8 +1260,7 @@ where fn visit_arguments(&mut self, arguments: &'b Arguments) { if self.settings.enabled.contains(&CheckCode::F831) { - self.checks - .extend(checks::check_duplicate_arguments(arguments)); + self.checks.extend(checkers::duplicate_arguments(arguments)); } // Bind, but intentionally avoid walking default expressions, as we handle them upstream. @@ -1296,7 +1293,7 @@ where ); if self.settings.enabled.contains(&CheckCode::E741) { - if let Some(check) = checks::check_ambiguous_variable_name( + if let Some(check) = checkers::ambiguous_variable_name( &arg.node.arg, self.locate_check(Range::from_located(arg)), ) { @@ -1744,7 +1741,7 @@ impl<'a> Checker<'a> { fn check_deferred_assignments(&mut self) { if self.settings.enabled.contains(&CheckCode::F841) { while let Some(index) = self.deferred_assignments.pop() { - self.checks.extend(checks::check_unused_variables( + self.checks.extend(checkers::unused_variables( &self.scopes[index], self, &self.settings.dummy_variable_rgx, @@ -1899,19 +1896,19 @@ impl<'a> Checker<'a> { // flake8-builtins if is_attribute && matches!(scope.kind, ScopeKind::Class) { if self.settings.enabled.contains(&CheckCode::A003) { - if let Some(check) = checks::check_builtin_shadowing( + if let Some(check) = checkers::builtin_shadowing( name, self.locate_check(location), - checks::ShadowingType::Attribute, + checkers::ShadowingType::Attribute, ) { self.checks.push(check); } } } else if self.settings.enabled.contains(&CheckCode::A001) { - if let Some(check) = checks::check_builtin_shadowing( + if let Some(check) = checkers::builtin_shadowing( name, self.locate_check(location), - checks::ShadowingType::Variable, + checkers::ShadowingType::Variable, ) { self.checks.push(check); } @@ -1920,10 +1917,10 @@ impl<'a> Checker<'a> { fn check_builtin_arg_shadowing(&mut self, name: &str, location: Range) { if self.settings.enabled.contains(&CheckCode::A002) { - if let Some(check) = checks::check_builtin_shadowing( + if let Some(check) = checkers::builtin_shadowing( name, self.locate_check(location), - checks::ShadowingType::Argument, + checkers::ShadowingType::Argument, ) { self.checks.push(check); } diff --git a/src/checks.rs b/src/checks.rs index f4f51313bb..6feba6b1de 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -1,10 +1,11 @@ +use std::str::FromStr; + use itertools::Itertools; use rustpython_parser::ast::Location; use serde::{Deserialize, Serialize}; -use std::str::FromStr; use strum_macros::{AsRefStr, EnumIter, EnumString}; -use crate::ast::checks::Primitive; +use crate::ast::checkers::Primitive; use crate::ast::types::Range; pub const DEFAULT_CHECK_CODES: [CheckCode; 43] = [ diff --git a/src/plugins/assert_tuple.rs b/src/plugins/assert_tuple.rs index a01f1894f8..247b6483ec 100644 --- a/src/plugins/assert_tuple.rs +++ b/src/plugins/assert_tuple.rs @@ -1,12 +1,12 @@ use rustpython_ast::{Expr, Stmt}; -use crate::ast::checks; +use crate::ast::checkers; use crate::ast::types::{CheckLocator, Range}; use crate::check_ast::Checker; pub fn assert_tuple(checker: &mut Checker, stmt: &Stmt, test: &Expr) { if let Some(check) = - checks::check_assert_tuple(test, checker.locate_check(Range::from_located(stmt))) + checkers::assert_tuple(test, checker.locate_check(Range::from_located(stmt))) { checker.add_check(check); } diff --git a/src/plugins/duplicate_exceptions.rs b/src/plugins/duplicate_exceptions.rs index c4f90815a9..93ec8a628b 100644 --- a/src/plugins/duplicate_exceptions.rs +++ b/src/plugins/duplicate_exceptions.rs @@ -1,6 +1,6 @@ -use itertools::Itertools; use std::collections::BTreeSet; +use itertools::Itertools; use rustpython_ast::{Excepthandler, ExcepthandlerKind, Expr, ExprKind, Stmt}; use crate::ast::helpers; diff --git a/src/plugins/if_tuple.rs b/src/plugins/if_tuple.rs index 649ed6ef5f..3a7a31bb70 100644 --- a/src/plugins/if_tuple.rs +++ b/src/plugins/if_tuple.rs @@ -1,13 +1,11 @@ use rustpython_ast::{Expr, Stmt}; -use crate::ast::checks; +use crate::ast::checkers; use crate::ast::types::{CheckLocator, Range}; use crate::check_ast::Checker; pub fn if_tuple(checker: &mut Checker, stmt: &Stmt, test: &Expr) { - if let Some(check) = - checks::check_if_tuple(test, checker.locate_check(Range::from_located(stmt))) - { + if let Some(check) = checkers::if_tuple(test, checker.locate_check(Range::from_located(stmt))) { checker.add_check(check); } } diff --git a/src/plugins/print_call.rs b/src/plugins/print_call.rs index cc93258fe6..8f8604a1a3 100644 --- a/src/plugins/print_call.rs +++ b/src/plugins/print_call.rs @@ -1,13 +1,13 @@ use log::error; use rustpython_ast::{Expr, Stmt, StmtKind}; -use crate::ast::checks; +use crate::ast::checkers; use crate::autofix::{fixer, fixes}; use crate::check_ast::Checker; use crate::checks::CheckCode; pub fn print_call(checker: &mut Checker, expr: &Expr, func: &Expr) { - if let Some(mut check) = checks::check_print_call( + if let Some(mut check) = checkers::print_call( expr, func, checker.settings.enabled.contains(&CheckCode::T201), diff --git a/src/plugins/super_call_with_parameters.rs b/src/plugins/super_call_with_parameters.rs index f352668f36..8c1dfa8c71 100644 --- a/src/plugins/super_call_with_parameters.rs +++ b/src/plugins/super_call_with_parameters.rs @@ -1,6 +1,6 @@ use rustpython_ast::{Expr, Stmt}; -use crate::ast::{checks, helpers}; +use crate::ast::{checkers, helpers}; use crate::autofix::{fixer, fixes}; use crate::check_ast::Checker; @@ -19,7 +19,7 @@ pub fn super_call_with_parameters( .iter() .map(|index| checker.parents[*index]) .collect(); - if let Some(mut check) = checks::check_super_args(scope, &parents, expr, func, args) { + if let Some(mut check) = checkers::super_args(scope, &parents, expr, func, args) { if matches!(checker.autofix, fixer::Mode::Generate | fixer::Mode::Apply) { if let Some(fix) = fixes::remove_super_arguments(&mut checker.locator, expr) { check.amend(fix); diff --git a/src/plugins/type_of_primitive.rs b/src/plugins/type_of_primitive.rs index 772fdfe780..ba6a3e146f 100644 --- a/src/plugins/type_of_primitive.rs +++ b/src/plugins/type_of_primitive.rs @@ -1,6 +1,6 @@ use rustpython_ast::Expr; -use crate::ast::checks; +use crate::ast::checkers; use crate::ast::types::{CheckLocator, Range}; use crate::autofix::fixer; use crate::check_ast::Checker; @@ -8,7 +8,7 @@ use crate::checks::{CheckKind, Fix}; pub fn type_of_primitive(checker: &mut Checker, expr: &Expr, func: &Expr, args: &Vec) { if let Some(mut check) = - checks::check_type_of_primitive(func, args, checker.locate_check(Range::from_located(expr))) + checkers::type_of_primitive(func, args, checker.locate_check(Range::from_located(expr))) { if matches!(checker.autofix, fixer::Mode::Generate | fixer::Mode::Apply) { if let CheckKind::TypeOfPrimitive(primitive) = &check.kind { diff --git a/src/plugins/unnecessary_abspath.rs b/src/plugins/unnecessary_abspath.rs index 8e3a8f56b3..45b5ac1ae0 100644 --- a/src/plugins/unnecessary_abspath.rs +++ b/src/plugins/unnecessary_abspath.rs @@ -1,17 +1,15 @@ use rustpython_ast::Expr; -use crate::ast::checks; +use crate::ast::checkers; use crate::ast::types::{CheckLocator, Range}; use crate::autofix::fixer; use crate::check_ast::Checker; use crate::checks::Fix; pub fn unnecessary_abspath(checker: &mut Checker, expr: &Expr, func: &Expr, args: &Vec) { - if let Some(mut check) = checks::check_unnecessary_abspath( - func, - args, - checker.locate_check(Range::from_located(expr)), - ) { + if let Some(mut check) = + checkers::unnecessary_abspath(func, args, checker.locate_check(Range::from_located(expr))) + { if matches!(checker.autofix, fixer::Mode::Generate | fixer::Mode::Apply) { check.amend(Fix { content: "__file__".to_string(), diff --git a/src/plugins/useless_metaclass_type.rs b/src/plugins/useless_metaclass_type.rs index d54d962b48..c7c85d23aa 100644 --- a/src/plugins/useless_metaclass_type.rs +++ b/src/plugins/useless_metaclass_type.rs @@ -1,7 +1,7 @@ use log::error; use rustpython_ast::{Expr, Stmt}; -use crate::ast::checks; +use crate::ast::checkers; use crate::ast::types::{CheckLocator, Range}; use crate::autofix::{fixer, fixes}; use crate::check_ast::Checker; @@ -12,7 +12,7 @@ pub fn useless_metaclass_type( value: &Expr, targets: &Vec, ) { - if let Some(mut check) = checks::check_useless_metaclass_type( + if let Some(mut check) = checkers::useless_metaclass_type( targets, value, checker.locate_check(Range::from_located(stmt)), diff --git a/src/plugins/useless_object_inheritance.rs b/src/plugins/useless_object_inheritance.rs index 34a24dbb54..ad6dc2a0d7 100644 --- a/src/plugins/useless_object_inheritance.rs +++ b/src/plugins/useless_object_inheritance.rs @@ -1,6 +1,6 @@ use rustpython_ast::{Expr, Keyword, Stmt}; -use crate::ast::checks; +use crate::ast::checkers; use crate::autofix::{fixer, fixes}; use crate::check_ast::Checker; @@ -12,7 +12,7 @@ pub fn useless_object_inheritance( keywords: &[Keyword], ) { let scope = checker.current_scope(); - if let Some(mut check) = checks::check_useless_object_inheritance(name, bases, scope) { + if let Some(mut check) = checkers::useless_object_inheritance(name, bases, scope) { if matches!(checker.autofix, fixer::Mode::Generate | fixer::Mode::Apply) { if let Some(fix) = fixes::remove_class_def_base( &mut checker.locator,