-
Is there already a rule that allows you to report else branches in when statements for exhaustive conditions (enums, sealed classes)? I am looking for a way to prevent such behaviour. enum class MyEnum {
ENUM1, ENUM2, ENUM3, ENUM4
} Noncompliant Code:when (type) {
ENUM1 -> // ok
ENUM2 -> // ok
else -> // detekt should report this else
} Compliant Code:when (type) {
ENUM1 -> // ok
ENUM2 -> // ok
ENUM3 -> // ok
ENUM4 -> // ok
} Maybe I am missing a rule that does that? |
Beta Was this translation helpful? Give feedback.
Answered by
cortinico
Mar 10, 2022
Replies: 2 comments 3 replies
-
Yes, it's the |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
G00fY2
-
I actually added this "missing" rule with #4632 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, it's the
RedundantElseInWhen
rule :)