GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] Fix #6096: Detect Lombok generated equals/hashCode in Comparable by mrclmh · Pull Request #6238 · pmd/pmd

Conversation

@mrclmh

@mrclmh mrclmh commented Nov 17, 2025 •
edited by adangel
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

  • Fix [java] OverrideBothEqualsAndHashCodeOnComparable on class with lombok.EqualsAndHashCode annotation #6096
  • Related to [java] OverrideBothEqualsAndHashCodeOnComparable should not be required for record classes #6072 and [java] Fix #6072: OverrideBothEqualsAndHashCodeOnComparable should not be required for record classes #6081 - same issue for records
  • See also [java] Better Lombok support #3119

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)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mrclmh
[java] Detect generated equals/hashCode in Comparable
a9f54e5
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

pmd-actions-helper Bot commented Nov 17, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mrclmh

mrclmh commented Nov 18, 2025

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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
adangel
adangel requested changes Nov 20, 2025
View reviewed changes

@adangel adangel left a comment

Copy link
Copy Markdown
Member

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.

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):

  • in

    pmd/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/ast/AstClassSym.java

    Line 158 in 33f00ec

    public void processLombok(JavaAstProcessor processor) {
    we could actually add fake methods for the generated equals and hashCode methods
  • in

    pmd/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/OverrideBothEqualsAndHashcodeRule.java

    Line 35 in 33f00ec

    for (ASTMethodDeclaration m : node.getDeclarations(ASTMethodDeclaration.class)) {
    the rule wouldn't iterate over the ast, but over the symbols (using node.getSymbol().getDeclaredMethods()) and would see then the generated methods as well

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


Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...sourceforge/pmd/lang/java/rule/errorprone/OverrideBothEqualsAndHashCodeOnComparableRule.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...sourceforge/pmd/lang/java/rule/errorprone/OverrideBothEqualsAndHashCodeOnComparableRule.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .../sourceforge/pmd/lang/java/rule/errorprone/xml/OverrideBothEqualsAndHashCodeOnComparable.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .../sourceforge/pmd/lang/java/rule/errorprone/xml/OverrideBothEqualsAndHashCodeOnComparable.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel mentioned this pull request Nov 20, 2025
[java] Better Lombok support #3119
Open
@adangel

adangel commented Nov 20, 2025

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mrclmh added 4 commits November 20, 2025 20:48
@mrclmh
Refactor: Specify that Lombok generates code
c581086
@mrclmh
Refactor: Use annotation check as additional guard clause
2ab3618
@mrclmh
Doc: Add comment about violations in tests
acf3f12
@mrclmh
Merge branch 'pmd:main' into issue6096
8ab254e
@mrclmh
mrclmh requested a review from adangel November 20, 2025 21:19
adangel
adangel approved these changes Nov 25, 2025
View reviewed changes

@adangel adangel left a comment

Copy link
Copy Markdown
Member

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.

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@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
adangel added a commit that referenced this pull request Nov 25, 2025
@adangel
[doc] Update release notes (#6096, #6238)
a386641
adangel added a commit that referenced this pull request Nov 25, 2025
@adangel
[java] Fix #6096: Detect Lombok generated equals/hashCode in Comparab…
578ad5d
…le (#6238)
@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

Reviewers

@adangel adangel adangel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@adangel adangel

Labels

None yet

Projects

None yet

Milestone

7.19.0

Development

Successfully merging this pull request may close these issues.

[java] OverrideBothEqualsAndHashCodeOnComparable on class with lombok.EqualsAndHashCode annotation

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@mrclmh @adangel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.