A loop with at most one iteration is equivalent to an if
statement. This can confuse developers and make the code less readable since
loops are not meant to replace if
statements.
If the intention was to conditionally execute the block only once, an if
statement should be used instead. Otherwise, the loop should
be fixed so the loop block can be executed multiple times.
A loop statement with at most one iteration can happen when a statement that unconditionally transfers control, such as a jump or throw statement,
is misplaced inside the loop block.
This rule arises when the following statements are misplaced: