avoid-nested-switches
- Group
- Complexity
- Path
lint/complexity/avoid-nested-switches- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 103 of 512
Reports deeply nested switch statements.
max-nesting (integer, default: 1) limits nesting of this construct.
Local functions and closures restart the nesting count.
Invalid
void handle(int x) {
switch (x) { case 0:
switch (x + 1) {
case 1: break;
}
}
} switch (x) { case 0: switch (x + 1) {Valid
void handle(int x) {
switch (x) { case 0: break; }
switch (x) { case 1: break; }
switch (x) { case 2:
void local() { switch (x) { case 3: break; } }
local();
}
}Configure avoid-nested-switches
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"complexity": {
"avoid-nested-switches": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/complexity/avoid-nested-switches: <reason>More complexity rules
- avoid-nested-try-statements
Reports deeply nested try statements.
- avoid-redundant-async
avoid-redundant-asyncrecommendedFlags an
asyncfunction whose body is a singlereturn await ...;. - avoid-unnecessary-containers
avoid_unnecessary_containersrecommendedflutterFlags a
Containerwhose only argument is achild. - avoid-unnecessary-type-assertions
avoid-unnecessary-type-assertionsrecommendedFlags an
ischeck whose result is already guaranteed by the resolved static type. - avoid-unnecessary-type-casts
avoid-unnecessary-type-castsrecommendedFlags an
ascast to the operand's resolved static type. - cascade-invocations
cascade_invocationsFlags consecutive statements that invoke members on the same variable.
- cognitive-complexity
Reports function bodies with excessive nesting-weighted control flow.
- cyclomatic-complexity
cyclomatic_complexityFlags a function whose cyclomatic complexity exceeds the configured threshold.