Skip to content

Commit

Permalink
Apply recipes of org.openrewrite.staticanalysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Nov 18, 2024
1 parent d3fa8d7 commit 1a306f2
Show file tree
Hide file tree
Showing 250 changed files with 423 additions and 182 deletions.
2 changes: 1 addition & 1 deletion etc/Jenkinsfile.declarative
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ pipeline {
recordIssues enabledForFailure: true, tool: taskScanner(includePattern:'**/*.java', highTags:'FIXME', normalTags:'TODO')
}
}
}
}
2 changes: 1 addition & 1 deletion etc/Jenkinsfile.fullBuild
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ node {
stage ('Collect Maven Warnings') {
recordIssues tool: mavenConsole()
}
}
}
2 changes: 1 addition & 1 deletion etc/Jenkinsfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ node {
stage ('Collect Maven Warnings') {
recordIssues tool: mavenConsole()
}
}
}
2 changes: 1 addition & 1 deletion etc/Jenkinsfile.parallel.declarative
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ pipeline {
[tool: taskScanner(includePattern:'**/*.java', highTags:'FIXME', normalTags:'TODO')]]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ Pattern getPattern() {
return NAMESPACE_PATTERN;
}
}

1 change: 0 additions & 1 deletion src/main/java/edu/hm/hafner/analysis/Categories.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ private Categories() {
// prevents instantiation
}
}

2 changes: 2 additions & 0 deletions src/main/java/edu/hm/hafner/analysis/DuplicationGroup.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis;

import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -15,6 +16,7 @@
* detector like CPD, DupFinder, or Simian.
*/
public final class DuplicationGroup implements Serializable {
@Serial
private static final long serialVersionUID = -5005784523279541971L;

private final List<Issue> occurrences = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,3 @@ Stream<String> readLinesFromFile(final String fileName, final Charset charset)
}
}
}

6 changes: 4 additions & 2 deletions src/main/java/edu/hm/hafner/analysis/Issue.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis;

