Skip to content

[java] EnumComparison: False positive for any object when object.equals(null) #6291

Closed

Description

@ben-manes

Affects PMD Version: 7.19.0

Rule: EnumComparison
https://docs.pmd-code.org/pmd-doc-7.19.0/pmd_rules_java_bestpractices.html#enumcomparison

Description:

Code Sample demonstrating the issue:
Image

Image Image

This is reproducible as,

assertThat(new Object().equals(null)).isFalse();

Expected outcome:
Only enums should be reported on and null should not be assumed to be an enum.

Running PMD through: Gradle

Activity

  1. added
    a:false-positive
    on Nov 28, 2025
  2. added a commit that references this issue on Nov 29, 2025
    82999bc
  3. added this to the 7.20.0 milestone on Nov 29, 2025
  4. changed the title [-][java] `EnumComparison` false positive for any object when object.equals(null)[/-] [+][java] EnumComparison: False positive for any object when object.equals(null)[/+] on Dec 18, 2025
  5. added 2 commits that reference this issue on Dec 19, 2025
  6. added a commit that references this issue on Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positive

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions