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

[java] OverrideBothEqualsAndHashCode ignores records #4546

Closed
oowekyala opened this issue May 3, 2023 · 0 comments · Fixed by #4540
Closed

[java] OverrideBothEqualsAndHashCode ignores records #4546

oowekyala opened this issue May 3, 2023 · 0 comments · Fixed by #4540
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Milestone

Comments

@oowekyala
Copy link
Member

Affects PMD Version: 7.0.0-rc2 and 6.x

Rule: OverrideBothEqualsAndHashCode

Please provide the rule name and a link to the rule documentation:
https://docs.pmd-code.org/latest/pmd_rules_java_errorprone.html#overridebothequalsandhashcode

Description:

Code Sample demonstrating the issue:

record Foo(int x) {
   @Override boolean equals(Object o) { return this == o; }
}

Expected outcome:

PMD should report a violation at line ..., but doesn't. This is a false-negative.

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]

@oowekyala oowekyala added the a:false-negative PMD doesn't flag a problematic piece of code label May 3, 2023
@oowekyala oowekyala added this to the 7.0.0 milestone May 3, 2023
adangel added a commit to adangel/pmd that referenced this issue May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant