Pattern: Uncollapsed if
statement
Issue: -
Reported if
statement can be collapsed - this can reduce nesting and help improve readability. However it should be carefully considered if merging the if statements actually does improve readability or if it hides some edge-cases from the reader.
Example of incorrect code:
val i = 1
if (i > 0) {
if (i < 5) {
println(i)
}
}
Example of correct code:
val i = 1
if (i > 0 && i < 5) {
println(i)
}