Skip to content

Conversation

@mrclmh
Copy link
Contributor

@mrclmh mrclmh commented Nov 17, 2025

Describe the PR

Rule: OverrideBothEqualsAndHashCodeOnComparable

Detect generated equals and hashCode in Comparable when neither method has been implemented manually.
Currently Lombok @EqualsAndHashCode, @Data and @Value are detected.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Detect generated equals and hashCode in Comparable when neither method
has been implemented manually.
@mrclmh mrclmh changed the title [java] Detect generated equals/hashCode in Comparable [java] Fix #6096: Detect generated equals/hashCode in Comparable Nov 17, 2025
@pmd-actions-helper
Copy link
Contributor

pmd-actions-helper bot commented Nov 17, 2025

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 25 errors and 8 configuration errors.

Regression Tester Report

(comment created at 2025-11-20 21:01:40+00:00 for 8ab254e)

@mrclmh
Copy link
Contributor Author

mrclmh commented Nov 18, 2025

Not sure about the line break in the Set init line. What is the preferred max line length for the project?

@adangel adangel changed the title [java] Fix #6096: Detect generated equals/hashCode in Comparable [java] Fix #6096: Detect Lombok generated equals/hashCode in Comparable Nov 20, 2025
Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

This will solve it for that rule.


optional request:
For Lombok, we actually have a bit more in mind (see #3119):

If you like, you can give it a try, maybe in a separate PR.


@adangel
Copy link
Member

adangel commented Nov 20, 2025

Not sure about the line break in the Set init line. What is the preferred max line length for the project?

around 120 I think

@mrclmh mrclmh requested a review from adangel November 20, 2025 21:19
Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@adangel adangel self-assigned this Nov 25, 2025
@adangel adangel added this to the 7.19.0 milestone Nov 25, 2025
@adangel adangel merged commit 8ab254e into pmd:main Nov 25, 2025
12 checks passed
adangel added a commit that referenced this pull request Nov 25, 2025
@mrclmh mrclmh deleted the issue6096 branch November 27, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[java] OverrideBothEqualsAndHashCodeOnComparable on class with lombok.EqualsAndHashCode annotation

2 participants