Empty Do While
ID |
kotlin.empty_do_while |
Severity |
low |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Kotlin |
Tags |
empty, loop |
Description
Reports do-while loops whose body is empty.
A do { } while (condition) executes its body at least once but performs no work. This is almost always a typo or the result of an incomplete refactoring where the body was accidentally removed.
Rationale
// Bad — empty body, no work done before condition check
do { } while (condition) // FLAW
// Good — non-empty body
do {
process()
} while (condition)
Remediation
Either fill in the missing body, or remove the do-while loop entirely if the block was no longer needed after a refactoring.