From 77f01f683dba0694231f4b1a36d3c79bbbb2fd09 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 28 Jan 2022 11:44:54 +0100 Subject: [PATCH] Fix PMD issues in core and test --- .../net/sourceforge/pmd/properties/AbstractProperty.java | 8 +------- .../net/sourceforge/pmd/AbstractRuleSetFactoryTest.java | 2 +- .../net/sourceforge/pmd/testframework/RuleTestRunner.java | 3 ++- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractProperty.java index 5a538a32c9..973185c552 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractProperty.java @@ -80,13 +80,7 @@ import org.apache.commons.lang3.StringUtils; @Override public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - return obj instanceof PropertyDescriptor + return this == obj || obj instanceof PropertyDescriptor && name.equals(((PropertyDescriptor) obj).name()); } diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java index b262bbcf46..16d70904b0 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java @@ -352,7 +352,7 @@ public abstract class AbstractRuleSetFactoryTest { file = file.replaceAll("xsi:schemaLocation=\"" + rulesetNamespace + " https://pmd.sourceforge.io/ruleset_\\d_0_0.xsd\"", ""); - if (rulesetNamespace.equals(RuleSetWriter.RULESET_2_0_0_NS_URI)) { + if (RuleSetWriter.RULESET_2_0_0_NS_URI.equals(rulesetNamespace)) { file = "" + PMD.EOL + "" + PMD.EOL + file; } else { diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTestRunner.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTestRunner.java index b85e3f5184..29e0570ee6 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTestRunner.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/RuleTestRunner.java @@ -10,6 +10,7 @@ import java.util.Comparator; import java.util.LinkedList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import org.junit.After; import org.junit.Before; @@ -34,7 +35,7 @@ import net.sourceforge.pmd.Rule; * @author Andreas Dangel */ public class RuleTestRunner extends ParentRunner { - private ConcurrentHashMap testDescriptions = new ConcurrentHashMap<>(); + private ConcurrentMap testDescriptions = new ConcurrentHashMap<>(); private final RuleTst instance; /* default */ RuleTestRunner(final Class testClass) throws InitializationError {