Home
IF statements should not be nested too deeply
Rule description
- IF statements should not be nested too deeply
Non-compliant Code Example
function string TestFunctionCall (string cnt) IF x > 1 THEN IF x > 2 THEN IF x > 3 THEN IF x > 4 THEN //Non Compliant Code (Nested loop should be less then 4) IF x > 5 THEN //Non Compliant Code (Nested loop should be less then 4) cnt = "x > 5" END IF; END IF; END IF; END IF; END IF; return cnt end function
Compliant Code Example
function string TestFunctionCall2 (string cnt) IF x > 1 THEN IF x > 2 THEN cnt = "x > 2" END IF; IF x > 3 THEN cnt = "x > 3" END IF; IF x > 4 THEN cnt = "x > 4" END IF; IF x > 5 THEN cnt = "x > 5" END IF; END IF; return cnt end function