Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
---|---|---|---|---|---|
Code smell |
BSL OS |
Minor |
Yes |
5 |
brainoverload |
Name | Type | Description | Default value |
---|---|---|---|
maxIfConditionComplexity |
Integer |
Acceptable number of logical expressions in operator If condition |
3 |
Complex expressions (with more than 3 boolean constructs) must be extracted to separated method or variable.
Bad:
If Id = "Expr1"
Or Id = "Expr2"
Or Id = "Expr3"
Or Id = "Expr4"
Or Id = "Expr5"
Or Id = "Expr6"
Or Id = "Expr7"
Or Id = "Expr8"
Or Id = "Expr9" Then
doSomeWork();
EndIf;
Good:
If IsCorrectId(Id) Then
doSomeWork();
КонецЕсли;
Function IsCorrectId(Id)
Return Id = "Expr1"
Or Id = "Expr2"
Or Id = "Expr3"
Or Id = "Expr4"
Or Id = "Expr5"
Or Id = "Expr6"
Or Id = "Expr7"
Or Id = "Expr8"
Or Id = "Expr9";
EndFunction
// BSLLS:IfConditionComplexity-off
// BSLLS:IfConditionComplexity-on
"IfConditionComplexity": {
"maxIfConditionComplexity": 3
}