mirror of https://github.com/astral-sh/ruff
Use `value > max` style in pylint and mccabe messages (#3553)
This commit is contained in:
parent
de1106b95a
commit
9ae9cc9d2f
|
|
@ -50,13 +50,18 @@ use ruff_python_ast::source_code::Locator;
|
|||
pub struct ComplexStructure {
|
||||
pub name: String,
|
||||
pub complexity: usize,
|
||||
pub max_complexity: usize,
|
||||
}
|
||||
|
||||
impl Violation for ComplexStructure {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
let ComplexStructure { name, complexity } = self;
|
||||
format!("`{name}` is too complex ({complexity})")
|
||||
let ComplexStructure {
|
||||
name,
|
||||
complexity,
|
||||
max_complexity,
|
||||
} = self;
|
||||
format!("`{name}` is too complex ({complexity} > {max_complexity})")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -135,6 +140,7 @@ pub fn function_is_too_complex(
|
|||
ComplexStructure {
|
||||
name: name.to_string(),
|
||||
complexity,
|
||||
max_complexity,
|
||||
},
|
||||
identifier_range(stmt, locator),
|
||||
))
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`trivial` is too complex (1)"
|
||||
body: "`trivial` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -17,7 +17,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`expr_as_statement` is too complex (1)"
|
||||
body: "`expr_as_statement` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -30,7 +30,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`sequential` is too complex (1)"
|
||||
body: "`sequential` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -43,7 +43,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`if_elif_else_dead_path` is too complex (3)"
|
||||
body: "`if_elif_else_dead_path` is too complex (3 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -56,7 +56,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`nested_ifs` is too complex (3)"
|
||||
body: "`nested_ifs` is too complex (3 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -69,7 +69,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`for_loop` is too complex (2)"
|
||||
body: "`for_loop` is too complex (2 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -82,7 +82,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`for_else` is too complex (2)"
|
||||
body: "`for_else` is too complex (2 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -95,7 +95,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`recursive` is too complex (2)"
|
||||
body: "`recursive` is too complex (2 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -108,7 +108,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`nested_functions` is too complex (3)"
|
||||
body: "`nested_functions` is too complex (3 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -121,7 +121,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`a` is too complex (2)"
|
||||
body: "`a` is too complex (2 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -134,7 +134,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`b` is too complex (1)"
|
||||
body: "`b` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -147,7 +147,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`try_else` is too complex (4)"
|
||||
body: "`try_else` is too complex (4 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -160,7 +160,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`nested_try_finally` is too complex (1)"
|
||||
body: "`nested_try_finally` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -173,7 +173,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`foobar` is too complex (3)"
|
||||
body: "`foobar` is too complex (3 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -186,7 +186,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`annotated_assign` is too complex (1)"
|
||||
body: "`annotated_assign` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -199,7 +199,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`handle` is too complex (9)"
|
||||
body: "`handle` is too complex (9 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -212,7 +212,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`a` is too complex (1)"
|
||||
body: "`a` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -225,7 +225,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`b` is too complex (2)"
|
||||
body: "`b` is too complex (2 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -238,7 +238,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`c` is too complex (1)"
|
||||
body: "`c` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -251,7 +251,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`error` is too complex (1)"
|
||||
body: "`error` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -264,7 +264,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`info` is too complex (1)"
|
||||
body: "`info` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -277,7 +277,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`exception` is too complex (1)"
|
||||
body: "`exception` is too complex (1 > 0)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`try_else` is too complex (4)"
|
||||
body: "`try_else` is too complex (4 > 3)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -17,7 +17,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: ComplexStructure
|
||||
body: "`handle` is too complex (9)"
|
||||
body: "`handle` is too complex (9 > 3)"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ impl Violation for TooManyArguments {
|
|||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
let TooManyArguments { c_args, max_args } = self;
|
||||
format!("Too many arguments to function call ({c_args}/{max_args})")
|
||||
format!("Too many arguments to function call ({c_args} > {max_args})")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ impl Violation for TooManyBranches {
|
|||
branches,
|
||||
max_branches,
|
||||
} = self;
|
||||
format!("Too many branches ({branches}/{max_branches})")
|
||||
format!("Too many branches ({branches} > {max_branches})")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ impl Violation for TooManyReturnStatements {
|
|||
returns,
|
||||
max_returns,
|
||||
} = self;
|
||||
format!("Too many return statements ({returns}/{max_returns})")
|
||||
format!("Too many return statements ({returns} > {max_returns})")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ impl Violation for TooManyStatements {
|
|||
statements,
|
||||
max_statements,
|
||||
} = self;
|
||||
format!("Too many statements ({statements}/{max_statements})")
|
||||
format!("Too many statements ({statements} > {max_statements})")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: TooManyReturnStatements
|
||||
body: Too many return statements (11/6)
|
||||
body: Too many return statements (11 > 6)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: TooManyBranches
|
||||
body: Too many branches (13/12)
|
||||
body: Too many branches (13 > 12)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: TooManyArguments
|
||||
body: Too many arguments to function call (8/5)
|
||||
body: Too many arguments to function call (8 > 5)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -17,7 +17,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: TooManyArguments
|
||||
body: Too many arguments to function call (6/5)
|
||||
body: Too many arguments to function call (6 > 5)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -30,7 +30,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: TooManyArguments
|
||||
body: Too many arguments to function call (6/5)
|
||||
body: Too many arguments to function call (6 > 5)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: TooManyStatements
|
||||
body: Too many statements (52/50)
|
||||
body: Too many statements (52 > 50)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: TooManyArguments
|
||||
body: Too many arguments to function call (6/4)
|
||||
body: Too many arguments to function call (6 > 4)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -17,7 +17,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: TooManyArguments
|
||||
body: Too many arguments to function call (6/4)
|
||||
body: Too many arguments to function call (6 > 4)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: TooManyArguments
|
||||
body: Too many arguments to function call (6/5)
|
||||
body: Too many arguments to function call (6 > 5)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: TooManyBranches
|
||||
body: Too many branches (2/1)
|
||||
body: Too many branches (2 > 1)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -17,7 +17,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: TooManyBranches
|
||||
body: Too many branches (2/1)
|
||||
body: Too many branches (2 > 1)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: TooManyReturnStatements
|
||||
body: Too many return statements (2/1)
|
||||
body: Too many return statements (2 > 1)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
name: TooManyStatements
|
||||
body: Too many statements (2/1)
|
||||
body: Too many statements (2 > 1)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -17,7 +17,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: TooManyStatements
|
||||
body: Too many statements (3/1)
|
||||
body: Too many statements (3 > 1)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
@ -30,7 +30,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
name: TooManyStatements
|
||||
body: Too many statements (2/1)
|
||||
body: Too many statements (2 > 1)
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
|
|
|
|||
Loading…
Reference in New Issue