G-4365: Never use unconditional CONTINUE or EXIT in a loop.
Major
Maintainability, Testability
Reason
An unconditional continue
is either redundant (a continue
as the last statement before the end of the loop) or causes dead code. An unconditional exit
causes no looping and may cause dead code as well. If continue
or exit
is needed, it should always have a condition.
Example (bad)
1 2 3 4 5 6 7 8 9 10 11 |
|
Example (good)
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|