Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public String getMessage() {

@Override
public Object visit(ASTUserClass clazz, Object ctx) {
if (clazz.getSimpleName().equalsIgnoreCase("bar")) {
if ("bar".equalsIgnoreCase(clazz.getSimpleName())) {
asCtx(ctx).addViolation(clazz);
}
return super.visit(clazz, ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static class Handler extends AbstractPmdLanguageVersionHandler {
@Override
public Parser getParser() {
return task -> {
if (task.getLanguageVersion().getVersion().equals(PARSER_THROWS)) {
if (PARSER_THROWS.equals(task.getLanguageVersion().getVersion())) {
throw new ParseException("ohio");
}
return readLispNode(task);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static Collection<NodeStream<?>> allNodeStreamVariants() {
stream.precedingSiblings(),
stream.descendantsOrSelf(),
stream.children(),
stream.children().filter(c -> c.getImage().equals("0")),
stream.children().filter(c -> "0".equals(c.getImage())),
stream.children(DummyNode.class)
)
).flatMap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void testFilterOnChain() {
void testTransitiveSucc() {

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

lattice.put("abc", "val");
lattice.put("bc", "v2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void testFlatmapEmpty2() {
void testFlatmapIsLazy() {
Iterator<String> iter = iterOf("a", "b");
Function<String, Iterator<String>> fun = s -> {
if (s.equals("a")) {
if ("a".equals(s)) {
return iterOf("a");
} else {
throw new AssertionError("This statement shouldn't be reached");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void testRenderFilterAttributes() throws IOException {
XmlRenderingConfig strategy = new XmlRenderingConfig() {
@Override
public boolean takeAttribute(Node node, Attribute attribute) {
return attribute.getName().equals("ohio");
return "ohio".equals(attribute.getName());
}
}.lineSeparator("\n");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

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

import net.sourceforge.pmd.lang.ast.Node;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
* The declaration of an annotation type.
* This is a {@linkplain Node#isFindBoundary() find boundary} for tree traversal methods.
* This is a {@linkplain net.sourceforge.pmd.lang.ast.Node#isFindBoundary() find boundary} for tree traversal methods.
*
* <p>Note that in contrast to interface types, no {@linkplain ASTExtendsList extends clause}
* is permitted, and an annotation type cannot be generic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@

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

import java.util.Locale;

public class User {

public String getName() {
return "username";
}

private String convert(String s) {
return s.toLowerCase(Locale.ROOT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ public static <A extends Annotation> A createAnnotationInstance(Class<A> annotat
@SuppressWarnings("unchecked")
public static <A extends Annotation> A createAnnotationInstance(Class<A> annotationClass, Map<String, Object> attributes) {
return (A) Proxy.newProxyInstance(annotationClass.getClassLoader(), new Class[] { annotationClass }, (proxy, method, args) -> {
if (method.getName().equals("annotationType") && args == null) {
if ("annotationType".equals(method.getName()) && args == null) {
return annotationClass;
} else if (method.getName().equals("toString") && args == null) {
} else if ("toString".equals(method.getName()) && args == null) {
return AnnotationUtils.toString((Annotation) proxy);
} else if (method.getName().equals("hashCode") && args == null) {
} else if ("hashCode".equals(method.getName()) && args == null) {
return AnnotationUtils.hashCode((Annotation) proxy);
} else if (method.getName().equals("equals") && args.length == 1) {
} else if ("equals".equals(method.getName()) && args.length == 1) {
if (args[0] instanceof Annotation) {
return AnnotationUtils.equals((Annotation) proxy, (Annotation) args[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/

import java.util.*;
import java.util.List;

public class InfiniteLoopInLookahead {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

package net.sourceforge.pmd.lang.typescript.ast;

import org.antlr.v4.runtime.*;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wildcard it nice to see gone, is the unused import now resolving these, or what recipe did it?

@timtebeek

import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.Token;

import java.util.ArrayDeque;
import java.util.Deque;
Expand Down
22 changes: 17 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -483,16 +483,22 @@
<configuration>
<exclusions>
<exclusion>**Chars.java</exclusion> <!-- // @SuppressWarnings("PMD.MissingOverride") -->
<exclusion>**Jep441_PatternMatchingForSwitch.java</exclusion>
<exclusion>**Dummy**Rule.java</exclusion>
<exclusion>**FooRule.java</exclusion>
<exclusion>**jdkversiontests**</exclusion>
<exclusion>**missingoverride**</exclusion>
<exclusion>**private_method_in_inner_class_interface*.java</exclusion>
<exclusion>**testdata**</exclusion>
<exclusion>**unnecessaryimport**</exclusion>
<exclusion>**uselessoverridingmethod**</exclusion>
</exclusions>
<activeRecipes>
<recipe>org.openrewrite.java.RemoveUnusedImports</recipe>
<recipe>org.openrewrite.staticanalysis.EqualsAvoidsNull</recipe>
<recipe>org.openrewrite.staticanalysis.ModifierOrder</recipe>
<recipe>org.openrewrite.staticanalysis.RedundantFileCreation</recipe>
<recipe>org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods</recipe>
<recipe>org.openrewrite.text.EndOfLineAtEndOfFile</recipe>
<!-- <recipe>org.openrewrite.java.format.AutoFormat</recipe>-->
<!-- <recipe>org.openrewrite.java.format.AutoFormat</recipe> checkstyle equivalent -->
<!-- <recipe>org.openrewrite.java.format.BlankLines</recipe>-->
<!-- <recipe>org.openrewrite.java.format.NormalizeFormat</recipe>-->
<!-- <recipe>org.openrewrite.java.format.NormalizeLineBreaks</recipe>-->
Expand All @@ -502,6 +508,7 @@
<!-- <recipe>org.openrewrite.java.format.WrappingAndBraces</recipe>-->
<!-- <recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>-->
<!-- <recipe>org.openrewrite.java.migrate.UpgradeToJava21</recipe>-->
<!-- <recipe>org.openrewrite.java.migrate.UpgradeToJava25</recipe>-->
<!-- <recipe>org.openrewrite.java.testing.assertj.Assertj</recipe>-->
<!-- <recipe>org.openrewrite.java.testing.cleanup.AssertTrueNullToAssertNull</recipe>-->
<!-- <recipe>org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic</recipe>-->
Expand All @@ -511,10 +518,10 @@
<!-- <recipe>org.openrewrite.staticanalysis.CommonStaticAnalysis</recipe>-->
<!-- <recipe>org.openrewrite.staticanalysis.FinalizeLocalVariables</recipe>-->
<!-- <recipe>org.openrewrite.staticanalysis.MissingOverrideAnnotation</recipe>-->
<!-- <recipe>org.openrewrite.staticanalysis.RedundantFileCreation</recipe>-->
<!-- <recipe>org.openrewrite.staticanalysis.RemoveUnusedLocalVariables</recipe>-->
<!-- <recipe>org.openrewrite.staticanalysis.RemoveUnusedPrivateFields</recipe>-->
<!-- <recipe>org.openrewrite.staticanalysis.StringLiteralEquality</recipe>-->
<!-- <recipe>org.openrewrite.text.EndOfLineAtEndOfFile</recipe>-->
</activeRecipes>
<failOnDryRunResults>true</failOnDryRunResults>
<rewriteSkip>${rewrite.skip}</rewriteSkip>
Expand All @@ -531,13 +538,18 @@
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-static-analysis</artifactId>
<version>2.11.0</version>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-testing-frameworks</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-migrate-java</artifactId>
<version>3.13.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
Expand Down
Loading