Skip to content

Files

Latest commit

 

History

History
25 lines (16 loc) · 573 Bytes

UnconditionalJumpStatementInLoop.md

File metadata and controls

25 lines (16 loc) · 573 Bytes

Pattern: Unconditional jump statement in loop

Issue: -

Description

Reports loops which contain jump statements that jump regardless of any conditions. This implies that the loop is only executed once and thus could be rewritten without a loop altogether.

Example of incorrect code:

for (i in 1..2) break

Example of correct code:

for (i in 1..2) {
    if (i == 1) break
}

Further Reading