Elseif else cc4m_logo_inline

IDSTAT-24
TitleEvery if that has an elseif section shall have an else section.
PriorityStrongly recommended
Severity level4
DescriptionEvery if with an elseif section shall have an else section, even if it does not contain executable code.
RationaleBy including an else section, default execution paths are not overlooked. Additionally, code coverage can be accurately reported because without else, it is unclear whether it is ever the case that neither the if nor the elseif conditions are true.

Avoid:

if x > 0
    y = 10;
elseif x == 0
    y = 0;
end

Instead use:

if x > 0
    y = 10;
elseif x == 0
    y = 0;
else
    y = -1;
end