Skip to content

Commit

Permalink
Rename function-is-too-complex to complex-structure
Browse files Browse the repository at this point in the history
  • Loading branch information
not-my-profile authored and charliermarsh committed Feb 11, 2023
1 parent 7db6a2d commit 70ff651
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/checkers/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/rules/mccabe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions crates/ruff/src/rules/mccabe/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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})")
}
}
Expand Down Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -15,7 +15,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: expr_as_statement
complexity: 1
location:
Expand All @@ -27,7 +27,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: sequential
complexity: 1
location:
Expand All @@ -39,7 +39,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: if_elif_else_dead_path
complexity: 3
location:
Expand All @@ -51,7 +51,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: nested_ifs
complexity: 3
location:
Expand All @@ -63,7 +63,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: for_loop
complexity: 2
location:
Expand All @@ -75,7 +75,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: for_else
complexity: 2
location:
Expand All @@ -87,7 +87,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: recursive
complexity: 2
location:
Expand All @@ -99,7 +99,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: nested_functions
complexity: 3
location:
Expand All @@ -111,7 +111,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: a
complexity: 2
location:
Expand All @@ -123,7 +123,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: b
complexity: 1
location:
Expand All @@ -135,7 +135,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: try_else
complexity: 4
location:
Expand All @@ -147,7 +147,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: nested_try_finally
complexity: 3
location:
Expand All @@ -159,7 +159,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: foobar
complexity: 3
location:
Expand All @@ -171,7 +171,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: annotated_assign
complexity: 1
location:
Expand All @@ -183,7 +183,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: handle
complexity: 9
location:
Expand All @@ -195,7 +195,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: a
complexity: 1
location:
Expand All @@ -207,7 +207,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: b
complexity: 2
location:
Expand All @@ -219,7 +219,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: c
complexity: 1
location:
Expand All @@ -231,7 +231,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: error
complexity: 1
location:
Expand All @@ -243,7 +243,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: info
complexity: 1
location:
Expand All @@ -255,7 +255,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: exception
complexity: 1
location:
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -15,7 +15,7 @@ expression: diagnostics
fix: ~
parent: ~
- kind:
FunctionIsTooComplex:
ComplexStructure:
name: handle
complexity: 9
location:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# function-is-too-complex (C901)
# complex-structure (C901)

Derived from the **mccabe** linter.

Expand Down

0 comments on commit 70ff651

Please sign in to comment.