From 333a5d83aa17e3bd2998ef84652181d8fc5d530a Mon Sep 17 00:00:00 2001 From: offa Date: Tue, 27 Jul 2021 12:28:35 +0200 Subject: [PATCH 1/5] Replace deprecated Json parser API usage. --- .../analysis/warnings/axivion/RemoteAxivionDashboard.java | 2 +- .../plugins/analysis/warnings/axivion/TestDashboard.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/axivion/RemoteAxivionDashboard.java b/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/axivion/RemoteAxivionDashboard.java index b5de8fc335..17b7d3cfc2 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/axivion/RemoteAxivionDashboard.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/axivion/RemoteAxivionDashboard.java @@ -92,7 +92,7 @@ private JsonObject convertToJson(final HttpResponse response) throws IOException throw new ParsingException("Response without a json body"); } try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { - final JsonElement json = new JsonParser().parse(reader); + final JsonElement json = JsonParser.parseReader(reader); if (!json.isJsonObject()) { throw new ParsingException("Invalid response from dashboard. Json object expected."); } diff --git a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/axivion/TestDashboard.java b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/axivion/TestDashboard.java index abf5a94fe8..6cffe04c71 100644 --- a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/axivion/TestDashboard.java +++ b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/axivion/TestDashboard.java @@ -28,7 +28,7 @@ public JsonObject getIssues(final AxIssueKind kind) { JsonObject getIssuesFrom(final String resourcePath) { final URL testCase = this.getClass().getResource(resourcePath); - return new JsonParser().parse(new Resource(testCase).asReader()).getAsJsonObject(); + return JsonParser.parseReader(new Resource(testCase).asReader()).getAsJsonObject(); } private String resolveResourcePath(final AxIssueKind kind) { From 10eb3870d8699d511cc0e8fdfb0f0d49cdf60b00 Mon Sep 17 00:00:00 2001 From: offa Date: Tue, 27 Jul 2021 12:42:12 +0200 Subject: [PATCH 2/5] Replace deprecated AssertJ method call. --- .../analysis/core/steps/WarningChecksPublisherITest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/test/java/io/jenkins/plugins/analysis/core/steps/WarningChecksPublisherITest.java b/plugin/src/test/java/io/jenkins/plugins/analysis/core/steps/WarningChecksPublisherITest.java index 0d5cb216aa..c2738e4124 100644 --- a/plugin/src/test/java/io/jenkins/plugins/analysis/core/steps/WarningChecksPublisherITest.java +++ b/plugin/src/test/java/io/jenkins/plugins/analysis/core/steps/WarningChecksPublisherITest.java @@ -164,7 +164,7 @@ public void shouldParseHtmlMessage() { ChecksDetails details = publisher.extractChecksDetails(AnnotationScope.PUBLISH_NEW_ISSUES); assertThat(details.getOutput().get().getChecksAnnotations()) - .usingElementComparatorOnFields("message") + .usingRecursiveFieldByFieldElementComparatorOnFields("message") .containsOnly(new ChecksAnnotationBuilder() .withMessage("ERROR:\n" + "Some diagnostic messages may contain incorrect line number.\n" From 5730e9927af9e5cc3a096fa665017b075deb5dae Mon Sep 17 00:00:00 2001 From: offa Date: Tue, 27 Jul 2021 12:43:42 +0200 Subject: [PATCH 3/5] Replace unnecessary toString() calls. --- .../jenkins/plugins/analysis/core/steps/AnalysisExecution.java | 2 +- .../plugins/analysis/warnings/tasks/TaskScannerTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/AnalysisExecution.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/AnalysisExecution.java index a5bfddadb0..84adb75c16 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/AnalysisExecution.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/AnalysisExecution.java @@ -43,7 +43,7 @@ abstract class AnalysisExecution extends SynchronousNonBlockingStepExecution< Run run = getContext().get(Run.class); if (run == null) { - throw new IOException("Can't resolve Run for " + toString()); + throw new IOException("Can't resolve Run for " + this); } return run; diff --git a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/tasks/TaskScannerTest.java b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/tasks/TaskScannerTest.java index 9a1f213b31..278c5e11a1 100644 --- a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/tasks/TaskScannerTest.java +++ b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/tasks/TaskScannerTest.java @@ -54,7 +54,7 @@ void shouldHandleMalformedInputException() { Report report = scanner.scan(pathToFile, StandardCharsets.UTF_8); assertThat(report.getErrorMessages()).isNotEmpty().contains("Can't read source file '" - + pathToFile.toString() + + pathToFile + "', defined encoding 'UTF-8' seems to be wrong"); } From d27e9244fbd703f0729aa06f22507ff1548ae4d8 Mon Sep 17 00:00:00 2001 From: offa Date: Tue, 27 Jul 2021 12:46:29 +0200 Subject: [PATCH 4/5] Fix javadoc closing tags. --- .../warnings/steps/ModuleDetectorITest.java | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ModuleDetectorITest.java b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ModuleDetectorITest.java index fe635b760a..db3be507be 100644 --- a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ModuleDetectorITest.java +++ b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ModuleDetectorITest.java @@ -36,50 +36,50 @@ * Maven: * *
- *
pom.xml
- *
a default pom.xml with a valid name tag
- *
m1/pom.xml
+ *
pom.xml
+ *
a default pom.xml with a valid name tag
+ *
m1/pom.xml
*
a default pom.xml with a valid name tag which could be used to detect additional modules in addition to - * the previous mentioned pom.xml
- *
m2/pom.xml
+ * the previous mentioned pom.xml + *
m2/pom.xml
*
a default pom.xml with a valid name tag which could be used to detect additional modules in addition to - * the previous mentioned pom.xml
- *
m3/pom.xml
- *
a broken XML-structure breaks the correct parsing of this file
- *
m4/pom.xml
- *
a pom.xml with an artifactId tag and without a name tag
- *
m5/pom.xml
- *
a pom.xml without an artifactId tag and without a name tag
+ * the previous mentioned pom.xml
+ *
m3/pom.xml
+ *
a broken XML-structure breaks the correct parsing of this file
+ *
m4/pom.xml
+ *
a pom.xml with an artifactId tag and without a name tag
+ *
m5/pom.xml
+ *
a pom.xml without an artifactId tag and without a name tag
*
*

* * Ant: * *

- *
build.xml
- *
a default build.xml with a valid name tag
- *
m1/build.xml
+ *
build.xml
+ *
a default build.xml with a valid name tag
+ *
m1/build.xml
*
a default build.xml with a valid name tag which could be used to detect additional modules in addition - * * to the previous mentioned build.xml
- *
m2/build.xml
- *
a broken XML-structure breaks the correct parsing of this file
- *
m3/build.xml
- *
a build file without the name tag
+ * * to the previous mentioned build.xml
+ *
m2/build.xml
+ *
a broken XML-structure breaks the correct parsing of this file
+ *
m3/build.xml
+ *
a build file without the name tag
*
* * OSGI: * *
- *
META-INF/MANIFEST.MF
- *
a default MANIFEST.MF with a set Bundle-SymbolicName and a set Bundle-Vendor
- *
m1/META-INF/MANIFEST.MF
- *
a MANIFEST.MF with a wildcard Bundle-Name, a set Bundle-SymbolicName and a wildcard
- *
m2/META-INF/MANIFEST.MF
- *
a MANIFEST.MF with a set Bundle-Name and a wildcard Bundle-Vendor
- *
m3/META-INF/MANIFEST.MF
- *
an empty MANIFEST.MF
- *
plugin.properties
- *
a default plugin.properties file
+ *
META-INF/MANIFEST.MF
+ *
a default MANIFEST.MF with a set Bundle-SymbolicName and a set Bundle-Vendor
+ *
m1/META-INF/MANIFEST.MF
+ *
a MANIFEST.MF with a wildcard Bundle-Name, a set Bundle-SymbolicName and a wildcard
+ *
m2/META-INF/MANIFEST.MF
+ *
a MANIFEST.MF with a set Bundle-Name and a wildcard Bundle-Vendor
+ *
m3/META-INF/MANIFEST.MF
+ *
an empty MANIFEST.MF
+ *
plugin.properties
+ *
a default plugin.properties file
*
*

* All tests work the same way: first of all a set of module files will be copied to the workspace. Each module file From 171a62053aaccf131b57c0819bf0ef2677e9e9ba Mon Sep 17 00:00:00 2001 From: offa Date: Tue, 27 Jul 2021 14:55:46 +0200 Subject: [PATCH 5/5] Fix test descriptions. --- .../plugins/analysis/warnings/steps/ParsersITest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java index c9be5c2649..7ef189ab42 100644 --- a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java +++ b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java @@ -112,31 +112,31 @@ public void shouldFindAllIssuesForCheckStyleAlias() { } } - /** Runs the Iar parser on an output file that contains 8 issues. */ + /** Runs the Cmake parser on an output file that contains 8 issues. */ @Test public void shouldFindAllCmakeIssues() { shouldFindIssuesOfTool(8, new Cmake(), "cmake.txt"); } - /** Runs the Iar parser on an output file that contains 2 issues. */ + /** Runs the Cargo parser on an output file that contains 2 issues. */ @Test public void shouldFindAllCargoIssues() { shouldFindIssuesOfTool(2, new Cargo(), "CargoCheck.json"); } - /** Runs the Iar parser on an output file that contains 262 issues. */ + /** Runs the Pmd parser on an output file that contains 262 issues. */ @Test public void shouldFindAllIssuesForPmdAlias() { shouldFindIssuesOfTool(262, new Infer(), "pmd-6.xml"); } - /** Runs the Iar parser on an output file that contains 262 issues. */ + /** Runs the MSBuild parser on an output file that contains 262 issues. */ @Test public void shouldFindAllIssuesForMsBuildAlias() { shouldFindIssuesOfTool(6, new PcLint(), "msbuild.txt"); } - /** Runs the Iar parser on an output file that contains 4 issues. */ + /** Runs the YamlLint parser on an output file that contains 4 issues. */ @Test public void shouldFindAllYamlLintIssues() { shouldFindIssuesOfTool(4, new YamlLint(), "yamllint.txt");