From 00361f90297fba3aa1fda53bfdca350e97cfe971 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Tue, 19 Nov 2024 19:54:53 +0100 Subject: [PATCH] Apply the remaining recipes of OpenRewrite. --- etc/Jenkinsfile.parallel.declarative | 4 ++-- pom.xml | 15 --------------- .../java/edu/hm/hafner/analysis/Report.java | 5 +++++ .../hafner/analysis/parser/pmd/Violation.java | 19 +++++++++++++++++++ .../analysis/IssueDifferenceBenchmark.java | 7 ++++--- .../hafner/analysis/IssueDifferenceTest.java | 4 ++-- .../edu/hm/hafner/analysis/IssueTest.java | 4 ++-- .../edu/hm/hafner/analysis/ReportTest.java | 3 +-- 8 files changed, 35 insertions(+), 26 deletions(-) diff --git a/etc/Jenkinsfile.parallel.declarative b/etc/Jenkinsfile.parallel.declarative index 9a1dc0996..7237c8a19 100644 --- a/etc/Jenkinsfile.parallel.declarative +++ b/etc/Jenkinsfile.parallel.declarative @@ -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')]] } } diff --git a/pom.xml b/pom.xml index 9c7cacde4..05004e96b 100644 --- a/pom.xml +++ b/pom.xml @@ -292,21 +292,6 @@ - - org.openrewrite.maven - rewrite-maven-plugin - ${rewrite-maven-plugin.version} - - - org.openrewrite.java.migrate.UpgradeToJava17 - org.openrewrite.java.migrate.util.SequencedCollection - org.openrewrite.java.migrate.lang.var.UseVarForObject - org.openrewrite.java.migrate.net.JavaNetAPIs - org.openrewrite.java.migrate.util.JavaUtilAPIs - org.openrewrite.java.migrate.lang.StringRulesRecipes - - - org.owasp dependency-check-maven diff --git a/src/main/java/edu/hm/hafner/analysis/Report.java b/src/main/java/edu/hm/hafner/analysis/Report.java index 957b6d418..ba24fc795 100644 --- a/src/main/java/edu/hm/hafner/analysis/Report.java +++ b/src/main/java/edu/hm/hafner/analysis/Report.java @@ -1366,6 +1366,7 @@ public IssueFilterBuilder setExcludeFileNameFilter(final Collection patt public IssueFilterBuilder setExcludeFileNameFilter(final String... patterns) { return setExcludeFileNameFilter(Arrays.asList(patterns)); } + // // @@ -1423,6 +1424,7 @@ public IssueFilterBuilder setExcludePackageNameFilter(final Collection p public IssueFilterBuilder setExcludePackageNameFilter(final String... patterns) { return setExcludePackageNameFilter(Arrays.asList(patterns)); } + // // @@ -1480,6 +1482,7 @@ public IssueFilterBuilder setExcludeModuleNameFilter(final Collection pa public IssueFilterBuilder setExcludeModuleNameFilter(final String... patterns) { return setExcludeModuleNameFilter(Arrays.asList(patterns)); } + // // @@ -1537,6 +1540,7 @@ public IssueFilterBuilder setExcludeCategoryFilter(final Collection patt public IssueFilterBuilder setExcludeCategoryFilter(final String... patterns) { return setExcludeCategoryFilter(Arrays.asList(patterns)); } + // // @@ -1594,6 +1598,7 @@ public IssueFilterBuilder setExcludeTypeFilter(final Collection patterns public IssueFilterBuilder setExcludeTypeFilter(final String... patterns) { return setExcludeTypeFilter(Arrays.asList(patterns)); } + // // diff --git a/src/main/java/edu/hm/hafner/analysis/parser/pmd/Violation.java b/src/main/java/edu/hm/hafner/analysis/parser/pmd/Violation.java index a814bb8ae..ddecd23fc 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/pmd/Violation.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/pmd/Violation.java @@ -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; } diff --git a/src/test/java/edu/hm/hafner/analysis/IssueDifferenceBenchmark.java b/src/test/java/edu/hm/hafner/analysis/IssueDifferenceBenchmark.java index a0856dec3..4412c9b9e 100644 --- a/src/test/java/edu/hm/hafner/analysis/IssueDifferenceBenchmark.java +++ b/src/test/java/edu/hm/hafner/analysis/IssueDifferenceBenchmark.java @@ -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; @@ -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}. * @@ -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(); diff --git a/src/test/java/edu/hm/hafner/analysis/IssueDifferenceTest.java b/src/test/java/edu/hm/hafner/analysis/IssueDifferenceTest.java index 6cf7344e7..77e1fc99c 100644 --- a/src/test/java/edu/hm/hafner/analysis/IssueDifferenceTest.java +++ b/src/test/java/edu/hm/hafner/analysis/IssueDifferenceTest.java @@ -1,6 +1,7 @@ package edu.hm.hafner.analysis; import java.nio.charset.StandardCharsets; +import java.util.List; import org.junit.jupiter.api.Test; @@ -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}. @@ -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(); diff --git a/src/test/java/edu/hm/hafner/analysis/IssueTest.java b/src/test/java/edu/hm/hafner/analysis/IssueTest.java index 85cbe7202..3bce50fb3 100644 --- a/src/test/java/edu/hm/hafner/analysis/IssueTest.java +++ b/src/test/java/edu/hm/hafner/analysis/IssueTest.java @@ -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; @@ -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}. @@ -55,7 +55,7 @@ class IssueTest extends SerializableTest { 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 diff --git a/src/test/java/edu/hm/hafner/analysis/ReportTest.java b/src/test/java/edu/hm/hafner/analysis/ReportTest.java index 3690da9be..c70e6f7e0 100644 --- a/src/test/java/edu/hm/hafner/analysis/ReportTest.java +++ b/src/test/java/edu/hm/hafner/analysis/ReportTest.java @@ -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; @@ -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());