Home
All branches in a conditional structure should not have exactly the same implementation
Rule description
- All branches in a conditional structure should not have exactly the same implementation
Non-compliant Code Example
function string TestFunctionCall (string cnt) if cnt = 1 then cnt = 'B'; elseif cnt = 2 then cnt = 'B'; //Non compliant code (Else if section is having same implementation as below) else cnt = 'B'; //Non compliant code (Else section is having same implementation as above) end if return cnt end function
function int TestFunctionCall() int @count = 1 if aa_value1 < aa_value2 then return @count elseif aa_value1 = aa_value2 then return @count //Non compliant code (Else if section is having same implementation as below) else return @count //Non compliant code (Else section is having same implementation as above) end if end function
Compliant Code Example
function string TestFunctionCall (string cnt)
if cnt = 1 then
cnt = 'B';
else
cnt = 'A'; //Compliant code
end if
return cnt
end function
function int TestFunctionCall()
int @count = 1
int @count1 = 0
if aa_value1 < aa_value2 then
return @count
elseif aa_value1 = aa_value2 then
return @count1 //Compliant code
end if
end function