Home

Two branches in a conditional structure should not have exactly the same implementation

Rule description

  • Two branches in a conditional structure should not have exactly the same implementation

 

Non-compliant Code Example

function string CallFunctionTest (string cnt)

string str;

if cnt = 1 then
	cnt = 'B';
	str = 'A';
elseif cnt = 2 then
	cnt = 'B'; //Non compliant code (IF clause and ELSEIF clause is having exactly the same implementation )
	str = 'A';
else 
	cnt = 'C';
	str = 'A';
end if

return cnt

end function

Compliant Code Example

function string CallFunctionTest (string cnt)

string str;

if cnt = 1 OR cnt = 2 then //compliant code
	cnt = 'B';
	str = 'A';
else 
	cnt = 'C';
	str = 'A';
end if

return cnt

end function
Visual Expert 2020
 VEPBRULE46