Hi! can ktlint detect usages for the `else` branc...
# ktlint
m
Hi! can ktlint detect usages for the
else
branch for
when
that have an enum as subject? i.e. i want to make ktlint recognize
when(someEnum) {else -> … }
- and raise an issue of course
p
Ktlint can recognize any valid kotlin code. But recognizing that someEnum is indeed an enum type variable might not always be possible.
m
so best thing i could to is place a feature reequest because it doesn't exist at the moment?
p
I don't know because you do not describe what you exactly want to achieve. But you can create an issue including examples for it. I will have a look at it at a later time.
m
k
I would only be in favour of having such a warning if the
else
part matches only a small number of cases (e.g. 3 or fewer). If you had an enum with 20 constants, and your
when
clause does something for cases of 2 or 3 of them, and something else for the rest of them, then an
else
part is indeed the right thing to have and there should be no warning.
m
can't that be configurable? i.e. let the user decide if it should be a warnig, and error, or just ignored?
p
I have closed the issue as unplanned because it does not fit the scope of the project. Please see issue for details.
👍 1