Skip to content

Conversation

@adangel
Copy link
Member

@adangel adangel commented Oct 30, 2025

Describe the PR

Ran #6193 against current PMD source code. Used the following snippet in build-tools pmd-dogfood-config.xml:

    <!-- https://github.com/pmd/pmd/issues/6193 -->
    <rule name="UnnecessaryEqualsForEnum"
          language="java"
          since="36"
          message="Use == to compare enum values"
          class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
        <description>Enum should be compared using ==, this is more readable. Using equals() is not necessary (and is prone to NPE).</description>
        <priority>1</priority>
        <properties>
            <property name="xpath">
                <value><![CDATA[
//MethodCall[pmd-java:matchesSig("_#equals(java.lang.Object)")]
  [*[pmd-java:typeIs("java.lang.Enum")] or
   ArgumentList[*[pmd-java:typeIs("java.lang.Enum")]]]
]]></value>
            </property>
        </properties>
    </rule>

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)

@adangel adangel added this to the 7.19.0 milestone Oct 30, 2025
@adangel adangel added the in:pmd-internals Affects PMD's internals label Oct 30, 2025
@pmd-actions-helper
Copy link
Contributor

pmd-actions-helper bot commented Oct 30, 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-06 15:06:42+00:00 for 6b6c555)

@adangel adangel force-pushed the chore/dogfood-enum-comparison branch from 677129c to 6b6c555 Compare November 6, 2025 14:47
@adangel adangel self-assigned this Nov 27, 2025
@adangel
Copy link
Member Author

adangel commented Nov 27, 2025

I'm going to merge this for 7.19.0, assuming this is ok.

@adangel adangel merged commit 6b6c555 into pmd:main Nov 27, 2025
12 checks passed
adangel added a commit to adangel/pmd that referenced this pull request Nov 27, 2025
adangel added a commit to adangel/pmd that referenced this pull request Nov 27, 2025
@adangel adangel deleted the chore/dogfood-enum-comparison branch November 27, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:pmd-internals Affects PMD's internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant