Pattern: Loop with too many jump statements
Issue: -
Loops which contain multiple break
or continue
statements are hard to read and understand. To increase readability they should be refactored into simpler loops.
Example of incorrect code:
val strs = listOf("foo, bar")
for (str in strs) {
if (str == "bar") {
break
} else {
continue
}
}