Home

Related IF/ELSIF statements and WHEN clauses in a CASE should not have the same condition

Rule description

  • Related IF/ELSIF statements and WHEN clauses in a CASE should not have the same condition

 

Non-compliant Code Example

function string TestFunctionCall (string cnt)

if cnt = 1 then
	cnt = 'A';
elseif cnt = 1 then //Non compliant code (If and ElseIf clause is having same condition)
	cnt = 'B';
else 
	cnt = 'C';
end if

return cnt

end function

Compliant Code Example

function string TestFunctionCall (string cnt)

if cnt = 1 then
	cnt = 'A';
elseif cnt = 2 then //Compliant code
	cnt = 'B';
else 
	cnt = 'C';
end if

return cnt

end function
Visual Expert 2020
 VEPBRULE38