From 02a9cb2653e61781b05deb9cf55bbc08c0ee3af9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Mar 2021 06:51:55 +0000 Subject: [PATCH 1/5] Bump analysis-pom from 4.7.0 to 5.0.0 Bumps [analysis-pom](https://github.com/jenkinsci/analysis-pom-plugin) from 4.7.0 to 5.0.0. - [Release notes](https://github.com/jenkinsci/analysis-pom-plugin/releases) - [Changelog](https://github.com/jenkinsci/analysis-pom-plugin/blob/master/CHANGELOG.md) - [Commits](https://github.com/jenkinsci/analysis-pom-plugin/compare/v4.7.0...v5.0.0) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 118b3bcc..56bdf874 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.jvnet.hudson.plugins analysis-pom - 4.7.0 + 5.0.0 From d321001a1930d4dcd8c95b7928c38e78baff6fe3 Mon Sep 17 00:00:00 2001 From: Kezhi Xiong Date: Tue, 2 Mar 2021 21:34:43 +0800 Subject: [PATCH 2/5] Ignore dependencies in rev-api check. --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 56bdf874..3c932241 100644 --- a/pom.xml +++ b/pom.xml @@ -116,6 +116,7 @@ revapi-maven-plugin \d+\.\d+\.\d+ + false @@ -124,6 +125,11 @@ 1 Adding actions list with an initial empty value should not break the compatibility. + + true + java.missing.* + Dependencies are not being checked, so they are reported as missing + From 48b0702d363084cab248723a94a1152a259c592a Mon Sep 17 00:00:00 2001 From: Kezhi Xiong Date: Tue, 2 Mar 2021 23:34:45 +0800 Subject: [PATCH 3/5] Suppress spotbugs warnings --- .../java/io/jenkins/plugins/checks/api/ChecksAnnotation.java | 4 ++++ .../java/io/jenkins/plugins/checks/api/ChecksDetails.java | 4 ++++ .../java/io/jenkins/plugins/checks/api/ChecksOutput.java | 4 ++++ .../io/jenkins/plugins/checks/steps/PublishChecksStep.java | 3 +++ .../java/io/jenkins/plugins/checks/steps/WithChecksStep.java | 5 +++-- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java b/src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java index 51fa01e3..3d5641db 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java @@ -1,5 +1,7 @@ package io.jenkins.plugins.checks.api; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.util.Optional; import static java.util.Objects.*; @@ -129,6 +131,8 @@ public static class ChecksAnnotationBuilder { /** * Constructs a builder for {@link ChecksAnnotation}. */ + @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", + justification = "Null values are a reasonable state implying the user doesn't specify it.") public ChecksAnnotationBuilder() { this.annotationLevel = ChecksAnnotationLevel.NONE; } diff --git a/src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java b/src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java index e3554ed7..c1a37aa7 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java @@ -1,5 +1,7 @@ package io.jenkins.plugins.checks.api; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Collections; @@ -138,6 +140,8 @@ public static class ChecksDetailsBuilder { /** * Construct a builder for {@link ChecksDetails}. */ + @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", + justification = "Null values are a reasonable state implying the user doesn't specify it.") public ChecksDetailsBuilder() { this.conclusion = ChecksConclusion.NONE; this.actions = new ArrayList<>(); diff --git a/src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java b/src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java index 4d11209a..b077bb73 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java @@ -1,5 +1,7 @@ package io.jenkins.plugins.checks.api; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -105,6 +107,8 @@ public static class ChecksOutputBuilder { * Construct a builder for a {@link ChecksOutput}. * */ + @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", + justification = "Null values are a reasonable state implying the user doesn't specify it.") public ChecksOutputBuilder() { this.annotations = new ArrayList<>(); this.images = new ArrayList<>(); diff --git a/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java b/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java index 5e62ff75..113abf66 100644 --- a/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java +++ b/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java @@ -2,6 +2,7 @@ import edu.hm.hafner.util.VisibleForTesting; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.Extension; import hudson.model.AbstractDescribableImpl; import hudson.model.Descriptor; @@ -270,6 +271,8 @@ public static class StepChecksAnnotation extends AbstractDescribableImpl Date: Wed, 3 Mar 2021 01:12:57 +0800 Subject: [PATCH 4/5] Use @CheckForNull for builder fields. --- .../plugins/checks/api/ChecksAnnotation.java | 38 +++++++++++++------ .../plugins/checks/api/ChecksDetails.java | 32 +++++++++++----- .../plugins/checks/api/ChecksOutput.java | 17 ++++++--- .../checks/steps/PublishChecksStep.java | 12 ++++-- .../plugins/checks/steps/WithChecksStep.java | 2 +- 5 files changed, 70 insertions(+), 31 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java b/src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java index 3d5641db..240997fb 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java @@ -1,6 +1,6 @@ package io.jenkins.plugins.checks.api; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.util.Optional; @@ -11,24 +11,31 @@ */ @SuppressWarnings("PMD.DataClass") public class ChecksAnnotation { + @CheckForNull private final String path; + @CheckForNull private final Integer startLine; + @CheckForNull private final Integer endLine; - private final ChecksAnnotationLevel annotationLevel; + @CheckForNull private final String message; + @CheckForNull private final Integer startColumn; + @CheckForNull private final Integer endColumn; + @CheckForNull private final String title; + @CheckForNull private final String rawDetails; + private final ChecksAnnotationLevel annotationLevel; + @SuppressWarnings("ParameterNumber") - private ChecksAnnotation(final String path, - final Integer startLine, final Integer endLine, - final ChecksAnnotationLevel annotationLevel, - final String message, - final Integer startColumn, final Integer endColumn, - final String title, - final String rawDetails) { + private ChecksAnnotation(@CheckForNull final String path, + @CheckForNull final Integer startLine, @CheckForNull final Integer endLine, + final ChecksAnnotationLevel annotationLevel, @CheckForNull final String message, + @CheckForNull final Integer startColumn, @CheckForNull final Integer endColumn, + @CheckForNull final String title, @CheckForNull final String rawDetails) { this.path = path; this.startLine = startLine; this.endLine = endLine; @@ -118,21 +125,28 @@ public String toString() { * Builder for {@link ChecksAnnotation}. */ public static class ChecksAnnotationBuilder { + @CheckForNull private String path; + @CheckForNull private Integer startLine; + @CheckForNull private Integer endLine; - private ChecksAnnotationLevel annotationLevel; + @CheckForNull private String message; + @CheckForNull private Integer startColumn; + @CheckForNull private Integer endColumn; + @CheckForNull private String title; + @CheckForNull private String rawDetails; + private ChecksAnnotationLevel annotationLevel; + /** * Constructs a builder for {@link ChecksAnnotation}. */ - @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", - justification = "Null values are a reasonable state implying the user doesn't specify it.") public ChecksAnnotationBuilder() { this.annotationLevel = ChecksAnnotationLevel.NONE; } diff --git a/src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java b/src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java index c1a37aa7..0060b0d7 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java @@ -1,6 +1,6 @@ package io.jenkins.plugins.checks.api; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.time.LocalDateTime; import java.util.ArrayList; @@ -15,19 +15,26 @@ */ @SuppressWarnings("PMD.DataClass") public class ChecksDetails { + @CheckForNull private final String name; - private final ChecksStatus status; + @CheckForNull private final String detailsURL; + @CheckForNull private final LocalDateTime startedAt; - private final ChecksConclusion conclusion; + @CheckForNull private final LocalDateTime completedAt; + @CheckForNull private final ChecksOutput output; + + private final ChecksStatus status; + private final ChecksConclusion conclusion; private final List actions; @SuppressWarnings("ParameterNumber") - private ChecksDetails(final String name, final ChecksStatus status, final String detailsURL, - final LocalDateTime startedAt, final ChecksConclusion conclusion, final LocalDateTime completedAt, - final ChecksOutput output, final List actions) { + private ChecksDetails(@CheckForNull final String name, final ChecksStatus status, + @CheckForNull final String detailsURL, @CheckForNull final LocalDateTime startedAt, + final ChecksConclusion conclusion, @CheckForNull final LocalDateTime completedAt, + @CheckForNull final ChecksOutput output, final List actions) { this.name = name; this.status = status; this.detailsURL = detailsURL; @@ -128,21 +135,26 @@ public String toString() { * Builder for {@link ChecksDetails}. */ public static class ChecksDetailsBuilder { + @CheckForNull private String name; - private ChecksStatus status; + @CheckForNull private String detailsURL; + @CheckForNull private LocalDateTime startedAt; - private ChecksConclusion conclusion; + @CheckForNull private LocalDateTime completedAt; + @CheckForNull private ChecksOutput output; + + private ChecksStatus status; + private ChecksConclusion conclusion; private List actions; /** * Construct a builder for {@link ChecksDetails}. */ - @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", - justification = "Null values are a reasonable state implying the user doesn't specify it.") public ChecksDetailsBuilder() { + this.status = ChecksStatus.NONE; this.conclusion = ChecksConclusion.NONE; this.actions = new ArrayList<>(); } diff --git a/src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java b/src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java index b077bb73..1f9b4416 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java @@ -1,6 +1,6 @@ package io.jenkins.plugins.checks.api; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.util.ArrayList; import java.util.Collections; @@ -14,14 +14,19 @@ * annotations, etc. */ public class ChecksOutput { + @CheckForNull private final String title; + @CheckForNull private final TruncatedString summary; + @CheckForNull private final TruncatedString text; + private final List annotations; private final List images; - private ChecksOutput(final String title, final TruncatedString summary, final TruncatedString text, - final List annotations, final List images) { + private ChecksOutput(@CheckForNull final String title, @CheckForNull final TruncatedString summary, + @CheckForNull final TruncatedString text, final List annotations, + final List images) { this.title = title; this.summary = summary; this.text = text; @@ -97,9 +102,13 @@ public String toString() { * Builder for {@link ChecksOutput}. */ public static class ChecksOutputBuilder { + @CheckForNull private String title; + @CheckForNull private TruncatedString summary; + @CheckForNull private TruncatedString text; + private List annotations; private List images; @@ -107,8 +116,6 @@ public static class ChecksOutputBuilder { * Construct a builder for a {@link ChecksOutput}. * */ - @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", - justification = "Null values are a reasonable state implying the user doesn't specify it.") public ChecksOutputBuilder() { this.annotations = new ArrayList<>(); this.images = new ArrayList<>(); diff --git a/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java b/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java index 113abf66..f8e26a4f 100644 --- a/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java +++ b/src/main/java/io/jenkins/plugins/checks/steps/PublishChecksStep.java @@ -1,8 +1,8 @@ package io.jenkins.plugins.checks.steps; import edu.hm.hafner.util.VisibleForTesting; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.Extension; import hudson.model.AbstractDescribableImpl; import hudson.model.Descriptor; @@ -251,9 +251,13 @@ public static class StepChecksAnnotation extends AbstractDescribableImpl Date: Wed, 3 Mar 2021 01:47:15 +0800 Subject: [PATCH 5/5] Refactor WithChecksCallBack --- .../jenkins/plugins/checks/steps/WithChecksStep.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/checks/steps/WithChecksStep.java b/src/main/java/io/jenkins/plugins/checks/steps/WithChecksStep.java index 0962c7a3..af4f3160 100644 --- a/src/main/java/io/jenkins/plugins/checks/steps/WithChecksStep.java +++ b/src/main/java/io/jenkins/plugins/checks/steps/WithChecksStep.java @@ -96,7 +96,7 @@ public boolean start() { ChecksInfo info = extractChecksInfo(); getContext().newBodyInvoker() .withContext(info) - .withCallback(new WithChecksCallBack(info)) + .withCallback(new WithChecksCallBack(info, this)) .start(); return false; } @@ -154,20 +154,22 @@ private boolean publish(final StepContext context, final ChecksDetails.ChecksDet return true; } - class WithChecksCallBack extends BodyExecutionCallback { + static class WithChecksCallBack extends BodyExecutionCallback { private static final long serialVersionUID = 1L; private final ChecksInfo info; + private final WithChecksStepExecution execution; - WithChecksCallBack(final ChecksInfo info) { + WithChecksCallBack(final ChecksInfo info, final WithChecksStepExecution execution) { super(); this.info = info; + this.execution = execution; } @Override public void onStart(final StepContext context) { - publish(context, new ChecksDetails.ChecksDetailsBuilder() + execution.publish(context, new ChecksDetails.ChecksDetailsBuilder() .withName(info.getName()) .withStatus(ChecksStatus.IN_PROGRESS) .withConclusion(ChecksConclusion.NONE)); @@ -204,7 +206,7 @@ public void onFailure(final StepContext context, final Throwable t) { .withTitle("Failed") .withText(t.toString()).build()); } - publish(context, builder); + execution.publish(context, builder); context.onFailure(t); } }