mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:44:56 +00:00
Rename function-is-too-complex to complex-structure
This commit is contained in:
parent
7db6a2d6d4
commit
70ff65154d
8 changed files with 35 additions and 35 deletions
|
@ -749,7 +749,7 @@ For more, see [mccabe](https://pypi.org/project/mccabe/) on PyPI.
|
|||
|
||||
| Code | Name | Message | Fix |
|
||||
| ---- | ---- | ------- | --- |
|
||||
| C901 | [function-is-too-complex](https://github.com/charliermarsh/ruff/blob/main/docs/rules/function-is-too-complex.md) | `{name}` is too complex ({complexity}) | |
|
||||
| C901 | [complex-structure](https://github.com/charliermarsh/ruff/blob/main/docs/rules/complex-structure.md) | `{name}` is too complex ({complexity}) | |
|
||||
|
||||
### isort (I)
|
||||
|
||||
|
|
|
@ -566,7 +566,7 @@ where
|
|||
flake8_return::rules::function(self, body);
|
||||
}
|
||||
|
||||
if self.settings.rules.enabled(&Rule::FunctionIsTooComplex) {
|
||||
if self.settings.rules.enabled(&Rule::ComplexStructure) {
|
||||
if let Some(diagnostic) = mccabe::rules::function_is_too_complex(
|
||||
stmt,
|
||||
name,
|
||||
|
|
|
@ -203,7 +203,7 @@ ruff_macros::define_rule_mapping!(
|
|||
// flake8-debugger
|
||||
T100 => rules::flake8_debugger::rules::Debugger,
|
||||
// mccabe
|
||||
C901 => rules::mccabe::rules::FunctionIsTooComplex,
|
||||
C901 => rules::mccabe::rules::ComplexStructure,
|
||||
// flake8-tidy-imports
|
||||
TID251 => rules::flake8_tidy_imports::banned_api::BannedApi,
|
||||
TID252 => rules::flake8_tidy_imports::relative_imports::RelativeImports,
|
||||
|
|
|
@ -23,7 +23,7 @@ mod tests {
|
|||
Path::new("mccabe/C901.py"),
|
||||
&Settings {
|
||||
mccabe: super::settings::Settings { max_complexity },
|
||||
..Settings::for_rules(vec![Rule::FunctionIsTooComplex])
|
||||
..Settings::for_rules(vec![Rule::ComplexStructure])
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!(snapshot, diagnostics);
|
||||
|
|
|
@ -44,15 +44,15 @@ define_violation!(
|
|||
/// return 2
|
||||
/// return 1
|
||||
/// ```
|
||||
pub struct FunctionIsTooComplex {
|
||||
pub struct ComplexStructure {
|
||||
pub name: String,
|
||||
pub complexity: usize,
|
||||
}
|
||||
);
|
||||
impl Violation for FunctionIsTooComplex {
|
||||
impl Violation for ComplexStructure {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
let FunctionIsTooComplex { name, complexity } = self;
|
||||
let ComplexStructure { name, complexity } = self;
|
||||
format!("`{name}` is too complex ({complexity})")
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ pub fn function_is_too_complex(
|
|||
let complexity = get_complexity_number(body) + 1;
|
||||
if complexity > max_complexity {
|
||||
Some(Diagnostic::new(
|
||||
FunctionIsTooComplex {
|
||||
ComplexStructure {
|
||||
name: name.to_string(),
|
||||
complexity,
|
||||
},
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
---
|
||||
source: src/rules/mccabe/mod.rs
|
||||
source: crates/ruff/src/rules/mccabe/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: trivial
|
||||
complexity: 1
|
||||
location:
|
||||
|
@ -15,7 +15,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: expr_as_statement
|
||||
complexity: 1
|
||||
location:
|
||||
|
@ -27,7 +27,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: sequential
|
||||
complexity: 1
|
||||
location:
|
||||
|
@ -39,7 +39,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: if_elif_else_dead_path
|
||||
complexity: 3
|
||||
location:
|
||||
|
@ -51,7 +51,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: nested_ifs
|
||||
complexity: 3
|
||||
location:
|
||||
|
@ -63,7 +63,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: for_loop
|
||||
complexity: 2
|
||||
location:
|
||||
|
@ -75,7 +75,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: for_else
|
||||
complexity: 2
|
||||
location:
|
||||
|
@ -87,7 +87,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: recursive
|
||||
complexity: 2
|
||||
location:
|
||||
|
@ -99,7 +99,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: nested_functions
|
||||
complexity: 3
|
||||
location:
|
||||
|
@ -111,7 +111,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: a
|
||||
complexity: 2
|
||||
location:
|
||||
|
@ -123,7 +123,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: b
|
||||
complexity: 1
|
||||
location:
|
||||
|
@ -135,7 +135,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: try_else
|
||||
complexity: 4
|
||||
location:
|
||||
|
@ -147,7 +147,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: nested_try_finally
|
||||
complexity: 3
|
||||
location:
|
||||
|
@ -159,7 +159,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: foobar
|
||||
complexity: 3
|
||||
location:
|
||||
|
@ -171,7 +171,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: annotated_assign
|
||||
complexity: 1
|
||||
location:
|
||||
|
@ -183,7 +183,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: handle
|
||||
complexity: 9
|
||||
location:
|
||||
|
@ -195,7 +195,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: a
|
||||
complexity: 1
|
||||
location:
|
||||
|
@ -207,7 +207,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: b
|
||||
complexity: 2
|
||||
location:
|
||||
|
@ -219,7 +219,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: c
|
||||
complexity: 1
|
||||
location:
|
||||
|
@ -231,7 +231,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: error
|
||||
complexity: 1
|
||||
location:
|
||||
|
@ -243,7 +243,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: info
|
||||
complexity: 1
|
||||
location:
|
||||
|
@ -255,7 +255,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: exception
|
||||
complexity: 1
|
||||
location:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
---
|
||||
source: src/rules/mccabe/mod.rs
|
||||
source: crates/ruff/src/rules/mccabe/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: try_else
|
||||
complexity: 4
|
||||
location:
|
||||
|
@ -15,7 +15,7 @@ expression: diagnostics
|
|||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
ComplexStructure:
|
||||
name: handle
|
||||
complexity: 9
|
||||
location:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# function-is-too-complex (C901)
|
||||
# complex-structure (C901)
|
||||
|
||||
Derived from the **mccabe** linter.
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue