-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(DefaultComesLast)[#289]: duplicate case fix #295
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for taking this on! I have a slight worry about the test case, and with that the logic that we have now. Would you agree we need to assert a different outcome @delanym ?
src/test/java/org/openrewrite/staticanalysis/DefaultComesLastTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fell free to leverage operator first speaking api
@@ -75,7 +75,7 @@ public J.Switch visitSwitch(J.Switch switch_, P p) { | |||
aCase.getStatements().isEmpty() && !foundNonEmptyCase) { | |||
casesGroupedWithDefault.add(aCase); | |||
} else { | |||
if (defaultCase != null && defaultCase.getStatements().isEmpty() && !foundNonEmptyCase) { | |||
if (defaultCase != null && defaultCase.getStatements().isEmpty() && foundNonEmptyCase) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (defaultCase != null && defaultCase.getStatements().isEmpty() && foundNonEmptyCase) { | |
if (nonNull(defaultCase) && isEmpty(defaultCase.getStatements()) && foundNonEmptyCase) { |
https://stackoverflow.com/questions/28140193/purpose-of-objects-isnull-objects-nonnull
https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/CollectionUtils.html#isEmpty(java.util.Collection)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/java/org/openrewrite/staticanalysis/ChainStringBuilderAppendCalls.java
- lines 36-38
What's changed?
Fix for DefaultComesLast recipe creates duplicate case #289
What's your motivation?
Bug fix