Return keyword
ID | STAT-15 |
Title | Minimize the use of return . |
Priority | Recommended |
Severity level | 9 |
Description | Minimize the use of the return keyword. |
Rationale | Using return decreases readability because the end of the function is not always reached. By avoiding the return keyword, the flow of the code remains clear. |
Avoid:
if isempty(x)
return
end
<rest of the code>
Instead use:
if isempty(x)
% No further actions.
else
<rest of the code>
end