Implicit inspection of $TEST
objectscriptQuality release
Id
OS0067
Rule type
Code Smell
Severity
Critical
Critical
SQALE characteristic
- Maintainability
- Understandability
Remediation function
Constant/issue
Remediation cost
5min
Those two constructs implicitly inspect the value of the $TEST
special variable:
/* * Example 1: set the x variable to 1 if $TEST evaluates to true. * * Note that there are TWO SPACES between IF and the actual statement. */ IF S x = 1 /* * Example 2: set the y variable to 1 if $TEST evaluates to false. * * Note that there are TWO SPACES between ELSE and the actual statement. */ E S y = 1
As you can see, spacing in this case is critical; two spaces and more trigger
an implicit check of $TEST
.
This makes the code hard to read. For clarity reasons and in order to prevent
any confusion, it is preferrable to explicitly inspect $TEST
instead, as in, for instance:
if ($TEST) { set x = 1 } // or if ('$TEST) { set y = 1 }
Exception
This rule will not trigger for ELSE
legacy statements if the
previous statement is a legacy IF
, as in:
if somecondition do ..something() else write "condition not met", !