Skip to content
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

"Writing a Java refactoring recipe" Should not use Lombok #252

Closed
asaikali opened this issue Dec 18, 2023 · 4 comments
Closed

"Writing a Java refactoring recipe" Should not use Lombok #252

asaikali opened this issue Dec 18, 2023 · 4 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@asaikali
Copy link

asaikali commented Dec 18, 2023

The tutorial at Writing a Java refactoring recipe is hard to understand / follow with Lombok, please consider removing the usage of Lombok. As a user I visited this page to learn how to write a recipe I want all my mental energy focused on learning how to write a recipe not contemplating what is this Lombok annotation doing.

I understand the argument from folks who use lombok every day that they know what the annotations do, for those of us who don't use lombok everyday its a pain to try and remember what those annotations do. My efforts to learn how to write a recipe are derailed by having to learn what the lombok annotations do.

Annotations like @EqualsAndHashCode(callSuper = true) in the sample template for recipes makes me guess that there is complex contract that is not well defined in the tutorial, for example the visitor requires an implementation of hashCode equals that behaves a certain way.

I generated the project from the recommend template project which the recipe below

@Value
@EqualsAndHashCode(callSuper = true)
public class NoGuavaListsNewArrayList extends Recipe {

The Recipe tutorial has the code below, in the final full recipe implementation.

@Value
@EqualsAndHashCode(callSuper = false)
public class SayHelloRecipe extends Recipe {

One has callSuper = true and the other callSuper = false as a user it is very confusing what is the contract that OpenRewrite excepts from recipe?

By removing Lombok from the recipe tutorial you will make the tutorial easier to understand, clearer, and less ambiguous for a wider range of readers.

@asaikali asaikali added the bug Something isn't working label Dec 18, 2023
@timtebeek timtebeek added the documentation Improvements or additions to documentation label Dec 18, 2023
@timtebeek
Copy link
Contributor

I agree with you there! We should at least be consistent in our use, and ideally not require additional tools when folks want to learn about OpenRewrite. Thanks for pointing those out!

/cc @mike-solomon

@mike-solomon
Copy link
Contributor

mike-solomon commented Dec 18, 2023

@timtebeek Do you have any examples of recipes that don't use Lombok or what is necessary if you don't include those annotations? I know that people need to ensure it's serializable -- but I'm not really sure how someone would do that and if anything else is needed there.

@mike-solomon mike-solomon added blocked When an issue can't be worked on right now help wanted Extra attention is needed and removed blocked When an issue can't be worked on right now labels Jan 4, 2024
@timtebeek
Copy link
Contributor

As soon as recipes use fields we typically use Lombok for convenience; to create a sample without Lombok from writing-a-java-refactoring-recipe you can remove the annotations, then have your IDE generate a getter, equals, hashcode and toString function. For brevity we could do this only for the completed visito on a separate tab that does not use Lombok. That might help to show but common use (with Lombok), and still provide an option without Lombok.

@timtebeek timtebeek moved this to Backlog in OpenRewrite Jan 21, 2024
@timtebeek
Copy link
Contributor

Not sure if you spoke to Jonathan @asaikali , but we're now enforcing a common standard with regards to the use of callSuper. Hope that helps! openrewrite/rewrite@d166ad5

@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenRewrite Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
Archived in project
Development

No branches or pull requests

3 participants