Why this matters
Makes edge cases visible before they become incidents.
In when/else or default branches, log a warning with the unexpected value to surface silent failures.
Makes edge cases visible before they become incidents.
Side-by-side examples engineers can pattern-match during review.
when (status) {
"ok" -> {}
else -> {}
}when (status) {
"ok" -> {}
else -> logger.warn("unknown_status", mapOf("status" to status))
}else -> {}else -> logger.warn("unexpected", mapOf("v" to v))From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.