-
Notifications
You must be signed in to change notification settings - Fork 83
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
Remove SolrAutoConfiguration
from @SpringBootApplication
exclusions
#577
Conversation
...gBoot_2_7/java/org/openrewrite/java/spring/boot2/RemoveSolrAutoConfigurationExcludeTest.java
Outdated
Show resolved
Hide resolved
} | ||
maybeRemoveImport(SOLR_AUTOCONFIGURATION_FQN); | ||
|
||
return a.withArguments(ListUtils.map(a.getArguments(), it -> { |
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.
@Laurens-W Notice how I'm unconditionally calling ListUtils.map
; that has an optimization in it to not create a new list unless changes are made to the list. That then in turn helps keep our recipe implementation clear of conditionals like the AtomicBoolean you had before, and the if/else checking of values.
if (newInitializer.isEmpty()) { | ||
return null; | ||
} | ||
return maybeAutoFormat(it, as.withAssignment(array.withInitializer(newInitializer)), ctx); |
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.
@Laurens-W This quick method allows you to apply the detected style to a code element, such that you need not worry about carrying over a specific space here or there.
|
||
private boolean isSolrAutoConfigurationClassReference(Expression expr) { | ||
return expr instanceof J.FieldAccess && | ||
TypeUtils.isAssignableTo(SOLR_AUTOCONFIGURATION_FQN, ((J.FieldAccess) expr).getTarget().getType()); |
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.
@Laurens-W A pattern I've seen you use a couple times now is to compare with .equals("SomeString")
. Try to use TypeUtils
where you can for type safe comparisons instead, as that then also handles the FQN case as seen in the added unit test.
@Nested | ||
class NoChange { |
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.
When the number of test cases grows, I like to group them logically for the ones that ought not make any changes. That quickly shows the invariants and makes it logical what to add where.
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 again for implementing most of this! Please go over the changes I made and comments I've left such that the next PR will be even better. :)
Also: always try to hook your new recipe into a larger upgrade where that makes sense. In this case it's a required upgrade for Spring Boot 3: |
What's changed?
Added recipe to specifically remove the
SolrAutoConfiguration
from a@SpringBootApplication
exclusions elementWhat's your motivation?
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
@timtebeek
Have you considered any alternatives or workarounds?
Any additional context
Checklist