Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
---|---|---|---|---|---|
Code smell |
BSL OS |
Critical |
Yes |
30 |
badpractice brainoverload |
Name | Type | Description | Default value |
---|---|---|---|
maxAllowedLevel |
Integer |
Max nested level |
4 |
Nested "If, "For", "For Each", "While" and "Try" operators are the key ingredients for creating so-called "spaghetti code".
Such code is hard for reading, refactoring and support.
Wrong
If Something Then // Allowed - level = 1
/* ... */
If Some Then // Allowed - level = 2
/* ... */
For Num = 0 To 10 Do // Allowed - level = 3
/* ... */
If OneMoreCondition Then // Acceptable - level = 4, limit is reached, not yet breached
If SomethingElse Then // Level = 5, Limit is breached
/* ... */
EndIf;
Return;
EndIf;
EndDo;
EndIf;
EndIf;
// BSLLS:NestedStatements-off
// BSLLS:NestedStatements-on
"NestedStatements": {
"maxAllowedLevel": 4
}