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

feat: convert any equals and hashcode to the lombok annotation, ignore implementation #647

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

timo-a
Copy link
Contributor

@timo-a timo-a commented Dec 24, 2024

What's changed?

What's your motivation?

To convert classes to @Value or @Data they need to have @EqualsAndHashCode.
But this annotation is probably not there.
equals() and hashCode() are if defined hard to validate, so this recipe assumes that manual work is necessary and adds
@EqualsAndHashCode to any class that implements either equals() or hashCode() regardless of how they are implemented. The user has to review each class, but saves the effort of finding and replacing.

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@timtebeek timtebeek self-requested a review January 1, 2025 14:43
@timo-a timo-a force-pushed the lombok/convert-equals-negligently branch from 4ab6051 to 68838e4 Compare January 1, 2025 19:13
@timo-a timo-a force-pushed the lombok/convert-equals-negligently branch from 4d5d678 to 4194a9d Compare January 15, 2025 15:59
@timo-a
Copy link
Contributor Author

timo-a commented Jan 15, 2025

Now there is a seemingly unrelated error in /home/runner/work/rewrite-migrate-java/rewrite-migrate-java/src/main/java/org/openrewrite/java/migrate/javax/AddColumnAnnotation.java:92:

error: constructor AddOrUpdateAnnotationAttribute in class AddOrUpdateAnnotationAttribute cannot be applied to given types;
                        J.VariableDeclarations updatedVariable = (J.VariableDeclarations) new AddOrUpdateAnnotationAttribute(
                                                                                          ^
  required: String,String,String,String,Boolean,Boolean
  found:    String,String,String,boolean,<null>
  reason: actual and formal argument lists differ in lengthNote: Recompile with -Xlint:unchecked for details.warning: [options] source value 8 is obsolete and will be removed in a future releaseNote: Some input files use unchecked or unsafe operations.warning: unknown enum constant ElementType.MODULE

Maybe a rebase on main can fix this?
Update: apparently so, pushing

timo-a and others added 4 commits January 15, 2025 17:23
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timo-a timo-a force-pushed the lombok/convert-equals-negligently branch from 7b8ffe4 to 51ffbc2 Compare January 15, 2025 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants