avoid-nested-try-statements
- Group
- Complexity
- Path
lint/complexity/avoid-nested-try-statements- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 104 of 512
Reports deeply nested try statements.
max-nesting (integer, default: 2) limits nesting of this construct.
Local functions and closures restart the nesting count.
Invalid
void handle() {
try {
try { print(1); } catch (_) {}
} catch (_) {}
} try { try { print(1); } catch (_) {}Valid
void handle() {
try { print(1); } catch (_) {}
try { void local() { try { print(2); } catch (_) {} } local(); } catch (_) {}
}Configure avoid-nested-try-statements
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"complexity": {
"avoid-nested-try-statements": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/complexity/avoid-nested-try-statements: <reason>More complexity rules
- 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.
- join-return-with-assignment
join_return_with_assignmentFlags an assignment immediately followed by
returnof the same variable.