Add Checker::enabled shortcut (#4625)

This is a refactoring that shortens a bunch of code by replacing `checker.settings.rules.enabled` with `checker.enabled`
This commit is contained in:
konstin 2023-05-24 14:56:41 +02:00 committed by GitHub
parent 5b9d4f18ae
commit a59d252246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 566 additions and 1273 deletions

File diff suppressed because it is too large Load Diff

View File

@ -135,15 +135,11 @@ pub(crate) fn subscript(checker: &mut Checker, value: &Expr, slice: &Expr) {
.. ..
}) = upper.as_ref() }) = upper.as_ref()
{ {
if *i == BigInt::from(1) if *i == BigInt::from(1) && checker.enabled(Rule::SysVersionSlice1) {
&& checker.settings.rules.enabled(Rule::SysVersionSlice1)
{
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(SysVersionSlice1, value.range())); .push(Diagnostic::new(SysVersionSlice1, value.range()));
} else if *i == BigInt::from(3) } else if *i == BigInt::from(3) && checker.enabled(Rule::SysVersionSlice3) {
&& checker.settings.rules.enabled(Rule::SysVersionSlice3)
{
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(SysVersionSlice3, value.range())); .push(Diagnostic::new(SysVersionSlice3, value.range()));
@ -155,12 +151,11 @@ pub(crate) fn subscript(checker: &mut Checker, value: &Expr, slice: &Expr) {
value: Constant::Int(i), value: Constant::Int(i),
.. ..
}) => { }) => {
if *i == BigInt::from(2) && checker.settings.rules.enabled(Rule::SysVersion2) { if *i == BigInt::from(2) && checker.enabled(Rule::SysVersion2) {
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(SysVersion2, value.range())); .push(Diagnostic::new(SysVersion2, value.range()));
} else if *i == BigInt::from(0) && checker.settings.rules.enabled(Rule::SysVersion0) } else if *i == BigInt::from(0) && checker.enabled(Rule::SysVersion0) {
{
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(SysVersion0, value.range())); .push(Diagnostic::new(SysVersion0, value.range()));
@ -192,9 +187,7 @@ pub(crate) fn compare(checker: &mut Checker, left: &Expr, ops: &[Cmpop], compara
})], })],
) = (ops, comparators) ) = (ops, comparators)
{ {
if *n == BigInt::from(3) if *n == BigInt::from(3) && checker.enabled(Rule::SysVersionInfo0Eq3) {
&& checker.settings.rules.enabled(Rule::SysVersionInfo0Eq3)
{
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(SysVersionInfo0Eq3, left.range())); .push(Diagnostic::new(SysVersionInfo0Eq3, left.range()));
@ -209,7 +202,7 @@ pub(crate) fn compare(checker: &mut Checker, left: &Expr, ops: &[Cmpop], compara
})], })],
) = (ops, comparators) ) = (ops, comparators)
{ {
if checker.settings.rules.enabled(Rule::SysVersionInfo1CmpInt) { if checker.enabled(Rule::SysVersionInfo1CmpInt) {
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(SysVersionInfo1CmpInt, left.range())); .push(Diagnostic::new(SysVersionInfo1CmpInt, left.range()));
@ -230,11 +223,7 @@ pub(crate) fn compare(checker: &mut Checker, left: &Expr, ops: &[Cmpop], compara
})], })],
) = (ops, comparators) ) = (ops, comparators)
{ {
if checker if checker.enabled(Rule::SysVersionInfoMinorCmpInt) {
.settings
.rules
.enabled(Rule::SysVersionInfoMinorCmpInt)
{
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(SysVersionInfoMinorCmpInt, left.range())); .push(Diagnostic::new(SysVersionInfoMinorCmpInt, left.range()));
@ -255,12 +244,12 @@ pub(crate) fn compare(checker: &mut Checker, left: &Expr, ops: &[Cmpop], compara
) = (ops, comparators) ) = (ops, comparators)
{ {
if s.len() == 1 { if s.len() == 1 {
if checker.settings.rules.enabled(Rule::SysVersionCmpStr10) { if checker.enabled(Rule::SysVersionCmpStr10) {
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(SysVersionCmpStr10, left.range())); .push(Diagnostic::new(SysVersionCmpStr10, left.range()));
} }
} else if checker.settings.rules.enabled(Rule::SysVersionCmpStr3) { } else if checker.enabled(Rule::SysVersionCmpStr3) {
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(SysVersionCmpStr3, left.range())); .push(Diagnostic::new(SysVersionCmpStr3, left.range()));

View File

@ -502,7 +502,7 @@ pub(crate) fn definition(
// ANN401 for dynamically typed arguments // ANN401 for dynamically typed arguments
if let Some(annotation) = &arg.annotation { if let Some(annotation) = &arg.annotation {
has_any_typed_arg = true; has_any_typed_arg = true;
if checker.settings.rules.enabled(Rule::AnyType) { if checker.enabled(Rule::AnyType) {
check_dynamically_typed( check_dynamically_typed(
checker.semantic_model(), checker.semantic_model(),
annotation, annotation,
@ -515,11 +515,7 @@ pub(crate) fn definition(
if !(checker.settings.flake8_annotations.suppress_dummy_args if !(checker.settings.flake8_annotations.suppress_dummy_args
&& checker.settings.dummy_variable_rgx.is_match(&arg.arg)) && checker.settings.dummy_variable_rgx.is_match(&arg.arg))
{ {
if checker if checker.enabled(Rule::MissingTypeFunctionArgument) {
.settings
.rules
.enabled(Rule::MissingTypeFunctionArgument)
{
diagnostics.push(Diagnostic::new( diagnostics.push(Diagnostic::new(
MissingTypeFunctionArgument { MissingTypeFunctionArgument {
name: arg.arg.to_string(), name: arg.arg.to_string(),
@ -536,7 +532,7 @@ pub(crate) fn definition(
if let Some(expr) = &arg.annotation { if let Some(expr) = &arg.annotation {
has_any_typed_arg = true; has_any_typed_arg = true;
if !checker.settings.flake8_annotations.allow_star_arg_any { if !checker.settings.flake8_annotations.allow_star_arg_any {
if checker.settings.rules.enabled(Rule::AnyType) { if checker.enabled(Rule::AnyType) {
let name = &arg.arg; let name = &arg.arg;
check_dynamically_typed( check_dynamically_typed(
checker.semantic_model(), checker.semantic_model(),
@ -551,7 +547,7 @@ pub(crate) fn definition(
if !(checker.settings.flake8_annotations.suppress_dummy_args if !(checker.settings.flake8_annotations.suppress_dummy_args
&& checker.settings.dummy_variable_rgx.is_match(&arg.arg)) && checker.settings.dummy_variable_rgx.is_match(&arg.arg))
{ {
if checker.settings.rules.enabled(Rule::MissingTypeArgs) { if checker.enabled(Rule::MissingTypeArgs) {
diagnostics.push(Diagnostic::new( diagnostics.push(Diagnostic::new(
MissingTypeArgs { MissingTypeArgs {
name: arg.arg.to_string(), name: arg.arg.to_string(),
@ -568,7 +564,7 @@ pub(crate) fn definition(
if let Some(expr) = &arg.annotation { if let Some(expr) = &arg.annotation {
has_any_typed_arg = true; has_any_typed_arg = true;
if !checker.settings.flake8_annotations.allow_star_arg_any { if !checker.settings.flake8_annotations.allow_star_arg_any {
if checker.settings.rules.enabled(Rule::AnyType) { if checker.enabled(Rule::AnyType) {
let name = &arg.arg; let name = &arg.arg;
check_dynamically_typed( check_dynamically_typed(
checker.semantic_model(), checker.semantic_model(),
@ -583,7 +579,7 @@ pub(crate) fn definition(
if !(checker.settings.flake8_annotations.suppress_dummy_args if !(checker.settings.flake8_annotations.suppress_dummy_args
&& checker.settings.dummy_variable_rgx.is_match(&arg.arg)) && checker.settings.dummy_variable_rgx.is_match(&arg.arg))
{ {
if checker.settings.rules.enabled(Rule::MissingTypeKwargs) { if checker.enabled(Rule::MissingTypeKwargs) {
diagnostics.push(Diagnostic::new( diagnostics.push(Diagnostic::new(
MissingTypeKwargs { MissingTypeKwargs {
name: arg.arg.to_string(), name: arg.arg.to_string(),
@ -603,7 +599,7 @@ pub(crate) fn definition(
if arg.annotation.is_none() { if arg.annotation.is_none() {
if visibility::is_classmethod(checker.semantic_model(), cast::decorator_list(stmt)) if visibility::is_classmethod(checker.semantic_model(), cast::decorator_list(stmt))
{ {
if checker.settings.rules.enabled(Rule::MissingTypeCls) { if checker.enabled(Rule::MissingTypeCls) {
diagnostics.push(Diagnostic::new( diagnostics.push(Diagnostic::new(
MissingTypeCls { MissingTypeCls {
name: arg.arg.to_string(), name: arg.arg.to_string(),
@ -612,7 +608,7 @@ pub(crate) fn definition(
)); ));
} }
} else { } else {
if checker.settings.rules.enabled(Rule::MissingTypeSelf) { if checker.enabled(Rule::MissingTypeSelf) {
diagnostics.push(Diagnostic::new( diagnostics.push(Diagnostic::new(
MissingTypeSelf { MissingTypeSelf {
name: arg.arg.to_string(), name: arg.arg.to_string(),
@ -630,7 +626,7 @@ pub(crate) fn definition(
// ANN201, ANN202, ANN401 // ANN201, ANN202, ANN401
if let Some(expr) = &returns { if let Some(expr) = &returns {
has_typed_return = true; has_typed_return = true;
if checker.settings.rules.enabled(Rule::AnyType) { if checker.enabled(Rule::AnyType) {
check_dynamically_typed( check_dynamically_typed(
checker.semantic_model(), checker.semantic_model(),
expr, expr,
@ -647,11 +643,7 @@ pub(crate) fn definition(
if is_method if is_method
&& visibility::is_classmethod(checker.semantic_model(), cast::decorator_list(stmt)) && visibility::is_classmethod(checker.semantic_model(), cast::decorator_list(stmt))
{ {
if checker if checker.enabled(Rule::MissingReturnTypeClassMethod) {
.settings
.rules
.enabled(Rule::MissingReturnTypeClassMethod)
{
diagnostics.push(Diagnostic::new( diagnostics.push(Diagnostic::new(
MissingReturnTypeClassMethod { MissingReturnTypeClassMethod {
name: name.to_string(), name: name.to_string(),
@ -662,11 +654,7 @@ pub(crate) fn definition(
} else if is_method } else if is_method
&& visibility::is_staticmethod(checker.semantic_model(), cast::decorator_list(stmt)) && visibility::is_staticmethod(checker.semantic_model(), cast::decorator_list(stmt))
{ {
if checker if checker.enabled(Rule::MissingReturnTypeStaticMethod) {
.settings
.rules
.enabled(Rule::MissingReturnTypeStaticMethod)
{
diagnostics.push(Diagnostic::new( diagnostics.push(Diagnostic::new(
MissingReturnTypeStaticMethod { MissingReturnTypeStaticMethod {
name: name.to_string(), name: name.to_string(),
@ -677,11 +665,7 @@ pub(crate) fn definition(
} else if is_method && visibility::is_init(name) { } else if is_method && visibility::is_init(name) {
// Allow omission of return annotation in `__init__` functions, as long as at // Allow omission of return annotation in `__init__` functions, as long as at
// least one argument is typed. // least one argument is typed.
if checker if checker.enabled(Rule::MissingReturnTypeSpecialMethod) {
.settings
.rules
.enabled(Rule::MissingReturnTypeSpecialMethod)
{
if !(checker.settings.flake8_annotations.mypy_init_return && has_any_typed_arg) { if !(checker.settings.flake8_annotations.mypy_init_return && has_any_typed_arg) {
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
MissingReturnTypeSpecialMethod { MissingReturnTypeSpecialMethod {
@ -699,11 +683,7 @@ pub(crate) fn definition(
} }
} }
} else if is_method && visibility::is_magic(name) { } else if is_method && visibility::is_magic(name) {
if checker if checker.enabled(Rule::MissingReturnTypeSpecialMethod) {
.settings
.rules
.enabled(Rule::MissingReturnTypeSpecialMethod)
{
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
MissingReturnTypeSpecialMethod { MissingReturnTypeSpecialMethod {
name: name.to_string(), name: name.to_string(),
@ -724,11 +704,7 @@ pub(crate) fn definition(
} else { } else {
match visibility { match visibility {
Visibility::Public => { Visibility::Public => {
if checker if checker.enabled(Rule::MissingReturnTypeUndocumentedPublicFunction) {
.settings
.rules
.enabled(Rule::MissingReturnTypeUndocumentedPublicFunction)
{
diagnostics.push(Diagnostic::new( diagnostics.push(Diagnostic::new(
MissingReturnTypeUndocumentedPublicFunction { MissingReturnTypeUndocumentedPublicFunction {
name: name.to_string(), name: name.to_string(),
@ -738,11 +714,7 @@ pub(crate) fn definition(
} }
} }
Visibility::Private => { Visibility::Private => {
if checker if checker.enabled(Rule::MissingReturnTypePrivateFunction) {
.settings
.rules
.enabled(Rule::MissingReturnTypePrivateFunction)
{
diagnostics.push(Diagnostic::new( diagnostics.push(Diagnostic::new(
MissingReturnTypePrivateFunction { MissingReturnTypePrivateFunction {
name: name.to_string(), name: name.to_string(),

View File

@ -194,11 +194,7 @@ pub(crate) fn shell_injection(
truthiness: Truthiness::Truthy, truthiness: Truthiness::Truthy,
keyword, keyword,
}) => { }) => {
if checker if checker.enabled(Rule::SubprocessPopenWithShellEqualsTrue) {
.settings
.rules
.enabled(Rule::SubprocessPopenWithShellEqualsTrue)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
SubprocessPopenWithShellEqualsTrue { SubprocessPopenWithShellEqualsTrue {
seems_safe: shell_call_seems_safe(arg), seems_safe: shell_call_seems_safe(arg),
@ -212,11 +208,7 @@ pub(crate) fn shell_injection(
truthiness: Truthiness::Falsey | Truthiness::Unknown, truthiness: Truthiness::Falsey | Truthiness::Unknown,
keyword, keyword,
}) => { }) => {
if checker if checker.enabled(Rule::SubprocessWithoutShellEqualsTrue) {
.settings
.rules
.enabled(Rule::SubprocessWithoutShellEqualsTrue)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
SubprocessWithoutShellEqualsTrue, SubprocessWithoutShellEqualsTrue,
keyword.range(), keyword.range(),
@ -225,11 +217,7 @@ pub(crate) fn shell_injection(
} }
// S603 // S603
None => { None => {
if checker if checker.enabled(Rule::SubprocessWithoutShellEqualsTrue) {
.settings
.rules
.enabled(Rule::SubprocessWithoutShellEqualsTrue)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
SubprocessWithoutShellEqualsTrue, SubprocessWithoutShellEqualsTrue,
arg.range(), arg.range(),
@ -244,11 +232,7 @@ pub(crate) fn shell_injection(
}) = find_shell_keyword(checker.semantic_model(), keywords) }) = find_shell_keyword(checker.semantic_model(), keywords)
{ {
// S604 // S604
if checker if checker.enabled(Rule::CallWithShellEqualsTrue) {
.settings
.rules
.enabled(Rule::CallWithShellEqualsTrue)
{
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(CallWithShellEqualsTrue, keyword.range())); .push(Diagnostic::new(CallWithShellEqualsTrue, keyword.range()));
@ -258,7 +242,7 @@ pub(crate) fn shell_injection(
// S605 // S605
if matches!(call_kind, Some(CallKind::Shell)) { if matches!(call_kind, Some(CallKind::Shell)) {
if let Some(arg) = args.first() { if let Some(arg) = args.first() {
if checker.settings.rules.enabled(Rule::StartProcessWithAShell) { if checker.enabled(Rule::StartProcessWithAShell) {
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
StartProcessWithAShell { StartProcessWithAShell {
seems_safe: shell_call_seems_safe(arg), seems_safe: shell_call_seems_safe(arg),
@ -271,11 +255,7 @@ pub(crate) fn shell_injection(
// S606 // S606
if matches!(call_kind, Some(CallKind::NoShell)) { if matches!(call_kind, Some(CallKind::NoShell)) {
if checker if checker.enabled(Rule::StartProcessWithNoShell) {
.settings
.rules
.enabled(Rule::StartProcessWithNoShell)
{
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(StartProcessWithNoShell, func.range())); .push(Diagnostic::new(StartProcessWithNoShell, func.range()));
@ -285,11 +265,7 @@ pub(crate) fn shell_injection(
// S607 // S607
if call_kind.is_some() { if call_kind.is_some() {
if let Some(arg) = args.first() { if let Some(arg) = args.first() {
if checker if checker.enabled(Rule::StartProcessWithPartialPath) {
.settings
.rules
.enabled(Rule::StartProcessWithPartialPath)
{
if let Some(value) = try_string_literal(arg) { if let Some(value) = try_string_literal(arg) {
if FULL_PATH_REGEX.find(value).is_none() { if FULL_PATH_REGEX.find(value).is_none() {
checker checker

View File

@ -512,7 +512,7 @@ pub(crate) fn suspicious_function_call(checker: &mut Checker, expr: &Expr) {
Reason::FTPLib => SuspiciousFTPLibUsage.into(), Reason::FTPLib => SuspiciousFTPLibUsage.into(),
}; };
let diagnostic = Diagnostic::new::<DiagnosticKind>(diagnostic_kind, expr.range()); let diagnostic = Diagnostic::new::<DiagnosticKind>(diagnostic_kind, expr.range());
if checker.settings.rules.enabled(diagnostic.kind.rule()) { if checker.enabled(diagnostic.kind.rule()) {
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
} }

View File

@ -111,11 +111,7 @@ pub(crate) fn abstract_base_class(
let has_abstract_decorator = is_abstract(checker.semantic_model(), decorator_list); let has_abstract_decorator = is_abstract(checker.semantic_model(), decorator_list);
has_abstract_method |= has_abstract_decorator; has_abstract_method |= has_abstract_decorator;
if !checker if !checker.enabled(Rule::EmptyMethodWithoutAbstractDecorator) {
.settings
.rules
.enabled(Rule::EmptyMethodWithoutAbstractDecorator)
{
continue; continue;
} }
@ -131,11 +127,7 @@ pub(crate) fn abstract_base_class(
)); ));
} }
} }
if checker if checker.enabled(Rule::AbstractBaseClassWithoutAbstractMethod) {
.settings
.rules
.enabled(Rule::AbstractBaseClassWithoutAbstractMethod)
{
if !has_abstract_method { if !has_abstract_method {
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
AbstractBaseClassWithoutAbstractMethod { AbstractBaseClassWithoutAbstractMethod {

View File

@ -75,11 +75,7 @@ fn duplicate_handler_exceptions<'a>(
} }
} }
if checker if checker.enabled(Rule::DuplicateHandlerException) {
.settings
.rules
.enabled(Rule::DuplicateHandlerException)
{
// TODO(charlie): Handle "BaseException" and redundant exception aliases. // TODO(charlie): Handle "BaseException" and redundant exception aliases.
if !duplicates.is_empty() { if !duplicates.is_empty() {
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
@ -140,11 +136,7 @@ pub(crate) fn duplicate_exceptions(checker: &mut Checker, handlers: &[Excepthand
} }
} }
if checker if checker.enabled(Rule::DuplicateTryBlockException) {
.settings
.rules
.enabled(Rule::DuplicateTryBlockException)
{
for (name, exprs) in duplicates { for (name, exprs) in duplicates {
for expr in exprs { for expr in exprs {
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(

View File

@ -229,7 +229,7 @@ pub(crate) fn string_in_exception(checker: &mut Checker, stmt: &Stmt, exc: &Expr
value: Constant::Str(string), value: Constant::Str(string),
.. ..
}) => { }) => {
if checker.settings.rules.enabled(Rule::RawStringInException) { if checker.enabled(Rule::RawStringInException) {
if string.len() > checker.settings.flake8_errmsg.max_string_length { if string.len() > checker.settings.flake8_errmsg.max_string_length {
let indentation = whitespace::indentation(checker.locator, stmt) let indentation = whitespace::indentation(checker.locator, stmt)
.and_then(|indentation| { .and_then(|indentation| {
@ -258,7 +258,7 @@ pub(crate) fn string_in_exception(checker: &mut Checker, stmt: &Stmt, exc: &Expr
} }
// Check for f-strings. // Check for f-strings.
Expr::JoinedStr(_) => { Expr::JoinedStr(_) => {
if checker.settings.rules.enabled(Rule::FStringInException) { if checker.enabled(Rule::FStringInException) {
let indentation = whitespace::indentation(checker.locator, stmt).and_then( let indentation = whitespace::indentation(checker.locator, stmt).and_then(
|indentation| { |indentation| {
if checker.semantic_model().find_binding("msg").is_none() { if checker.semantic_model().find_binding("msg").is_none() {
@ -285,7 +285,7 @@ pub(crate) fn string_in_exception(checker: &mut Checker, stmt: &Stmt, exc: &Expr
} }
// Check for .format() calls. // Check for .format() calls.
Expr::Call(ast::ExprCall { func, .. }) => { Expr::Call(ast::ExprCall { func, .. }) => {
if checker.settings.rules.enabled(Rule::DotFormatInException) { if checker.enabled(Rule::DotFormatInException) {
if let Expr::Attribute(ast::ExprAttribute { value, attr, .. }) = if let Expr::Attribute(ast::ExprAttribute { value, attr, .. }) =
func.as_ref() func.as_ref()
{ {

View File

@ -44,14 +44,14 @@ fn check_msg(checker: &mut Checker, msg: &Expr) {
// Check for string concatenation and percent format. // Check for string concatenation and percent format.
Expr::BinOp(ast::ExprBinOp { op, .. }) => match op { Expr::BinOp(ast::ExprBinOp { op, .. }) => match op {
Operator::Add => { Operator::Add => {
if checker.settings.rules.enabled(Rule::LoggingStringConcat) { if checker.enabled(Rule::LoggingStringConcat) {
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(LoggingStringConcat, msg.range())); .push(Diagnostic::new(LoggingStringConcat, msg.range()));
} }
} }
Operator::Mod => { Operator::Mod => {
if checker.settings.rules.enabled(Rule::LoggingPercentFormat) { if checker.enabled(Rule::LoggingPercentFormat) {
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(LoggingPercentFormat, msg.range())); .push(Diagnostic::new(LoggingPercentFormat, msg.range()));
@ -61,7 +61,7 @@ fn check_msg(checker: &mut Checker, msg: &Expr) {
}, },
// Check for f-strings. // Check for f-strings.
Expr::JoinedStr(_) => { Expr::JoinedStr(_) => {
if checker.settings.rules.enabled(Rule::LoggingFString) { if checker.enabled(Rule::LoggingFString) {
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(LoggingFString, msg.range())); .push(Diagnostic::new(LoggingFString, msg.range()));
@ -69,7 +69,7 @@ fn check_msg(checker: &mut Checker, msg: &Expr) {
} }
// Check for .format() calls. // Check for .format() calls.
Expr::Call(ast::ExprCall { func, .. }) => { Expr::Call(ast::ExprCall { func, .. }) => {
if checker.settings.rules.enabled(Rule::LoggingStringFormat) { if checker.enabled(Rule::LoggingStringFormat) {
if let Expr::Attribute(ast::ExprAttribute { value, attr, .. }) = func.as_ref() { if let Expr::Attribute(ast::ExprAttribute { value, attr, .. }) = func.as_ref() {
if attr == "format" && value.is_constant_expr() { if attr == "format" && value.is_constant_expr() {
checker checker
@ -167,7 +167,7 @@ pub(crate) fn logging_call(
} }
// G010 // G010
if checker.settings.rules.enabled(Rule::LoggingWarn) if checker.enabled(Rule::LoggingWarn)
&& matches!( && matches!(
logging_call_type, logging_call_type,
LoggingCallType::LevelCall(LoggingLevel::Warn) LoggingCallType::LevelCall(LoggingLevel::Warn)
@ -185,18 +185,15 @@ pub(crate) fn logging_call(
} }
// G101 // G101
if checker.settings.rules.enabled(Rule::LoggingExtraAttrClash) { if checker.enabled(Rule::LoggingExtraAttrClash) {
if let Some(extra) = find_keyword(keywords, "extra") { if let Some(extra) = find_keyword(keywords, "extra") {
check_log_record_attr_clash(checker, extra); check_log_record_attr_clash(checker, extra);
} }
} }
// G201, G202 // G201, G202
if checker.settings.rules.enabled(Rule::LoggingExcInfo) if checker.enabled(Rule::LoggingExcInfo)
|| checker || checker.enabled(Rule::LoggingRedundantExcInfo)
.settings
.rules
.enabled(Rule::LoggingRedundantExcInfo)
{ {
if !checker.semantic_model().in_exception_handler() { if !checker.semantic_model().in_exception_handler() {
return; return;
@ -226,18 +223,14 @@ pub(crate) fn logging_call(
if let LoggingCallType::LevelCall(logging_level) = logging_call_type { if let LoggingCallType::LevelCall(logging_level) = logging_call_type {
match logging_level { match logging_level {
LoggingLevel::Error => { LoggingLevel::Error => {
if checker.settings.rules.enabled(Rule::LoggingExcInfo) { if checker.enabled(Rule::LoggingExcInfo) {
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(LoggingExcInfo, level_call_range)); .push(Diagnostic::new(LoggingExcInfo, level_call_range));
} }
} }
LoggingLevel::Exception => { LoggingLevel::Exception => {
if checker if checker.enabled(Rule::LoggingRedundantExcInfo) {
.settings
.rules
.enabled(Rule::LoggingRedundantExcInfo)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
LoggingRedundantExcInfo, LoggingRedundantExcInfo,
exc_info.range(), exc_info.range(),

View File

@ -112,7 +112,7 @@ pub(crate) fn print_call(checker: &mut Checker, func: &Expr, keywords: &[Keyword
} }
}; };
if !checker.settings.rules.enabled(diagnostic.kind.rule()) { if !checker.enabled(diagnostic.kind.rule()) {
return; return;
} }

View File

@ -113,12 +113,7 @@ pub(crate) fn unrecognized_platform(
} }
// "in" might also make sense but we don't currently have one. // "in" might also make sense but we don't currently have one.
if !matches!(op, Cmpop::Eq | Cmpop::NotEq) if !matches!(op, Cmpop::Eq | Cmpop::NotEq) && checker.enabled(Rule::UnrecognizedPlatformCheck) {
&& checker
.settings
.rules
.enabled(Rule::UnrecognizedPlatformCheck)
{
checker checker
.diagnostics .diagnostics
.push(diagnostic_unrecognized_platform_check); .push(diagnostic_unrecognized_platform_check);
@ -133,10 +128,7 @@ pub(crate) fn unrecognized_platform(
// Other values are possible but we don't need them right now. // Other values are possible but we don't need them right now.
// This protects against typos. // This protects against typos.
if !["linux", "win32", "cygwin", "darwin"].contains(&value.as_str()) if !["linux", "win32", "cygwin", "darwin"].contains(&value.as_str())
&& checker && checker.enabled(Rule::UnrecognizedPlatformName)
.settings
.rules
.enabled(Rule::UnrecognizedPlatformName)
{ {
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
UnrecognizedPlatformName { UnrecognizedPlatformName {
@ -147,11 +139,7 @@ pub(crate) fn unrecognized_platform(
} }
} }
_ => { _ => {
if checker if checker.enabled(Rule::UnrecognizedPlatformCheck) {
.settings
.rules
.enabled(Rule::UnrecognizedPlatformCheck)
{
checker checker
.diagnostics .diagnostics
.push(diagnostic_unrecognized_platform_check); .push(diagnostic_unrecognized_platform_check);

View File

@ -285,10 +285,7 @@ fn check_fixture_decorator(checker: &mut Checker, func_name: &str, decorator: &E
keywords, keywords,
range: _, range: _,
}) => { }) => {
if checker if checker.enabled(Rule::PytestFixtureIncorrectParenthesesStyle)
.settings
.rules
.enabled(Rule::PytestFixtureIncorrectParenthesesStyle)
&& !checker.settings.flake8_pytest_style.fixture_parentheses && !checker.settings.flake8_pytest_style.fixture_parentheses
&& args.is_empty() && args.is_empty()
&& keywords.is_empty() && keywords.is_empty()
@ -304,12 +301,7 @@ fn check_fixture_decorator(checker: &mut Checker, func_name: &str, decorator: &E
); );
} }
if checker if checker.enabled(Rule::PytestFixturePositionalArgs) && !args.is_empty() {
.settings
.rules
.enabled(Rule::PytestFixturePositionalArgs)
&& !args.is_empty()
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
PytestFixturePositionalArgs { PytestFixturePositionalArgs {
function: func_name.to_string(), function: func_name.to_string(),
@ -318,11 +310,7 @@ fn check_fixture_decorator(checker: &mut Checker, func_name: &str, decorator: &E
)); ));
} }
if checker if checker.enabled(Rule::PytestExtraneousScopeFunction) {
.settings
.rules
.enabled(Rule::PytestExtraneousScopeFunction)
{
let scope_keyword = keywords let scope_keyword = keywords
.iter() .iter()
.find(|kw| kw.arg.as_ref().map_or(false, |arg| arg == "scope")); .find(|kw| kw.arg.as_ref().map_or(false, |arg| arg == "scope"));
@ -350,10 +338,7 @@ fn check_fixture_decorator(checker: &mut Checker, func_name: &str, decorator: &E
} }
} }
_ => { _ => {
if checker if checker.enabled(Rule::PytestFixtureIncorrectParenthesesStyle)
.settings
.rules
.enabled(Rule::PytestFixtureIncorrectParenthesesStyle)
&& checker.settings.flake8_pytest_style.fixture_parentheses && checker.settings.flake8_pytest_style.fixture_parentheses
{ {
#[allow(deprecated)] #[allow(deprecated)]
@ -381,10 +366,7 @@ fn check_fixture_returns(checker: &mut Checker, stmt: &Stmt, name: &str, body: &
visitor.visit_stmt(stmt); visitor.visit_stmt(stmt);
} }
if checker if checker.enabled(Rule::PytestIncorrectFixtureNameUnderscore)
.settings
.rules
.enabled(Rule::PytestIncorrectFixtureNameUnderscore)
&& visitor.has_return_with_value && visitor.has_return_with_value
&& name.starts_with('_') && name.starts_with('_')
{ {
@ -394,10 +376,7 @@ fn check_fixture_returns(checker: &mut Checker, stmt: &Stmt, name: &str, body: &
}, },
helpers::identifier_range(stmt, checker.locator), helpers::identifier_range(stmt, checker.locator),
)); ));
} else if checker } else if checker.enabled(Rule::PytestMissingFixtureNameUnderscore)
.settings
.rules
.enabled(Rule::PytestMissingFixtureNameUnderscore)
&& !visitor.has_return_with_value && !visitor.has_return_with_value
&& !visitor.has_yield_from && !visitor.has_yield_from
&& !name.starts_with('_') && !name.starts_with('_')
@ -410,11 +389,7 @@ fn check_fixture_returns(checker: &mut Checker, stmt: &Stmt, name: &str, body: &
)); ));
} }
if checker if checker.enabled(Rule::PytestUselessYieldFixture) {
.settings
.rules
.enabled(Rule::PytestUselessYieldFixture)
{
if let Some(stmt) = body.last() { if let Some(stmt) = body.last() {
if let Stmt::Expr(ast::StmtExpr { value, range: _ }) = stmt { if let Stmt::Expr(ast::StmtExpr { value, range: _ }) = stmt {
if value.is_yield_expr() { if value.is_yield_expr() {
@ -489,11 +464,7 @@ fn check_fixture_addfinalizer(checker: &mut Checker, args: &Arguments, body: &[S
fn check_fixture_marks(checker: &mut Checker, decorators: &[Expr]) { fn check_fixture_marks(checker: &mut Checker, decorators: &[Expr]) {
for (expr, call_path) in get_mark_decorators(decorators) { for (expr, call_path) in get_mark_decorators(decorators) {
let name = call_path.last().expect("Expected a mark name"); let name = call_path.last().expect("Expected a mark name");
if checker if checker.enabled(Rule::PytestUnnecessaryAsyncioMarkOnFixture) {
.settings
.rules
.enabled(Rule::PytestUnnecessaryAsyncioMarkOnFixture)
{
if *name == "asyncio" { if *name == "asyncio" {
let mut diagnostic = let mut diagnostic =
Diagnostic::new(PytestUnnecessaryAsyncioMarkOnFixture, expr.range()); Diagnostic::new(PytestUnnecessaryAsyncioMarkOnFixture, expr.range());
@ -506,11 +477,7 @@ fn check_fixture_marks(checker: &mut Checker, decorators: &[Expr]) {
} }
} }
if checker if checker.enabled(Rule::PytestErroneousUseFixturesOnFixture) {
.settings
.rules
.enabled(Rule::PytestErroneousUseFixturesOnFixture)
{
if *name == "usefixtures" { if *name == "usefixtures" {
let mut diagnostic = let mut diagnostic =
Diagnostic::new(PytestErroneousUseFixturesOnFixture, expr.range()); Diagnostic::new(PytestErroneousUseFixturesOnFixture, expr.range());
@ -535,75 +502,39 @@ pub(crate) fn fixture(
) { ) {
let decorator = get_fixture_decorator(checker.semantic_model(), decorators); let decorator = get_fixture_decorator(checker.semantic_model(), decorators);
if let Some(decorator) = decorator { if let Some(decorator) = decorator {
if checker if checker.enabled(Rule::PytestFixtureIncorrectParenthesesStyle)
.settings || checker.enabled(Rule::PytestFixturePositionalArgs)
.rules || checker.enabled(Rule::PytestExtraneousScopeFunction)
.enabled(Rule::PytestFixtureIncorrectParenthesesStyle)
|| checker
.settings
.rules
.enabled(Rule::PytestFixturePositionalArgs)
|| checker
.settings
.rules
.enabled(Rule::PytestExtraneousScopeFunction)
{ {
check_fixture_decorator(checker, name, decorator); check_fixture_decorator(checker, name, decorator);
} }
if checker if checker.enabled(Rule::PytestDeprecatedYieldFixture)
.settings
.rules
.enabled(Rule::PytestDeprecatedYieldFixture)
&& checker.settings.flake8_pytest_style.fixture_parentheses && checker.settings.flake8_pytest_style.fixture_parentheses
{ {
check_fixture_decorator_name(checker, decorator); check_fixture_decorator_name(checker, decorator);
} }
if (checker if (checker.enabled(Rule::PytestMissingFixtureNameUnderscore)
.settings || checker.enabled(Rule::PytestIncorrectFixtureNameUnderscore)
.rules || checker.enabled(Rule::PytestUselessYieldFixture))
.enabled(Rule::PytestMissingFixtureNameUnderscore)
|| checker
.settings
.rules
.enabled(Rule::PytestIncorrectFixtureNameUnderscore)
|| checker
.settings
.rules
.enabled(Rule::PytestUselessYieldFixture))
&& !is_abstract(checker.semantic_model(), decorators) && !is_abstract(checker.semantic_model(), decorators)
{ {
check_fixture_returns(checker, stmt, name, body); check_fixture_returns(checker, stmt, name, body);
} }
if checker if checker.enabled(Rule::PytestFixtureFinalizerCallback) {
.settings
.rules
.enabled(Rule::PytestFixtureFinalizerCallback)
{
check_fixture_addfinalizer(checker, args, body); check_fixture_addfinalizer(checker, args, body);
} }
if checker if checker.enabled(Rule::PytestUnnecessaryAsyncioMarkOnFixture)
.settings || checker.enabled(Rule::PytestErroneousUseFixturesOnFixture)
.rules
.enabled(Rule::PytestUnnecessaryAsyncioMarkOnFixture)
|| checker
.settings
.rules
.enabled(Rule::PytestErroneousUseFixturesOnFixture)
{ {
check_fixture_marks(checker, decorators); check_fixture_marks(checker, decorators);
} }
} }
if checker if checker.enabled(Rule::PytestFixtureParamWithoutValue) && name.starts_with("test_") {
.settings
.rules
.enabled(Rule::PytestFixtureParamWithoutValue)
&& name.starts_with("test_")
{
check_test_function_args(checker, args); check_test_function_args(checker, args);
} }
} }

View File

@ -125,14 +125,8 @@ fn check_useless_usefixtures(checker: &mut Checker, decorator: &Expr, call_path:
} }
pub(crate) fn marks(checker: &mut Checker, decorators: &[Expr]) { pub(crate) fn marks(checker: &mut Checker, decorators: &[Expr]) {
let enforce_parentheses = checker let enforce_parentheses = checker.enabled(Rule::PytestIncorrectMarkParenthesesStyle);
.settings let enforce_useless_usefixtures = checker.enabled(Rule::PytestUseFixturesWithoutParameters);
.rules
.enabled(Rule::PytestIncorrectMarkParenthesesStyle);
let enforce_useless_usefixtures = checker
.settings
.rules
.enabled(Rule::PytestUseFixturesWithoutParameters);
for (expr, call_path) in get_mark_decorators(decorators) { for (expr, call_path) in get_mark_decorators(decorators) {
if enforce_parentheses { if enforce_parentheses {

View File

@ -421,20 +421,12 @@ pub(crate) fn parametrize(checker: &mut Checker, decorators: &[Expr]) {
for decorator in decorators { for decorator in decorators {
if is_pytest_parametrize(checker.semantic_model(), decorator) { if is_pytest_parametrize(checker.semantic_model(), decorator) {
if let Expr::Call(ast::ExprCall { args, .. }) = decorator { if let Expr::Call(ast::ExprCall { args, .. }) = decorator {
if checker if checker.enabled(Rule::PytestParametrizeNamesWrongType) {
.settings
.rules
.enabled(Rule::PytestParametrizeNamesWrongType)
{
if let Some(names) = args.get(0) { if let Some(names) = args.get(0) {
check_names(checker, decorator, names); check_names(checker, decorator, names);
} }
} }
if checker if checker.enabled(Rule::PytestParametrizeValuesWrongType) {
.settings
.rules
.enabled(Rule::PytestParametrizeValuesWrongType)
{
if let Some(names) = args.get(0) { if let Some(names) = args.get(0) {
if let Some(values) = args.get(1) { if let Some(values) = args.get(1) {
check_values(checker, names, values); check_values(checker, names, values);

View File

@ -65,11 +65,7 @@ const fn is_non_trivial_with_body(body: &[Stmt]) -> bool {
pub(crate) fn raises_call(checker: &mut Checker, func: &Expr, args: &[Expr], keywords: &[Keyword]) { pub(crate) fn raises_call(checker: &mut Checker, func: &Expr, args: &[Expr], keywords: &[Keyword]) {
if is_pytest_raises(func, checker.semantic_model()) { if is_pytest_raises(func, checker.semantic_model()) {
if checker if checker.enabled(Rule::PytestRaisesWithoutException) {
.settings
.rules
.enabled(Rule::PytestRaisesWithoutException)
{
if args.is_empty() && keywords.is_empty() { if args.is_empty() && keywords.is_empty() {
checker checker
.diagnostics .diagnostics
@ -77,7 +73,7 @@ pub(crate) fn raises_call(checker: &mut Checker, func: &Expr, args: &[Expr], key
} }
} }
if checker.settings.rules.enabled(Rule::PytestRaisesTooBroad) { if checker.enabled(Rule::PytestRaisesTooBroad) {
let match_keyword = keywords let match_keyword = keywords
.iter() .iter()
.find(|kw| kw.arg == Some(Identifier::new("match"))); .find(|kw| kw.arg == Some(Identifier::new("match")));

View File

@ -633,7 +633,7 @@ fn superfluous_else_node(checker: &mut Checker, stmt: &Stmt, branch: Branch) ->
SuperfluousElseReturn { branch }, SuperfluousElseReturn { branch },
elif_else_range(stmt, checker.locator).unwrap_or_else(|| stmt.range()), elif_else_range(stmt, checker.locator).unwrap_or_else(|| stmt.range()),
); );
if checker.settings.rules.enabled(diagnostic.kind.rule()) { if checker.enabled(diagnostic.kind.rule()) {
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
return true; return true;
@ -642,7 +642,7 @@ fn superfluous_else_node(checker: &mut Checker, stmt: &Stmt, branch: Branch) ->
SuperfluousElseBreak { branch }, SuperfluousElseBreak { branch },
elif_else_range(stmt, checker.locator).unwrap_or_else(|| stmt.range()), elif_else_range(stmt, checker.locator).unwrap_or_else(|| stmt.range()),
); );
if checker.settings.rules.enabled(diagnostic.kind.rule()) { if checker.enabled(diagnostic.kind.rule()) {
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
return true; return true;
@ -651,7 +651,7 @@ fn superfluous_else_node(checker: &mut Checker, stmt: &Stmt, branch: Branch) ->
SuperfluousElseRaise { branch }, SuperfluousElseRaise { branch },
elif_else_range(stmt, checker.locator).unwrap_or_else(|| stmt.range()), elif_else_range(stmt, checker.locator).unwrap_or_else(|| stmt.range()),
); );
if checker.settings.rules.enabled(diagnostic.kind.rule()) { if checker.enabled(diagnostic.kind.rule()) {
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
return true; return true;
@ -660,7 +660,7 @@ fn superfluous_else_node(checker: &mut Checker, stmt: &Stmt, branch: Branch) ->
SuperfluousElseContinue { branch }, SuperfluousElseContinue { branch },
elif_else_range(stmt, checker.locator).unwrap_or_else(|| stmt.range()), elif_else_range(stmt, checker.locator).unwrap_or_else(|| stmt.range()),
); );
if checker.settings.rules.enabled(diagnostic.kind.rule()) { if checker.enabled(diagnostic.kind.rule()) {
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
return true; return true;
@ -727,14 +727,14 @@ pub(crate) fn function(checker: &mut Checker, body: &[Stmt], returns: Option<&Ex
// If we have at least one non-`None` return... // If we have at least one non-`None` return...
if result_exists(&stack.returns) { if result_exists(&stack.returns) {
if checker.settings.rules.enabled(Rule::ImplicitReturnValue) { if checker.enabled(Rule::ImplicitReturnValue) {
implicit_return_value(checker, &stack); implicit_return_value(checker, &stack);
} }
if checker.settings.rules.enabled(Rule::ImplicitReturn) { if checker.enabled(Rule::ImplicitReturn) {
implicit_return(checker, last_stmt); implicit_return(checker, last_stmt);
} }
if checker.settings.rules.enabled(Rule::UnnecessaryAssign) { if checker.enabled(Rule::UnnecessaryAssign) {
for (_, expr) in &stack.returns { for (_, expr) in &stack.returns {
if let Some(expr) = expr { if let Some(expr) = expr {
unnecessary_assign(checker, &stack, expr); unnecessary_assign(checker, &stack, expr);
@ -742,7 +742,7 @@ pub(crate) fn function(checker: &mut Checker, body: &[Stmt], returns: Option<&Ex
} }
} }
} else { } else {
if checker.settings.rules.enabled(Rule::UnnecessaryReturnNone) { if checker.enabled(Rule::UnnecessaryReturnNone) {
// Skip functions that have a return annotation that is not `None`. // Skip functions that have a return annotation that is not `None`.
if returns.map_or(true, is_const_none) { if returns.map_or(true, is_const_none) {
unnecessary_return_none(checker, &stack); unnecessary_return_none(checker, &stack);

View File

@ -213,7 +213,7 @@ pub(crate) fn convert_for_loop_to_any_all(
.or_else(|| sibling.and_then(|sibling| return_values_for_siblings(stmt, sibling))) .or_else(|| sibling.and_then(|sibling| return_values_for_siblings(stmt, sibling)))
{ {
if loop_info.return_value && !loop_info.next_return_value { if loop_info.return_value && !loop_info.next_return_value {
if checker.settings.rules.enabled(Rule::ReimplementedBuiltin) { if checker.enabled(Rule::ReimplementedBuiltin) {
let contents = return_stmt( let contents = return_stmt(
"any", "any",
loop_info.test, loop_info.test,
@ -253,7 +253,7 @@ pub(crate) fn convert_for_loop_to_any_all(
} }
if !loop_info.return_value && loop_info.next_return_value { if !loop_info.return_value && loop_info.next_return_value {
if checker.settings.rules.enabled(Rule::ReimplementedBuiltin) { if checker.enabled(Rule::ReimplementedBuiltin) {
// Invert the condition. // Invert the condition.
let test = { let test = {
if let Expr::UnaryOp(ast::ExprUnaryOp { if let Expr::UnaryOp(ast::ExprUnaryOp {

View File

@ -300,10 +300,7 @@ pub(crate) fn unused_arguments(
&checker.settings.pep8_naming.staticmethod_decorators, &checker.settings.pep8_naming.staticmethod_decorators,
) { ) {
FunctionType::Function => { FunctionType::Function => {
if checker if checker.enabled(Argumentable::Function.rule_code())
.settings
.rules
.enabled(Argumentable::Function.rule_code())
&& !visibility::is_overload(checker.semantic_model(), decorator_list) && !visibility::is_overload(checker.semantic_model(), decorator_list)
{ {
function( function(
@ -322,10 +319,7 @@ pub(crate) fn unused_arguments(
} }
} }
FunctionType::Method => { FunctionType::Method => {
if checker if checker.enabled(Argumentable::Method.rule_code())
.settings
.rules
.enabled(Argumentable::Method.rule_code())
&& !helpers::is_empty(body) && !helpers::is_empty(body)
&& (!visibility::is_magic(name) && (!visibility::is_magic(name)
|| visibility::is_init(name) || visibility::is_init(name)
@ -351,10 +345,7 @@ pub(crate) fn unused_arguments(
} }
} }
FunctionType::ClassMethod => { FunctionType::ClassMethod => {
if checker if checker.enabled(Argumentable::ClassMethod.rule_code())
.settings
.rules
.enabled(Argumentable::ClassMethod.rule_code())
&& !helpers::is_empty(body) && !helpers::is_empty(body)
&& (!visibility::is_magic(name) && (!visibility::is_magic(name)
|| visibility::is_init(name) || visibility::is_init(name)
@ -380,10 +371,7 @@ pub(crate) fn unused_arguments(
} }
} }
FunctionType::StaticMethod => { FunctionType::StaticMethod => {
if checker if checker.enabled(Argumentable::StaticMethod.rule_code())
.settings
.rules
.enabled(Argumentable::StaticMethod.rule_code())
&& !helpers::is_empty(body) && !helpers::is_empty(body)
&& (!visibility::is_magic(name) && (!visibility::is_magic(name)
|| visibility::is_init(name) || visibility::is_init(name)
@ -411,11 +399,7 @@ pub(crate) fn unused_arguments(
} }
} }
ScopeKind::Lambda(Lambda { args, .. }) => { ScopeKind::Lambda(Lambda { args, .. }) => {
if checker if checker.enabled(Argumentable::Lambda.rule_code()) {
.settings
.rules
.enabled(Argumentable::Lambda.rule_code())
{
function( function(
Argumentable::Lambda, Argumentable::Lambda,
args, args,

View File

@ -52,7 +52,7 @@ pub(crate) fn replaceable_by_pathlib(checker: &mut Checker, expr: &Expr) {
{ {
let diagnostic = Diagnostic::new::<DiagnosticKind>(diagnostic_kind, expr.range()); let diagnostic = Diagnostic::new::<DiagnosticKind>(diagnostic_kind, expr.range());
if checker.settings.rules.enabled(diagnostic.kind.rule()) { if checker.enabled(diagnostic.kind.rule()) {
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
} }

View File

@ -68,11 +68,7 @@ pub(crate) fn blank_before_after_class(checker: &mut Checker, docstring: &Docstr
return; return;
}; };
if checker if checker.enabled(Rule::OneBlankLineBeforeClass) || checker.enabled(Rule::BlankLineBeforeClass)
.settings
.rules
.enabled(Rule::OneBlankLineBeforeClass)
|| checker.settings.rules.enabled(Rule::BlankLineBeforeClass)
{ {
let before = checker let before = checker
.locator .locator
@ -91,7 +87,7 @@ pub(crate) fn blank_before_after_class(checker: &mut Checker, docstring: &Docstr
} }
} }
if checker.settings.rules.enabled(Rule::BlankLineBeforeClass) { if checker.enabled(Rule::BlankLineBeforeClass) {
if blank_lines_before != 0 { if blank_lines_before != 0 {
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
BlankLineBeforeClass { BlankLineBeforeClass {
@ -110,11 +106,7 @@ pub(crate) fn blank_before_after_class(checker: &mut Checker, docstring: &Docstr
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
} }
if checker if checker.enabled(Rule::OneBlankLineBeforeClass) {
.settings
.rules
.enabled(Rule::OneBlankLineBeforeClass)
{
if blank_lines_before != 1 { if blank_lines_before != 1 {
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
OneBlankLineBeforeClass { OneBlankLineBeforeClass {
@ -136,7 +128,7 @@ pub(crate) fn blank_before_after_class(checker: &mut Checker, docstring: &Docstr
} }
} }
if checker.settings.rules.enabled(Rule::OneBlankLineAfterClass) { if checker.enabled(Rule::OneBlankLineAfterClass) {
let after = checker let after = checker
.locator .locator
.slice(TextRange::new(docstring.end(), stmt.end())); .slice(TextRange::new(docstring.end(), stmt.end()));

View File

@ -59,11 +59,7 @@ pub(crate) fn blank_before_after_function(checker: &mut Checker, docstring: &Doc
return; return;
}; };
if checker if checker.enabled(Rule::NoBlankLineBeforeFunction) {
.settings
.rules
.enabled(Rule::NoBlankLineBeforeFunction)
{
let before = checker let before = checker
.locator .locator
.slice(TextRange::new(stmt.start(), docstring.start())); .slice(TextRange::new(stmt.start(), docstring.start()));
@ -100,11 +96,7 @@ pub(crate) fn blank_before_after_function(checker: &mut Checker, docstring: &Doc
} }
} }
if checker if checker.enabled(Rule::NoBlankLineAfterFunction) {
.settings
.rules
.enabled(Rule::NoBlankLineAfterFunction)
{
let after = checker let after = checker
.locator .locator
.slice(TextRange::new(docstring.end(), stmt.end())); .slice(TextRange::new(docstring.end(), stmt.end()));

View File

@ -82,7 +82,7 @@ pub(crate) fn indent(checker: &mut Checker, docstring: &Docstring) {
// yet. // yet.
has_seen_tab = has_seen_tab || line_indent.contains('\t'); has_seen_tab = has_seen_tab || line_indent.contains('\t');
if checker.settings.rules.enabled(Rule::UnderIndentation) { if checker.enabled(Rule::UnderIndentation) {
// We report under-indentation on every line. This isn't great, but enables // We report under-indentation on every line. This isn't great, but enables
// autofix. // autofix.
if (i == lines.len() - 1 || !is_blank) if (i == lines.len() - 1 || !is_blank)
@ -116,7 +116,7 @@ pub(crate) fn indent(checker: &mut Checker, docstring: &Docstring) {
} }
} }
if checker.settings.rules.enabled(Rule::IndentWithSpaces) { if checker.enabled(Rule::IndentWithSpaces) {
if has_seen_tab { if has_seen_tab {
checker checker
.diagnostics .diagnostics
@ -124,7 +124,7 @@ pub(crate) fn indent(checker: &mut Checker, docstring: &Docstring) {
} }
} }
if checker.settings.rules.enabled(Rule::OverIndentation) { if checker.enabled(Rule::OverIndentation) {
// If every line (except the last) is over-indented... // If every line (except the last) is over-indented...
if is_over_indented { if is_over_indented {
for over_indented in over_indented_lines { for over_indented in over_indented_lines {

View File

@ -60,11 +60,7 @@ pub(crate) fn multi_line_summary_start(checker: &mut Checker, docstring: &Docstr
}; };
if is_triple_quote(&first_line) { if is_triple_quote(&first_line) {
if checker if checker.enabled(Rule::MultiLineSummaryFirstLine) {
.settings
.rules
.enabled(Rule::MultiLineSummaryFirstLine)
{
let mut diagnostic = Diagnostic::new(MultiLineSummaryFirstLine, docstring.range()); let mut diagnostic = Diagnostic::new(MultiLineSummaryFirstLine, docstring.range());
if checker.patch(diagnostic.kind.rule()) { if checker.patch(diagnostic.kind.rule()) {
// Delete until first non-whitespace char. // Delete until first non-whitespace char.
@ -82,11 +78,7 @@ pub(crate) fn multi_line_summary_start(checker: &mut Checker, docstring: &Docstr
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
} else { } else {
if checker if checker.enabled(Rule::MultiLineSummarySecondLine) {
.settings
.rules
.enabled(Rule::MultiLineSummarySecondLine)
{
let mut diagnostic = Diagnostic::new(MultiLineSummarySecondLine, docstring.range()); let mut diagnostic = Diagnostic::new(MultiLineSummarySecondLine, docstring.range());
if checker.patch(diagnostic.kind.rule()) { if checker.patch(diagnostic.kind.rule()) {
let mut indentation = String::from(docstring.indentation); let mut indentation = String::from(docstring.indentation);

View File

@ -21,7 +21,7 @@ pub(crate) fn not_empty(checker: &mut Checker, docstring: &Docstring) -> bool {
return true; return true;
} }
if checker.settings.rules.enabled(Rule::EmptyDocstring) { if checker.enabled(Rule::EmptyDocstring) {
checker checker
.diagnostics .diagnostics
.push(Diagnostic::new(EmptyDocstring, docstring.range())); .push(Diagnostic::new(EmptyDocstring, docstring.range()));

View File

@ -107,11 +107,7 @@ pub(crate) fn not_missing(
kind: ModuleKind::Module, kind: ModuleKind::Module,
.. ..
}) => { }) => {
if checker if checker.enabled(Rule::UndocumentedPublicModule) {
.settings
.rules
.enabled(Rule::UndocumentedPublicModule)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
UndocumentedPublicModule, UndocumentedPublicModule,
TextRange::default(), TextRange::default(),
@ -123,11 +119,7 @@ pub(crate) fn not_missing(
kind: ModuleKind::Package, kind: ModuleKind::Package,
.. ..
}) => { }) => {
if checker if checker.enabled(Rule::UndocumentedPublicPackage) {
.settings
.rules
.enabled(Rule::UndocumentedPublicPackage)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
UndocumentedPublicPackage, UndocumentedPublicPackage,
TextRange::default(), TextRange::default(),
@ -140,11 +132,7 @@ pub(crate) fn not_missing(
stmt, stmt,
.. ..
}) => { }) => {
if checker if checker.enabled(Rule::UndocumentedPublicClass) {
.settings
.rules
.enabled(Rule::UndocumentedPublicClass)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
UndocumentedPublicClass, UndocumentedPublicClass,
identifier_range(stmt, checker.locator), identifier_range(stmt, checker.locator),
@ -157,11 +145,7 @@ pub(crate) fn not_missing(
stmt, stmt,
.. ..
}) => { }) => {
if checker if checker.enabled(Rule::UndocumentedPublicNestedClass) {
.settings
.rules
.enabled(Rule::UndocumentedPublicNestedClass)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
UndocumentedPublicNestedClass, UndocumentedPublicNestedClass,
identifier_range(stmt, checker.locator), identifier_range(stmt, checker.locator),
@ -177,11 +161,7 @@ pub(crate) fn not_missing(
if is_overload(checker.semantic_model(), cast::decorator_list(stmt)) { if is_overload(checker.semantic_model(), cast::decorator_list(stmt)) {
true true
} else { } else {
if checker if checker.enabled(Rule::UndocumentedPublicFunction) {
.settings
.rules
.enabled(Rule::UndocumentedPublicFunction)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
UndocumentedPublicFunction, UndocumentedPublicFunction,
identifier_range(stmt, checker.locator), identifier_range(stmt, checker.locator),
@ -200,7 +180,7 @@ pub(crate) fn not_missing(
{ {
true true
} else if is_init(cast::name(stmt)) { } else if is_init(cast::name(stmt)) {
if checker.settings.rules.enabled(Rule::UndocumentedPublicInit) { if checker.enabled(Rule::UndocumentedPublicInit) {
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
UndocumentedPublicInit, UndocumentedPublicInit,
identifier_range(stmt, checker.locator), identifier_range(stmt, checker.locator),
@ -208,11 +188,7 @@ pub(crate) fn not_missing(
} }
true true
} else if is_new(cast::name(stmt)) || is_call(cast::name(stmt)) { } else if is_new(cast::name(stmt)) || is_call(cast::name(stmt)) {
if checker if checker.enabled(Rule::UndocumentedPublicMethod) {
.settings
.rules
.enabled(Rule::UndocumentedPublicMethod)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
UndocumentedPublicMethod, UndocumentedPublicMethod,
identifier_range(stmt, checker.locator), identifier_range(stmt, checker.locator),
@ -220,11 +196,7 @@ pub(crate) fn not_missing(
} }
true true
} else if is_magic(cast::name(stmt)) { } else if is_magic(cast::name(stmt)) {
if checker if checker.enabled(Rule::UndocumentedMagicMethod) {
.settings
.rules
.enabled(Rule::UndocumentedMagicMethod)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
UndocumentedMagicMethod, UndocumentedMagicMethod,
identifier_range(stmt, checker.locator), identifier_range(stmt, checker.locator),
@ -232,11 +204,7 @@ pub(crate) fn not_missing(
} }
true true
} else { } else {
if checker if checker.enabled(Rule::UndocumentedPublicMethod) {
.settings
.rules
.enabled(Rule::UndocumentedPublicMethod)
{
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
UndocumentedPublicMethod, UndocumentedPublicMethod,
identifier_range(stmt, checker.locator), identifier_range(stmt, checker.locator),

View File

@ -363,11 +363,7 @@ fn blanks_and_section_underline(
if dash_line_found { if dash_line_found {
if blank_lines_after_header > 0 { if blank_lines_after_header > 0 {
if checker if checker.enabled(Rule::SectionUnderlineAfterName) {
.settings
.rules
.enabled(Rule::SectionUnderlineAfterName)
{
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
SectionUnderlineAfterName { SectionUnderlineAfterName {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -392,11 +388,7 @@ fn blanks_and_section_underline(
.count() .count()
!= context.section_name().len() != context.section_name().len()
{ {
if checker if checker.enabled(Rule::SectionUnderlineMatchesSectionLength) {
.settings
.rules
.enabled(Rule::SectionUnderlineMatchesSectionLength)
{
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
SectionUnderlineMatchesSectionLength { SectionUnderlineMatchesSectionLength {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -422,11 +414,7 @@ fn blanks_and_section_underline(
} }
} }
if checker if checker.enabled(Rule::SectionUnderlineNotOverIndented) {
.settings
.rules
.enabled(Rule::SectionUnderlineNotOverIndented)
{
let leading_space = whitespace::leading_space(&non_blank_line); let leading_space = whitespace::leading_space(&non_blank_line);
if leading_space.len() > docstring.indentation.len() { if leading_space.len() > docstring.indentation.len() {
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
@ -465,7 +453,7 @@ fn blanks_and_section_underline(
} }
if following_lines.peek().is_none() { if following_lines.peek().is_none() {
if checker.settings.rules.enabled(Rule::EmptyDocstringSection) { if checker.enabled(Rule::EmptyDocstringSection) {
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
EmptyDocstringSection { EmptyDocstringSection {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -473,11 +461,7 @@ fn blanks_and_section_underline(
docstring.range(), docstring.range(),
)); ));
} }
} else if checker } else if checker.enabled(Rule::BlankLinesBetweenHeaderAndContent) {
.settings
.rules
.enabled(Rule::BlankLinesBetweenHeaderAndContent)
{
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
BlankLinesBetweenHeaderAndContent { BlankLinesBetweenHeaderAndContent {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -496,7 +480,7 @@ fn blanks_and_section_underline(
} }
} }
} else { } else {
if checker.settings.rules.enabled(Rule::EmptyDocstringSection) { if checker.enabled(Rule::EmptyDocstringSection) {
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
EmptyDocstringSection { EmptyDocstringSection {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -506,11 +490,7 @@ fn blanks_and_section_underline(
} }
} }
} else { } else {
if checker if checker.enabled(Rule::DashedUnderlineAfterSection) {
.settings
.rules
.enabled(Rule::DashedUnderlineAfterSection)
{
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
DashedUnderlineAfterSection { DashedUnderlineAfterSection {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -534,11 +514,7 @@ fn blanks_and_section_underline(
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
if blank_lines_after_header > 0 { if blank_lines_after_header > 0 {
if checker if checker.enabled(Rule::BlankLinesBetweenHeaderAndContent) {
.settings
.rules
.enabled(Rule::BlankLinesBetweenHeaderAndContent)
{
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
BlankLinesBetweenHeaderAndContent { BlankLinesBetweenHeaderAndContent {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -559,11 +535,7 @@ fn blanks_and_section_underline(
} }
// Nothing but blank lines after the section header. // Nothing but blank lines after the section header.
else { else {
if checker if checker.enabled(Rule::DashedUnderlineAfterSection) {
.settings
.rules
.enabled(Rule::DashedUnderlineAfterSection)
{
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
DashedUnderlineAfterSection { DashedUnderlineAfterSection {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -587,7 +559,7 @@ fn blanks_and_section_underline(
} }
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
if checker.settings.rules.enabled(Rule::EmptyDocstringSection) { if checker.enabled(Rule::EmptyDocstringSection) {
checker.diagnostics.push(Diagnostic::new( checker.diagnostics.push(Diagnostic::new(
EmptyDocstringSection { EmptyDocstringSection {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -604,7 +576,7 @@ fn common_section(
context: &SectionContext, context: &SectionContext,
next: Option<&SectionContext>, next: Option<&SectionContext>,
) { ) {
if checker.settings.rules.enabled(Rule::CapitalizeSectionName) { if checker.enabled(Rule::CapitalizeSectionName) {
let capitalized_section_name = context.kind().as_str(); let capitalized_section_name = context.kind().as_str();
if context.section_name() != capitalized_section_name { if context.section_name() != capitalized_section_name {
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
@ -627,7 +599,7 @@ fn common_section(
} }
} }
if checker.settings.rules.enabled(Rule::SectionNotOverIndented) { if checker.enabled(Rule::SectionNotOverIndented) {
let leading_space = whitespace::leading_space(context.summary_line()); let leading_space = whitespace::leading_space(context.summary_line());
if leading_space.len() > docstring.indentation.len() { if leading_space.len() > docstring.indentation.len() {
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
@ -656,11 +628,7 @@ fn common_section(
let last_line = context.following_lines().last(); let last_line = context.following_lines().last();
if last_line.map_or(true, |line| !line.trim().is_empty()) { if last_line.map_or(true, |line| !line.trim().is_empty()) {
if let Some(next) = next { if let Some(next) = next {
if checker if checker.enabled(Rule::NoBlankLineAfterSection) {
.settings
.rules
.enabled(Rule::NoBlankLineAfterSection)
{
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
NoBlankLineAfterSection { NoBlankLineAfterSection {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -678,11 +646,7 @@ fn common_section(
checker.diagnostics.push(diagnostic); checker.diagnostics.push(diagnostic);
} }
} else { } else {
if checker if checker.enabled(Rule::BlankLineAfterLastSection) {
.settings
.rules
.enabled(Rule::BlankLineAfterLastSection)
{
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
BlankLineAfterLastSection { BlankLineAfterLastSection {
name: context.section_name().to_string(), name: context.section_name().to_string(),
@ -702,11 +666,7 @@ fn common_section(
} }
} }
if checker if checker.enabled(Rule::NoBlankLineBeforeSection) {
.settings
.rules
.enabled(Rule::NoBlankLineBeforeSection)
{
if !context.previous_line().map_or(false, str::is_empty) { if !context.previous_line().map_or(false, str::is_empty) {
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
NoBlankLineBeforeSection { NoBlankLineBeforeSection {
@ -904,11 +864,7 @@ fn numpy_section(
) { ) {
common_section(checker, docstring, context, next); common_section(checker, docstring, context, next);
if checker if checker.enabled(Rule::NewLineAfterSectionName) {
.settings
.rules
.enabled(Rule::NewLineAfterSectionName)
{
let suffix = context.summary_after_section_name(); let suffix = context.summary_after_section_name();
if !suffix.is_empty() { if !suffix.is_empty() {
@ -931,7 +887,7 @@ fn numpy_section(
} }
} }
if checker.settings.rules.enabled(Rule::UndocumentedParam) { if checker.enabled(Rule::UndocumentedParam) {
if matches!(context.kind(), SectionKind::Parameters) { if matches!(context.kind(), SectionKind::Parameters) {
parameters_section(checker, docstring, context); parameters_section(checker, docstring, context);
} }
@ -946,7 +902,7 @@ fn google_section(
) { ) {
common_section(checker, docstring, context, next); common_section(checker, docstring, context, next);
if checker.settings.rules.enabled(Rule::SectionNameEndsInColon) { if checker.enabled(Rule::SectionNameEndsInColon) {
let suffix = context.summary_after_section_name(); let suffix = context.summary_after_section_name();
if suffix != ":" { if suffix != ":" {
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
@ -990,7 +946,7 @@ fn parse_google_sections(
google_section(checker, docstring, &context, iterator.peek()); google_section(checker, docstring, &context, iterator.peek());
} }
if checker.settings.rules.enabled(Rule::UndocumentedParam) { if checker.enabled(Rule::UndocumentedParam) {
let mut has_args = false; let mut has_args = false;
let mut documented_args: FxHashSet<String> = FxHashSet::default(); let mut documented_args: FxHashSet<String> = FxHashSet::default();
for section_context in section_contexts { for section_context in section_contexts {

View File

@ -96,11 +96,7 @@ pub(crate) fn repeated_keys(checker: &mut Checker, keys: &[Option<Expr>], values
if let Some(seen_values) = seen.get_mut(&dict_key) { if let Some(seen_values) = seen.get_mut(&dict_key) {
match dict_key { match dict_key {
DictionaryKey::Constant(..) => { DictionaryKey::Constant(..) => {
if checker if checker.enabled(Rule::MultiValueRepeatedKeyLiteral) {
.settings
.rules
.enabled(Rule::MultiValueRepeatedKeyLiteral)
{
let comparable_value: ComparableExpr = (&values[i]).into(); let comparable_value: ComparableExpr = (&values[i]).into();
let is_duplicate_value = seen_values.contains(&comparable_value); let is_duplicate_value = seen_values.contains(&comparable_value);
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(
@ -125,11 +121,7 @@ pub(crate) fn repeated_keys(checker: &mut Checker, keys: &[Option<Expr>], values
} }
} }
DictionaryKey::Variable(dict_key) => { DictionaryKey::Variable(dict_key) => {
if checker if checker.enabled(Rule::MultiValueRepeatedKeyVariable) {
.settings
.rules
.enabled(Rule::MultiValueRepeatedKeyVariable)
{
let comparable_value: ComparableExpr = (&values[i]).into(); let comparable_value: ComparableExpr = (&values[i]).into();
let is_duplicate_value = seen_values.contains(&comparable_value); let is_duplicate_value = seen_values.contains(&comparable_value);
let mut diagnostic = Diagnostic::new( let mut diagnostic = Diagnostic::new(

View File

@ -124,7 +124,7 @@ pub(crate) fn logging_call(
let message_args = call_args.args.len() - 1; let message_args = call_args.args.len() - 1;
if checker.settings.rules.enabled(Rule::LoggingTooManyArgs) { if checker.enabled(Rule::LoggingTooManyArgs) {
if summary.num_positional < message_args { if summary.num_positional < message_args {
checker checker
.diagnostics .diagnostics
@ -132,7 +132,7 @@ pub(crate) fn logging_call(
} }
} }
if checker.settings.rules.enabled(Rule::LoggingTooFewArgs) { if checker.enabled(Rule::LoggingTooFewArgs) {
if message_args > 0 if message_args > 0
&& call_args.kwargs.is_empty() && call_args.kwargs.is_empty()
&& summary.num_positional > message_args && summary.num_positional > message_args