Home

GOTO statements should not be used

Rule description

  • GOTO statements should not be used

 

Non-compliant Code Example

function string TestFunctionCall (int cnt)

integer A = 1, B = 1
DO WHILE A <= 15
      goto restart; //Non compliant code
      A = (A + 1) * B
LOOP

messagebox('Test','testing... ')

restart: 
if isvalid(cnt) and not isnull( cnt ) then
	messagebox('Test','is valid found ')
end if

return "

end function
function string TestFunctionCall (string cnt)

smallint @count  
	
if cnt < 1 then
	messagebox('Test','is less than 1 found ')
	goto restart //Non compliant code
end if

messagebox('Test','select at least ')
@count = 1 

restart: 
if isvalid(cnt) and not isnull( cnt ) then
	messagebox('Test','is valid found ')
end if

return cnt

end function
Visual Expert 2020
 VEPBRULE43