mirror of
https://github.com/astral-sh/ruff
synced 2026-01-20 21:10:48 -05:00
Avoid incrementing McCabe complexity for class methods (#857)
This commit is contained in:
@@ -46,7 +46,6 @@ fn get_complexity_number(stmts: &[Stmt]) -> usize {
|
||||
complexity += get_complexity_number(body);
|
||||
}
|
||||
StmtKind::ClassDef { body, .. } => {
|
||||
complexity += 1;
|
||||
complexity += get_complexity_number(body);
|
||||
}
|
||||
_ => {}
|
||||
|
||||
@@ -164,7 +164,84 @@ expression: checks
|
||||
row: 107
|
||||
column: 0
|
||||
end_location:
|
||||
row: 109
|
||||
row: 112
|
||||
column: 0
|
||||
fix: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
- handle
|
||||
- 9
|
||||
location:
|
||||
row: 113
|
||||
column: 4
|
||||
end_location:
|
||||
row: 139
|
||||
column: 0
|
||||
fix: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
- a
|
||||
- 1
|
||||
location:
|
||||
row: 118
|
||||
column: 12
|
||||
end_location:
|
||||
row: 121
|
||||
column: 12
|
||||
fix: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
- b
|
||||
- 2
|
||||
location:
|
||||
row: 121
|
||||
column: 12
|
||||
end_location:
|
||||
row: 125
|
||||
column: 8
|
||||
fix: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
- c
|
||||
- 1
|
||||
location:
|
||||
row: 126
|
||||
column: 12
|
||||
end_location:
|
||||
row: 129
|
||||
column: 12
|
||||
fix: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
- error
|
||||
- 1
|
||||
location:
|
||||
row: 129
|
||||
column: 12
|
||||
end_location:
|
||||
row: 132
|
||||
column: 12
|
||||
fix: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
- info
|
||||
- 1
|
||||
location:
|
||||
row: 132
|
||||
column: 12
|
||||
end_location:
|
||||
row: 135
|
||||
column: 12
|
||||
fix: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
- exception
|
||||
- 1
|
||||
location:
|
||||
row: 135
|
||||
column: 12
|
||||
end_location:
|
||||
row: 138
|
||||
column: 8
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -13,4 +13,15 @@ expression: checks
|
||||
row: 85
|
||||
column: 0
|
||||
fix: ~
|
||||
- kind:
|
||||
FunctionIsTooComplex:
|
||||
- handle
|
||||
- 9
|
||||
location:
|
||||
row: 113
|
||||
column: 4
|
||||
end_location:
|
||||
row: 139
|
||||
column: 0
|
||||
fix: ~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user