Unnecessary ELSE
objectscriptQuality release
Id
OS0055
Rule type
Code Smell
Severity
Minor
Minor
SQALE characteristic
- Maintainability
- Understandability
Remediation function
Constant/issue
Remediation cost
10min
Consider this code example:
if (condition) { return value1 } else { do something do somethingElse etc etc }
Since the if block exits unconditionally, the else may be pruned and the code then becomes:
if (condition1) { return value1 } do something do somethingElse etc etc
This rule will only trigger if the number of statements in the else block is greater than or equal to a certain threshold, which is configurable (it is 5 by default).
Parameters
Name | Description | Default value |
---|---|---|
nrElseStatementsThreshold
| Number of statements in ELSE to trigger this rule (inclusive)
| 5
|