avoid-nested-switch-expressions
- Group
- Complexity
- Path
lint/complexity/avoid-nested-switch-expressions- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 102 of 512
Reports deeply nested switch expressions.
max-nesting (integer, default: 1) limits nesting of this construct.
Local functions and closures restart the nesting count.
Invalid
int handle(int x) => switch (x) {
0 => switch (x + 1) { 1 => 2, _ => 3 },
_ => 4,
};int handle(int x) => switch (x) { 0 => switch (x + 1) { 1 => 2, _ => 3 },Valid
int handle(int x) => switch (x) { 0 => 1, _ => 2 };
int independent(int x) => switch (x) { 1 => 2, _ => 3 };Configure avoid-nested-switch-expressions
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"complexity": {
"avoid-nested-switch-expressions": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/complexity/avoid-nested-switch-expressions: <reason>More complexity rules
- avoid-nested-switches
Reports deeply nested switch statements.
- 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.