-
Notifications
You must be signed in to change notification settings - Fork 1
Remove Traits
factory recipe
#16
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
Conversation
Let's add rewrite-rewrite/src/main/resources/META-INF/rewrite/recipebestpractice.yml Lines 44 to 51 in 1e649d1
|
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.
Pull Request Overview
This pull request removes the use of factory methods in centralized Traits classes in favor of using direct constructor calls, addressing name clash issues and streamlining the API usage.
- Added a migration recipe for Java Traits usage.
- Updated best practice recipe configuration to include the new migration recipe.
- Added unit tests for validating the migration behavior.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/test/java/org/openrewrite/java/recipes/migrate/RemoveTraitsUsageTest.java | Added tests to validate migration from Traits factory usage to constructor calls. |
src/main/resources/META-INF/rewrite/recipebestpractice.yml | Extended best practice recipe list with the new RemoveTraitsUsage recipe. |
src/main/java/org/openrewrite/java/recipes/migrate/RemoveTraitsUsage.java | Implemented recipes to replace static Traits calls with corresponding constructor calls for Java, Maven, and Gradle. |
Comments suppressed due to low confidence (1)
src/main/java/org/openrewrite/java/recipes/migrate/RemoveTraitsUsage.java:199
- The description references 'org.openrewrite.java.gradle.Traits' while the code calls 'org.openrewrite.gradle.trait.Traits'. Please update the description to match the actual package used.
description = "Removes the usage of static `org.openrewrite.java.gradle.Traits` class and replace with corresponding constructor calls."
What's changed?
Added a recipe to remove Traits static method usage in favor of the actual constructor calls.
What's your motivation?
The usage of central
Traits
classes for every language makes it easier to discover traits, but if more than one type of trait is used, name clashes are the result.It indicates that the introduction of Traits as central factory was to early and therefore shold be rolled back now as long as the adoption is not that high.
This recipe provided the migration to adapt to this rollback.
Example of a clash for example in Dependency migrations
Any additional context
removal sugested by @jkschneider
Checklist