Home
GOTO should not be used to jump backwards
Rule description
- GOTO should not be used to jump backwards
Non-compliant Code Example
function string TestFunctionCall (int cnt) restart: if cnt > 0 then messagebox('Success','greater than 1 found ') end if smallint @count if cnt < 1 then messagebox('Success','less than 1 found ') goto restart //Non compliant code (As it is jumped backward on restart) end if messagebox('Success','finished test ') @count = 1 return " end function
Compliant Code Example
function string TestFunctionCall (int cnt) smallint @count if cnt < 1 then messagebox('Success','less than 1 found ') goto restart //Compliant code (As it is jumped forward on restart) end if messagebox('Success','finished test ') @count = 1 restart: if isvalid(cnt) and not isnull( cnt ) then messagebox('Success','test is valid ') end if return " end function