Skip to content

Commit 4afbbfc

Browse files
Pankraz76Vincent Potucek
andauthored
EqualsAvoidsNull (#4)
* EqualsAvoidsNull * EqualsAvoidsNull * EqualsAvoidsNull * EqualsAvoidsNull * EqualsAvoidsNull * EqualsAvoidsNull * EqualsAvoidsNull --------- Co-authored-by: Vincent Potucek <[email protected]>
1 parent 79149bf commit 4afbbfc

File tree

7 files changed

+17
-42
lines changed

7 files changed

+17
-42
lines changed

pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public String getMessage() {
3131

3232
@Override
3333
public Object visit(ASTUserClass clazz, Object ctx) {
34-
if (clazz.getSimpleName().equalsIgnoreCase("bar")) {
34+
if ("bar".equalsIgnoreCase(clazz.getSimpleName())) {
3535
asCtx(ctx).addViolation(clazz);
3636
}
3737
return super.visit(clazz, ctx);

pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamBlanketTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static Collection<NodeStream<?>> allNodeStreamVariants() {
236236
stream.precedingSiblings(),
237237
stream.descendantsOrSelf(),
238238
stream.children(),
239-
stream.children().filter(c -> c.getImage().equals("0")),
239+
stream.children().filter(c -> "0".equals(c.getImage())),
240240
stream.children(DummyNode.class)
241241
)
242242
).flatMap(

pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void testFilterOnChain() {
207207
void testTransitiveSucc() {
208208

209209
LatticeRelation<String, String, Set<String>> lattice =
210-
stringLattice(s -> s.equals("c") || s.equals("bc"));
210+
stringLattice(s -> "c".equals(s) || "bc".equals(s));
211211

212212
lattice.put("abc", "val");
213213
lattice.put("bc", "v2");

pmd-core/src/test/java/net/sourceforge/pmd/util/IteratorUtilTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void testFlatmapEmpty2() {
149149
void testFlatmapIsLazy() {
150150
Iterator<String> iter = iterOf("a", "b");
151151
Function<String, Iterator<String>> fun = s -> {
152-
if (s.equals("a")) {
152+
if ("a".equals(s)) {
153153
return iterOf("a");
154154
} else {
155155
throw new AssertionError("This statement shouldn't be reached");

pmd-core/src/test/java/net/sourceforge/pmd/util/treeexport/XmlTreeRendererTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void testRenderFilterAttributes() throws IOException {
130130
XmlRenderingConfig strategy = new XmlRenderingConfig() {
131131
@Override
132132
public boolean takeAttribute(Node node, Attribute attribute) {
133-
return attribute.getName().equals("ohio");
133+
return "ohio".equals(attribute.getName());
134134
}
135135
}.lineSeparator("\n");
136136

pmd-java/src/test/java/net/sourceforge/pmd/lang/java/symbols/internal/TypeAnnotTestUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ public static <A extends Annotation> A createAnnotationInstance(Class<A> annotat
8484
@SuppressWarnings("unchecked")
8585
public static <A extends Annotation> A createAnnotationInstance(Class<A> annotationClass, Map<String, Object> attributes) {
8686
return (A) Proxy.newProxyInstance(annotationClass.getClassLoader(), new Class[] { annotationClass }, (proxy, method, args) -> {
87-
if (method.getName().equals("annotationType") && args == null) {
87+
if ("annotationType".equals(method.getName()) && args == null) {
8888
return annotationClass;
89-
} else if (method.getName().equals("toString") && args == null) {
89+
} else if ("toString".equals(method.getName()) && args == null) {
9090
return AnnotationUtils.toString((Annotation) proxy);
91-
} else if (method.getName().equals("hashCode") && args == null) {
91+
} else if ("hashCode".equals(method.getName()) && args == null) {
9292
return AnnotationUtils.hashCode((Annotation) proxy);
93-
} else if (method.getName().equals("equals") && args.length == 1) {
93+
} else if ("equals".equals(method.getName()) && args.length == 1) {
9494
if (args[0] instanceof Annotation) {
9595
return AnnotationUtils.equals((Annotation) proxy, (Annotation) args[0]);
9696
}

pom.xml

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -483,38 +483,18 @@
483483
<configuration>
484484
<exclusions>
485485
<exclusion>**Chars.java</exclusion> <!-- // @SuppressWarnings("PMD.MissingOverride") -->
486-
<exclusion>**Jep441_PatternMatchingForSwitch.java</exclusion>
486+
<exclusion>**Dummy**.java</exclusion>
487+
<exclusion>**FooRule.java</exclusion>
488+
<exclusion>**jdkversiontests**</exclusion>
489+
<exclusion>**missingoverride**</exclusion>
490+
<exclusion>**private_method_in_inner_class_interface*.java</exclusion>
487491
<exclusion>**testdata**</exclusion>
492+
<exclusion>**unnecessaryimport**</exclusion>
493+
<exclusion>**uselessoverridingmethod**</exclusion>
488494
</exclusions>
489495
<activeRecipes>
490-
<recipe>org.openrewrite.java.RemoveUnusedImports</recipe>
491496
<recipe>org.openrewrite.staticanalysis.EqualsAvoidsNull</recipe>
492497
<recipe>org.openrewrite.staticanalysis.ModifierOrder</recipe>
493-
<recipe>org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods</recipe>
494-
<recipe>org.openrewrite.text.EndOfLineAtEndOfFile</recipe>
495-
<!-- <recipe>org.openrewrite.java.format.AutoFormat</recipe>-->
496-
<!-- <recipe>org.openrewrite.java.format.BlankLines</recipe>-->
497-
<!-- <recipe>org.openrewrite.java.format.NormalizeFormat</recipe>-->
498-
<!-- <recipe>org.openrewrite.java.format.NormalizeLineBreaks</recipe>-->
499-
<!-- <recipe>org.openrewrite.java.format.RemoveTrailingWhitespace</recipe>-->
500-
<!-- <recipe>org.openrewrite.java.format.Spaces</recipe>-->
501-
<!-- <recipe>org.openrewrite.java.format.TabsAndIndents</recipe>-->
502-
<!-- <recipe>org.openrewrite.java.format.WrappingAndBraces</recipe>-->
503-
<!-- <recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>-->
504-
<!-- <recipe>org.openrewrite.java.migrate.UpgradeToJava21</recipe>-->
505-
<!-- <recipe>org.openrewrite.java.testing.assertj.Assertj</recipe>-->
506-
<!-- <recipe>org.openrewrite.java.testing.cleanup.AssertTrueNullToAssertNull</recipe>-->
507-
<!-- <recipe>org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic</recipe>-->
508-
<!-- <recipe>org.openrewrite.java.testing.junit5.JUnit5BestPractices</recipe>-->
509-
<!-- <recipe>org.openrewrite.maven.OrderPomElements</recipe>-->
510-
<!-- <recipe>org.openrewrite.staticanalysis.CodeCleanup</recipe>-->
511-
<!-- <recipe>org.openrewrite.staticanalysis.CommonStaticAnalysis</recipe>-->
512-
<!-- <recipe>org.openrewrite.staticanalysis.FinalizeLocalVariables</recipe>-->
513-
<!-- <recipe>org.openrewrite.staticanalysis.MissingOverrideAnnotation</recipe>-->
514-
<!-- <recipe>org.openrewrite.staticanalysis.RedundantFileCreation</recipe>-->
515-
<!-- <recipe>org.openrewrite.staticanalysis.RemoveUnusedLocalVariables</recipe>-->
516-
<!-- <recipe>org.openrewrite.staticanalysis.RemoveUnusedPrivateFields</recipe>-->
517-
<!-- <recipe>org.openrewrite.staticanalysis.StringLiteralEquality</recipe>-->
518498
</activeRecipes>
519499
<failOnDryRunResults>true</failOnDryRunResults>
520500
<rewriteSkip>${rewrite.skip}</rewriteSkip>
@@ -531,12 +511,7 @@
531511
<dependency>
532512
<groupId>org.openrewrite.recipe</groupId>
533513
<artifactId>rewrite-static-analysis</artifactId>
534-
<version>2.11.0</version>
535-
</dependency>
536-
<dependency>
537-
<groupId>org.openrewrite.recipe</groupId>
538-
<artifactId>rewrite-testing-frameworks</artifactId>
539-
<version>3.12.0</version>
514+
<version>2.12.0</version>
540515
</dependency>
541516
</dependencies>
542517
</plugin>

0 commit comments

Comments
 (0)