Skip to content

Commit

Permalink
Apply the remaining recipes of OpenRewrite.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Nov 19, 2024
1 parent f3f24a9 commit 00361f9
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 26 deletions.
4 changes: 2 additions & 2 deletions etc/Jenkinsfile.parallel.declarative
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pipeline {
}
post {
always {
recordIssues tools: [[tool: java()],
[tool: javaDoc()],
recordIssues tools: [[tool: java()],
[tool: javaDoc()],
[tool: taskScanner(includePattern:'**/*.java', highTags:'FIXME', normalTags:'TODO')]]
}
}
Expand Down
15 changes: 0 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,6 @@

<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>${rewrite-maven-plugin.version}</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>
<recipe>org.openrewrite.java.migrate.util.SequencedCollection</recipe>
<recipe>org.openrewrite.java.migrate.lang.var.UseVarForObject</recipe>
<recipe>org.openrewrite.java.migrate.net.JavaNetAPIs</recipe>
<recipe>org.openrewrite.java.migrate.util.JavaUtilAPIs</recipe>
<recipe>org.openrewrite.java.migrate.lang.StringRulesRecipes</recipe>
</activeRecipes>
</configuration>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/edu/hm/hafner/analysis/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,7 @@ public IssueFilterBuilder setExcludeFileNameFilter(final Collection<String> patt
public IssueFilterBuilder setExcludeFileNameFilter(final String... patterns) {
return setExcludeFileNameFilter(Arrays.asList(patterns));
}

//</editor-fold>

//<editor-fold desc="Package name">
Expand Down Expand Up @@ -1423,6 +1424,7 @@ public IssueFilterBuilder setExcludePackageNameFilter(final Collection<String> p
public IssueFilterBuilder setExcludePackageNameFilter(final String... patterns) {
return setExcludePackageNameFilter(Arrays.asList(patterns));
}

//</editor-fold>

//<editor-fold desc="Module name">
Expand Down Expand Up @@ -1480,6 +1482,7 @@ public IssueFilterBuilder setExcludeModuleNameFilter(final Collection<String> pa
public IssueFilterBuilder setExcludeModuleNameFilter(final String... patterns) {
return setExcludeModuleNameFilter(Arrays.asList(patterns));
}

//</editor-fold>

//<editor-fold desc="Category">
Expand Down Expand Up @@ -1537,6 +1540,7 @@ public IssueFilterBuilder setExcludeCategoryFilter(final Collection<String> patt
public IssueFilterBuilder setExcludeCategoryFilter(final String... patterns) {
return setExcludeCategoryFilter(Arrays.asList(patterns));
}

//</editor-fold>

//<editor-fold desc="Type">
Expand Down Expand Up @@ -1594,6 +1598,7 @@ public IssueFilterBuilder setExcludeTypeFilter(final Collection<String> patterns
public IssueFilterBuilder setExcludeTypeFilter(final String... patterns) {
return setExcludeTypeFilter(Arrays.asList(patterns));
}

//</editor-fold>

//<editor-fold desc="Message">
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/edu/hm/hafner/analysis/parser/pmd/Violation.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,64 +33,83 @@ public class Violation {
public String getRule() {
return rule;
}

public void setRule(final String rule) {
this.rule = rule;
}

@CheckForNull
public String getRuleset() {
return ruleset;
}

public void setRuleset(final String ruleset) {
this.ruleset = ruleset;
}

@CheckForNull
public String getExternalInfoUrl() {
return externalInfoUrl;
}

public void setExternalInfoUrl(final String externalInfoUrl) {
this.externalInfoUrl = externalInfoUrl;
}

@CheckForNull
public String getPackage() {
return javaPackage;
}

public void setPackage(final String packageName) {
javaPackage = packageName;
}

public int getPriority() {
return priority;
}

public void setPriority(final int priority) {
this.priority = priority;
}

@CheckForNull
public String getMessage() {
return message;
}

public void setMessage(final String message) {
this.message = message;
}

public int getBeginline() {
return beginline;
}

public void setBeginline(final int beginline) {
this.beginline = beginline;
}

public int getEndline() {
return endline;
}

public void setEndline(final int endline) {
this.endline = endline;
}

public int getEndcolumn() {
return endcolumn;
}

public void setEndcolumn(final int endcolumn) {
this.endcolumn = endcolumn;
}

public int getBegincolumn() {
return begincolumn;
}

public void setBegincolumn(final int begincolumn) {
this.begincolumn = begincolumn;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package edu.hm.hafner.analysis;

import java.util.List;


import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Scope;
Expand All @@ -10,8 +13,6 @@
import edu.hm.hafner.util.LineRange;
import edu.hm.hafner.util.LineRangeList;

import static java.util.Collections.*;

/**
* Performance benchmarks for the class {@link IssueDifference}.
*
Expand Down Expand Up @@ -86,7 +87,7 @@ private Issue createIssue(final String message, final String fingerprint) {
.setMessage(message)
.setDescription("description")
.setOrigin("origin")
.setLineRanges(new LineRangeList(singletonList(new LineRange(5, 6))))
.setLineRanges(new LineRangeList(List.of(new LineRange(5, 6))))
.setFingerprint(fingerprint)
.setReference(REFERENCE_BUILD);
return builder.build();
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/edu/hm/hafner/analysis/IssueDifferenceTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.hm.hafner.analysis;

import java.nio.charset.StandardCharsets;
import java.util.List;

import org.junit.jupiter.api.Test;

Expand All @@ -10,7 +11,6 @@
import edu.hm.hafner.util.ResourceTest;

import static edu.hm.hafner.analysis.assertions.Assertions.*;
import static java.util.Collections.*;

/**
* Unit Tests of the class {@link IssueDifference}.
Expand Down Expand Up @@ -174,7 +174,7 @@ private Issue createIssue(final String message, final String fingerprint, final
.setMessage(message)
.setDescription("description")
.setOrigin("origin")
.setLineRanges(new LineRangeList(singletonList(new LineRange(5, 6))))
.setLineRanges(new LineRangeList(List.of(new LineRange(5, 6))))
.setFingerprint(fingerprint)
.setReference(REFERENCE_BUILD);
return builder.build();
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/edu/hm/hafner/analysis/IssueTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.hm.hafner.analysis;

import java.io.IOException;
import java.util.List;
import java.util.UUID;

import org.junit.jupiter.api.Test;
Expand All @@ -16,7 +17,6 @@
import nl.jqno.equalsverifier.EqualsVerifier;

import static edu.hm.hafner.analysis.assertions.Assertions.*;
import static java.util.Collections.*;

/**
* Unit tests for {@link Issue}.
Expand Down Expand Up @@ -55,7 +55,7 @@ class IssueTest extends SerializableTest<Issue> {
static final String ORIGIN_NAME = "Origin";
static final String REFERENCE = "reference";
static final String ADDITIONAL_PROPERTIES = "additional";
static final LineRangeList LINE_RANGES = new LineRangeList(singletonList(new LineRange(5, 6)));
static final LineRangeList LINE_RANGES = new LineRangeList(List.of(new LineRange(5, 6)));
private static final String WINDOWS_PATH = "C:/Windows";

@Test
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/edu/hm/hafner/analysis/ReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -608,7 +607,7 @@ void shouldThrowExceptionWhenRemovingWithWrongKey() {
@Test
void shouldFindIfOnlyOneIssue() {
var report = new Report();
report.addAll(Collections.singletonList(HIGH));
report.addAll(List.of(HIGH));

var found = report.findById(HIGH.getId());

Expand Down

0 comments on commit 00361f9

Please sign in to comment.