Constant conditional statements
ID | STAT-12 |
Title | Do not use conditions like if true and similar. |
Priority | Mandatory |
Severity level | 3 |
Description | Do not use conditions that are always true or always false such as if true or elseif 0 . MATLAB's Code Analyzer warns about some of these cases. |
Rationale | These constructs may cause unreachable code or unintended behaviour. |
Avoid:
if x > 0 || true
disp(x)
end
Instead use:
disp(x)