Skip to content

Commit e76cdfd

Browse files
author
Vincent Potucek
committed
EqualsAvoidsNull
1 parent c511228 commit e76cdfd

File tree

12 files changed

+95
-21
lines changed

12 files changed

+95
-21
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/DummyLanguageModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static class Handler extends AbstractPmdLanguageVersionHandler {
104104
@Override
105105
public Parser getParser() {
106106
return task -> {
107-
if (task.getLanguageVersion().getVersion().equals(PARSER_THROWS)) {
107+
if (PARSER_THROWS.equals(task.getLanguageVersion().getVersion())) {
108108
throw new ParseException("ohio");
109109
}
110110
return readLispNode(task);

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/main/java/net/sourceforge/pmd/lang/java/ast/ASTAnnotationTypeDeclaration.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
package net.sourceforge.pmd.lang.java.ast;
66

7-
import net.sourceforge.pmd.lang.ast.Node;
8-
97
/**
108
* The declaration of an annotation type.
11-
* This is a {@linkplain Node#isFindBoundary() find boundary} for tree traversal methods.
9+
* This is a {@linkplain net.sourceforge.pmd.lang.ast.Node#isFindBoundary() find boundary} for tree traversal methods.
1210
*
1311
* <p>Note that in contrast to interface types, no {@linkplain ASTExtendsList extends clause}
1412
* is permitted, and an annotation type cannot be generic.

pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/stringtostring/User.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44

55
package net.sourceforge.pmd.lang.java.rule.performance.stringtostring;
66

7-
import java.util.Locale;
8-
97
public class User {
108

119
public String getName() {
1210
return "username";
1311
}
14-
15-
private String convert(String s) {
16-
return s.toLowerCase(Locale.ROOT);
17-
}
1812
}

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
}

pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/InfiniteLoopInLookahead.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
33
*/
44

5-
import java.util.*;
5+
import java.util.List;
66

77
public class InfiniteLoopInLookahead {
88

0 commit comments

Comments
 (0)