Skip to content

Commit

Permalink
Add Apache Commons StringUtils refaster template replacements (#271)
Browse files Browse the repository at this point in the history
* Add Apache Commons StringUtils refaster template replacements

* Add missing import

* Fix import in test

* Fix import in test

* Rename recipe since package already includes Apache Commons

* Show _once_ that static imports work too

* Format fix

* initial commit

* updated tests

* added a couple more tests and recipe

* more tests and recipes

* more recipes, all moved into one class

* updated license headers

* small fix

* Update src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java

Co-authored-by: Tim te Beek <tim@moderne.io>

* made changes from PR feedback

* used `regionMatches()` for `EndsWithIgnoreCase`

* Fix one test, disable another

* Always run all ApacheCommonsStringUtilsRecipes

* fixed old templates, made some new templates and created more tests

* finished adding refaster template classes for all possible methods

* sorted refaster templates alphabetically

* Update src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java

Co-authored-by: Knut Wannheden <knut@moderne.io>

* Update src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java

Co-authored-by: Knut Wannheden <knut@moderne.io>

* Update build.gradle.kts

Co-authored-by: Tim te Beek <tim@moderne.io>

* Update src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java

Co-authored-by: Knut Wannheden <knut@moderne.io>

* null checked all templates

* commented out templates that I am not sure are accurate replacements yet, added new test to cover in future

* Fix uberTest execution and expected values

* Minor fixes to some of the patterns

* Verify there's no change yet in additional cases

* Add parentheses around replacement templates that need it

* Test that input methods are not called twice

* Swap case should also use parentheses

* Fix rules Abbreviate through EqualsIgnoreCase

* Disable inputMethodsNotCalledTwice; tracked separately

* Check Equals through Lowercase

* Fix RemoveEnd

* Fix Replace and Split

* Disable with note broken recipes

* Disable Uncapitalize

* Update build.gradle.kts

---------

Co-authored-by: Tim te Beek <tim@moderne.io>
Co-authored-by: Knut Wannheden <knut@moderne.io>
  • Loading branch information
3 people authored Aug 18, 2023
1 parent 4bfadd2 commit 89b00e6
Show file tree
Hide file tree
Showing 3 changed files with 940 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
implementation("org.openrewrite.gradle.tooling:model:$rewriteVersion")

implementation("commons-io:commons-io:2.+")
implementation("org.apache.commons:commons-lang3:3.+")
implementation("org.codehaus.plexus:plexus-utils:3.+")

runtimeOnly("org.openrewrite:rewrite-java-8")
Expand All @@ -49,7 +50,6 @@ dependencies {
testImplementation("com.google.guava:guava:29.0-jre")

testImplementation("commons-codec:commons-codec:1.+")
testImplementation("org.apache.commons:commons-lang3:3.+")
testImplementation("org.apache.maven.shared:maven-shared-utils:3.+")

testRuntimeOnly("com.fasterxml.jackson.datatype:jackson-datatype-jsr353")
Expand Down
Loading

0 comments on commit 89b00e6

Please sign in to comment.