Legacy flow control with no associated statements
objectscriptQuality release
Id
OS0043
Rule type
Code Smell
Severity
Blocker
Blocker
SQALE characteristic
- Reliability
- Logic
Remediation function
Constant/issue
Remediation cost
10min
This check verifies that a legacy flow control statement has at least one associated statement to it.
The trap with legacy flow control statements is that associated statements must be on the same line; the following will actually execute ..something() even though the condition is false:
method m() { set condition = 0 if condition do ..something() // NOT THE SAME STATEMENT!! }
The correct way to write the above is actually:
method m() { set condition = 0 if (condition) { do ..something() } }