Home
Loops with at most one iteration should be refactored
Rule description
- Loops with at most one iteration should be refactored
Non-compliant Code Example
function integer TestFunctionCall (integer cnt) integer A = 1, B = cnt DO WHILE A <= 15 //Non compliant code (Only one iteration will take place because of EXIT) A = (A + 1) * B; EXIT; LOOP return A end function
Compliant Code Example
function integer TestFunctionCall (integer cnt) integer A = 1, B = cnt DO WHILE A <= 15 //Compliant code A = (A + 1) * B; IF counter > 10 THEN EXIT; ELSE A = B; END IF; LOOP return A end function
function void TestFunctionCall () do while IsValid (lpo_parent) if lpo_parent.TypeOf() <> window! then lpo_parent = lpo_parent.GetParent() else exit end if loop end function