import java.io.Serial;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
Expand All @@ -26,6 +27,7 @@
*/
@SuppressWarnings({"PMD.TooManyFields", "PMD.GodClass", "PMD.CyclomaticComplexity", "NoFunctionalReturnType"})
public class Issue implements Serializable {
@Serial
private static final long serialVersionUID = 1L; // release 1.0.0

private static final PathUtil PATH_UTIL = new PathUtil();
Expand Down Expand Up @@ -935,8 +937,8 @@ public boolean equals(@CheckForNull final Object o) {
if (!description.equals(issue.description)) {
return false;
}
if (additionalProperties != null ? !additionalProperties.equals(issue.additionalProperties) :
issue.additionalProperties != null) {
if (additionalProperties != null ? !additionalProperties.equals(issue.additionalProperties)
: issue.additionalProperties != null) {
return false;
}
if (!origin.equals(issue.origin)) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/edu/hm/hafner/analysis/IssueBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public class IssueBuilder implements AutoCloseable {
private final TreeStringBuilder packageNameBuilder = new TreeStringBuilder();
private final TreeStringBuilder messageBuilder = new TreeStringBuilder();

private int lineStart = 0;
private int lineEnd = 0;
private int columnStart = 0;
private int columnEnd = 0;
private int lineStart;
private int lineEnd;
private int columnStart;
private int columnEnd;

@CheckForNull
private LineRangeList lineRanges;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/edu/hm/hafner/analysis/IssueParser.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis;

import java.io.Serial;
import java.io.Serializable;
import java.util.Locale;
import java.util.stream.Stream;
Expand All @@ -16,6 +17,7 @@
*/
@SuppressWarnings("checkstyle:JavadocVariable")
public abstract class IssueParser implements Serializable {
@Serial
private static final long serialVersionUID = 200992696185460268L;

protected static final String ADDITIONAL_PROPERTIES = "additionalProperties";
Expand Down Expand Up @@ -133,4 +135,3 @@ private static String normalize(@CheckForNull final String input) {
return StringUtils.defaultString(input).toUpperCase(Locale.ENGLISH);
}
}

2 changes: 2 additions & 0 deletions src/main/java/edu/hm/hafner/analysis/LookaheadParser.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis;

import java.io.Serial;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Optional;
Expand All @@ -21,6 +22,7 @@
* @author Ullrich Hafner
*/
public abstract class LookaheadParser extends IssueParser {
@Serial
private static final long serialVersionUID = 3240719494150024894L;

/** Pattern identifying an ant task debug output prefix. */
Expand Down
1 change: 0 additions & 1 deletion src/main/java/edu/hm/hafner/analysis/ModuleDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,3 @@ public interface FileSystem {
InputStream open(String fileName) throws IOException, InvalidPathException;
}
}

Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package edu.hm.hafner.analysis;

import java.io.Serial;

/**
* Indicates that parsing has been canceled due to a user initiated interrupt.
*
* @author Ullrich Hafner
*/
public class ParsingCanceledException extends RuntimeException {
@Serial
private static final long serialVersionUID = 3341274949787014225L;

/**
Expand All @@ -25,4 +28,3 @@ public ParsingCanceledException(final Throwable cause) {
super("Canceling parsing since build has been aborted.", cause);
}
}

3 changes: 3 additions & 0 deletions src/main/java/edu/hm/hafner/analysis/ParsingException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package edu.hm.hafner.analysis;

import java.io.Serial;

import org.apache.commons.lang3.exception.ExceptionUtils;

import com.google.errorprone.annotations.FormatMethod;
Expand All @@ -10,6 +12,7 @@
* @author Ullrich Hafner
*/
public class ParsingException extends RuntimeException {
@Serial
private static final long serialVersionUID = -9016364685084958944L;

/**
Expand Down
1 change: 0 additions & 1 deletion src/main/java/edu/hm/hafner/analysis/ReaderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,3 @@ public void parse(final DefaultHandler handler) {
}
}
}

4 changes: 3 additions & 1 deletion src/main/java/edu/hm/hafner/analysis/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintStream;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -60,6 +61,7 @@
@SuppressWarnings({"PMD.ExcessivePublicCount", "PMD.ExcessiveClassLength", "PMD.GodClass", "PMD.CognitiveComplexity", "PMD.CyclomaticComplexity", "checkstyle:ClassFanOutComplexity"})
// TODO: provide a readResolve method to check the instance and improve the performance (TreeString, etc.)
public class Report implements Iterable<Issue>, Serializable {
@Serial
private static final long serialVersionUID = 4L; // release 10.0.0

@VisibleForTesting
Expand All @@ -81,7 +83,7 @@ public class Report implements Iterable<Issue>, Serializable {
@CheckForNull @SuppressWarnings({"all", "UnusedVariable"})
private transient Map<String, String> namesByOrigin; // Not needed anymore since 10.0.0

private int duplicatesSize = 0;
private int duplicatesSize;

/**
* Creates an empty {@link Report}.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/hm/hafner/analysis/RevApiInfoExtension.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis;

import java.io.Serial;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -13,6 +14,7 @@
*/
@SuppressWarnings("PMD.DataClass")
public final class RevApiInfoExtension implements Serializable {
@Serial
private static final long serialVersionUID = 6058160289391492934L;
private final Map<String, String> severities = new HashMap<>();
private final String issueName;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/hm/hafner/analysis/Severity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis;

import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -28,6 +29,7 @@
*/
@Immutable
public class Severity implements Serializable {
@Serial
private static final long serialVersionUID = 8921726169259131484L;

/** An error, e.g. a compile error. */
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/hm/hafner/analysis/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
package edu.hm.hafner.analysis;

import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.NonNull;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis.parser;

import java.io.Serial;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -14,6 +15,7 @@
* @author Jagruti Tiwari
*/
public abstract class AbstractMavenLogParser extends LookaheadParser {
@Serial
private static final long serialVersionUID = -3768790896172545192L;

/** Regular expression to parse the start of maven plugin in console. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis.parser;

import java.io.Serial;
import java.util.Optional;
import java.util.regex.Matcher;

Expand All @@ -16,6 +17,7 @@
* @author jerryshea
*/
public class AcuCobolParser extends LookaheadParser {
@Serial
private static final long serialVersionUID = -894639209290549425L;

private static final String ACU_COBOL_WARNING_PATTERN = "^\\s*(\\[.*\\])?\\s*?(.*), line ([0-9]*): Warning: (.*)$";
Expand All @@ -42,4 +44,3 @@ protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStre
.buildOptional();
}
}

2 changes: 2 additions & 0 deletions src/main/java/edu/hm/hafner/analysis/parser/AjcParser.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis.parser;

import java.io.Serial;
import java.io.UncheckedIOException;
import java.util.Iterator;
import java.util.regex.Pattern;
Expand All @@ -18,6 +19,7 @@
* @author Tom Diamond
*/
public class AjcParser extends IssueParser {
@Serial
private static final long serialVersionUID = -9123765511497052454L;

private static final Pattern ESCAPE_CHARACTERS = Pattern.compile((char) 27 + "\\[.*" + (char) 27 + "\\[0m");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis.parser;

import java.io.Serial;
import java.util.Optional;
import java.util.regex.Matcher;

Expand All @@ -19,6 +20,7 @@
* @author Ce Qi
*/
public class AnsibleLintParser extends LookaheadParser {
@Serial
private static final long serialVersionUID = 8481090596321427484L;

private static final String ANSIBLE_LINT_WARNING_PATTERN = "(?<file>.*)\\:(?<lineno>[0-9]*)\\:\\s*(\\[(?<cat>[a-zA-Z0-9\\-\\[\\]]+)\\]|(?<newcat>[^\\[][a-zA-Z0-9\\[\\]\\-]+)):?\\s(?<msg>.*)";
Expand Down Expand Up @@ -57,4 +59,3 @@ protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStre
.buildOptional();
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis.parser;

import java.io.Serial;
import java.util.Optional;
import java.util.regex.Matcher;

Expand All @@ -18,6 +19,7 @@
* @author Ullrich Hafner
*/
public class AntJavacParser extends AbstractMavenLogParser {
@Serial
private static final long serialVersionUID = 1737791073711198075L;

private static final String ANT_JAVAC_WARNING_PATTERN = ANT_TASK + "\\s*(.*java):(\\d*):\\s*"
Expand Down Expand Up @@ -73,4 +75,3 @@ private Severity mapSeverity(final String type) {
return equalsIgnoreCase(type, "error") ? Severity.ERROR : Severity.WARNING_NORMAL;
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package edu.hm.hafner.analysis.parser;

import java.io.Serial;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
Expand All @@ -22,6 +24,7 @@ public class AquaScannerParser extends JsonIssueParser {
private static final String AQUA_VULNERABILITY_LEVEL_TAG_MEDIUM = "medium";
private static final String AQUA_VULNERABILITY_LEVEL_TAG_LOW = "low";
private static final String AQUA_VULNERABILITY_LEVEL_TAG_NEGLIGIBLE = "negligible";
@Serial
private static final long serialVersionUID = 1L;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis.parser;

import java.io.Serial;
import java.util.Optional;
import java.util.regex.Matcher;

Expand All @@ -15,6 +16,7 @@
* @author Dmytro Kutianskyi
*/
public class Armcc5CompilerParser extends LookaheadParser {
@Serial
private static final long serialVersionUID = -2677728927938443701L;

private static final String ARMCC5_WARNING_PATTERN = "^(.+)\\((\\d+)\\): (warning|error): #(.+): (.+)$";
Expand Down Expand Up @@ -52,4 +54,3 @@ protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStre
.setSeverity(priority).buildOptional();
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.hm.hafner.analysis.parser;

import java.io.Serial;
import java.util.Optional;
import java.util.regex.Matcher;

Expand All @@ -17,6 +18,7 @@
* @author Emanuele Zattin
*/
public class ArmccCompilerParser extends LookaheadParser {
@Serial
private static final long serialVersionUID = -2677728927938443703L;

private static final String ARMCC_WARNING_PATTERN = "^\"(.+)\", line (\\d+): ([A-Z][a-z]+):\\D*(\\d+)\\D*?:\\s+(.+)$";
Expand Down Expand Up @@ -47,4 +49,3 @@ protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStre
.setSeverity(priority).buildOptional();
}
}

Loading

0 comments on commit 1a306f2

Please sign in to comment.