Home

GOTO statements should not be used

Rule description

  • GOTO statements should not be used

 

Non-compliant Code Example

function integer calculateSteps(integer step)

integer totalSteps = 0

	if step < 0 then
		goto negative //Non compliant code 
	end if

totalSteps = totalSteps + step

negative: 
    totalSteps = 0

return totalSteps

end function

Compliant Code Example

function integer TestFunctionCall (integer step)

boolean	flag = false //Compliant code 

integer totalSteps = 0

if step < 0 then
	flag = true  
end if

IF flag THEN
   totalSteps = 0
ELSE
   totalSteps = totalSteps + step
END IF

return totalSteps

end function
Visual Expert 2020
 VEPBRULE43