-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add Apache Commons StringUtils refaster template replacements #271
Add Apache Commons StringUtils refaster template replacements #271
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.
I have added a first set of review comments.
src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java
Outdated
Show resolved
Hide resolved
…/ApacheCommonsStringUtils.java Co-authored-by: Tim te Beek <tim@moderne.io>
Ok the latest commit has all the changes made based off of the feedback given. |
I am still seeing errors when I run the tests. It tells me that |
You probably need to declare the Refaster template classes as static. |
I have made them all static. I think the issue could be because I have the a local version of |
Meanwhile quite a few fixes have been integrated. I suggest you try with the latest integration build. |
...test/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtilsTest.java
Outdated
Show resolved
Hide resolved
...test/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtilsTest.java
Outdated
Show resolved
Hide resolved
We need a merge of this one to fix the parentheses cases: |
|
||
class Foo { | ||
void test(String s) { | ||
String test = StringUtils.strip(bar()).toString(); |
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.
@knutwannheden A more interesting failure: here I would not want to make a change when the input is a method call itself; I suspect that's harder to fix quickly; would this need changes to JavaTemplateSemanticallyEqual.matchesTemplate
either in the matcher, or in the TemplateMatchResult
? Curious to hear your thoughts, as I have no experience there yet.
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.
A perhaps better troublesome case is when people pass in iterator.next()
; then you definitely don't want that called twice.
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.
What's changed?
Refaster rule recipes to replace Apache Commons StringUtils methods with JDK internals where possible.
What's your motivation?
Fixes #267
Anyone you would like to review specifically?
@timtebeek
Checklist
./gradlew licenseFormat