Add filter for Kotlin enum classes#1625
Conversation
leveretka
left a comment
There was a problem hiding this comment.
Overall looks good, thanks for fixing it!
I just have a small suggestion to improve readability.
|
|
||
| public void filter(final MethodNode methodNode, | ||
| final IFilterContext context, final IFilterOutput output) { | ||
| if (!"java/lang/Enum".equals(context.getSuperClassName())) { |
There was a problem hiding this comment.
I don't know if this is the convention here, but as a code reader, I'd prefer to see a single if without negations in the conditions to reduce a cognitive load. Since the body of the if is just one line, this is an acceptable level of nesting.
There was a problem hiding this comment.
We don't have a strict convention about this and both styles can be found, but seems that the early-returns style is prevalent:
single if in
early returns in
| new ExhaustiveSwitchFilter(), // | ||
| new RecordPatternFilter(), // | ||
| new AnnotationGeneratedFilter(), new KotlinGeneratedFilter(), | ||
| new KotlinEnumFilter(), // |
There was a problem hiding this comment.
Why do we need a // here?
There was a problem hiding this comment.
Otherwise Eclipse JDT Formatter will join lines and the change will look like
new AnnotationGeneratedFilter(), new KotlinGeneratedFilter(),
- new KotlinLateinitFilter(), new KotlinWhenFilter(),
- new KotlinWhenStringFilter(),
+ new KotlinEnumFilter(), new KotlinLateinitFilter(),
+ new KotlinWhenFilter(), new KotlinWhenStringFilter(),
new KotlinUnsafeCastOperatorFilter(),
Fixes #1557