diff --git a/src/main/java/io/jenkins/plugins/checks/BuildStatusChecksPublisher.java b/src/main/java/io/jenkins/plugins/checks/BuildStatusChecksPublisher.java index b7694c0b..91608e92 100644 --- a/src/main/java/io/jenkins/plugins/checks/BuildStatusChecksPublisher.java +++ b/src/main/java/io/jenkins/plugins/checks/BuildStatusChecksPublisher.java @@ -45,7 +45,7 @@ public static class JobScheduledListener extends QueueListener { * When a job enters queue, creates the check on "queued". */ @Override - public void onEnterWaiting(Queue.WaitingItem wi) { + public void onEnterWaiting(final Queue.WaitingItem wi) { publish(ChecksPublisherFactory.fromItem(wi), ChecksStatus.QUEUED, ChecksConclusion.NONE); } } diff --git a/src/main/java/io/jenkins/plugins/checks/api/ChecksAction.java b/src/main/java/io/jenkins/plugins/checks/api/ChecksAction.java index 3d9c3b46..b153be98 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksAction.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksAction.java @@ -4,6 +4,7 @@ import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.Beta; @@ -31,6 +32,7 @@ public class ChecksAction { * @param identifier * a reference for the action on the integrator's system */ + @SuppressFBWarnings("NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE") public ChecksAction(@Nullable final String label, @Nullable final String description, @Nullable final String identifier) { this.label = label; 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 c22d1f2f..3f0645f7 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java @@ -11,6 +11,7 @@ * An annotation for specific lines of code. */ @Restricted(Beta.class) +@SuppressWarnings("PMD.DataClass") public class ChecksAnnotation { private final String path; private final Integer startLine; @@ -22,6 +23,7 @@ public class ChecksAnnotation { private final String title; private final String rawDetails; + @SuppressWarnings("ParameterNumber") private ChecksAnnotation(final String path, final Integer startLine, final Integer endLine, final ChecksAnnotationLevel annotationLevel, @@ -128,6 +130,7 @@ public ChecksAnnotationBuilder() { * e.g. src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksAnnotationBuilder withPath(final String path) { this.path = requireNonNull(path); return this; @@ -153,6 +156,7 @@ public ChecksAnnotationBuilder withLine(final int line) { * the start line of code to annotate * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksAnnotationBuilder withStartLine(final Integer startLine) { this.startLine = requireNonNull(startLine); return this; @@ -165,6 +169,7 @@ public ChecksAnnotationBuilder withStartLine(final Integer startLine) { * the end line of code to annotate * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksAnnotationBuilder withEndLine(final Integer endLine) { this.endLine = requireNonNull(endLine); return this; @@ -178,6 +183,7 @@ public ChecksAnnotationBuilder withEndLine(final Integer endLine) { * the annotation level * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksAnnotationBuilder withAnnotationLevel(final ChecksAnnotationLevel level) { this.annotationLevel = requireNonNull(level); return this; @@ -190,6 +196,7 @@ public ChecksAnnotationBuilder withAnnotationLevel(final ChecksAnnotationLevel l * a short description * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksAnnotationBuilder withMessage(final String message) { this.message = requireNonNull(message); return this; @@ -202,6 +209,7 @@ public ChecksAnnotationBuilder withMessage(final String message) { * the start column of the annotation * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksAnnotationBuilder withStartColumn(final Integer startColumn) { this.startColumn = requireNonNull(startColumn); return this; @@ -214,6 +222,7 @@ public ChecksAnnotationBuilder withStartColumn(final Integer startColumn) { * the end column of the annotation * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksAnnotationBuilder withEndColumn(final Integer endColumn) { this.endColumn = requireNonNull(endColumn); return this; @@ -230,6 +239,7 @@ public ChecksAnnotationBuilder withEndColumn(final Integer endColumn) { * the title of the annotation * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksAnnotationBuilder withTitle(final String title) { this.title = requireNonNull(title); return this; @@ -246,6 +256,7 @@ public ChecksAnnotationBuilder withTitle(final String title) { * the details about this annotation * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksAnnotationBuilder withRawDetails(final String rawDetails) { this.rawDetails = requireNonNull(rawDetails); return this; 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 b2280dd9..006fb8ad 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java @@ -15,6 +15,7 @@ * Details of a check. This class is a top class which contains all parameters needed for a check. */ @Restricted(Beta.class) +@SuppressWarnings("PMD.DataClass") public class ChecksDetails { private final String name; private final ChecksStatus status; @@ -25,6 +26,7 @@ public class ChecksDetails { private final ChecksOutput output; 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) { @@ -144,6 +146,7 @@ public ChecksDetailsBuilder() { * @return this builder * @throws NullPointerException if the {@code name} is null */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksDetailsBuilder withName(final String name) { this.name = requireNonNull(name); return this; @@ -161,6 +164,7 @@ public ChecksDetailsBuilder withName(final String name) { * @return this builder * @throws NullPointerException if the {@code status} is null */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksDetailsBuilder withStatus(final ChecksStatus status) { this.status = requireNonNull(status); return this; @@ -183,6 +187,7 @@ public ChecksDetailsBuilder withStatus(final ChecksStatus status) { * @return this builder * @throws NullPointerException if the {@code detailsURL} is null */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksDetailsBuilder withDetailsURL(final String detailsURL) { this.detailsURL = requireNonNull(detailsURL); return this; @@ -196,6 +201,7 @@ public ChecksDetailsBuilder withDetailsURL(final String detailsURL) { * @return this builder * @throws NullPointerException if the {@code startAt} is null */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksDetailsBuilder withStartedAt(final LocalDateTime startedAt) { this.startedAt = requireNonNull(startedAt); return this; @@ -214,6 +220,7 @@ public ChecksDetailsBuilder withStartedAt(final LocalDateTime startedAt) { * @return this builder * @throws NullPointerException if the {@code conclusion} is null */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksDetailsBuilder withConclusion(final ChecksConclusion conclusion) { this.conclusion = requireNonNull(conclusion); return this; @@ -227,6 +234,7 @@ public ChecksDetailsBuilder withConclusion(final ChecksConclusion conclusion) { * @return this builder * @throws NullPointerException if the {@code completedAt} is null */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksDetailsBuilder withCompletedAt(final LocalDateTime completedAt) { this.completedAt = requireNonNull(completedAt); return this; @@ -240,6 +248,7 @@ public ChecksDetailsBuilder withCompletedAt(final LocalDateTime completedAt) { * @return this builder * @throws NullPointerException if the {@code outputs} is null */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksDetailsBuilder withOutput(final ChecksOutput output) { this.output = new ChecksOutput(requireNonNull(output)); return this; @@ -253,6 +262,7 @@ public ChecksDetailsBuilder withOutput(final ChecksOutput output) { * @return this builder * @throws NullPointerException if the {@code actions} is null */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksDetailsBuilder withActions(final List actions) { this.actions = new ArrayList<>(requireNonNull(actions)); return this; diff --git a/src/main/java/io/jenkins/plugins/checks/api/ChecksImage.java b/src/main/java/io/jenkins/plugins/checks/api/ChecksImage.java index f0907fd6..2d4b5d2d 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksImage.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksImage.java @@ -4,6 +4,7 @@ import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.Beta; @@ -26,6 +27,7 @@ public class ChecksImage { * @param caption * a short description of the image */ + @SuppressFBWarnings("NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE") public ChecksImage(@Nullable final String alt, @Nullable final String imageUrl, @Nullable final String caption) { this.alt = alt; this.imageUrl = imageUrl; 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 097e1cd3..0672ee67 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java @@ -88,6 +88,7 @@ public ChecksOutputBuilder() { * the title of the check run * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksOutputBuilder withTitle(final String title) { this.title = requireNonNull(title); return this; @@ -104,6 +105,7 @@ public ChecksOutputBuilder withTitle(final String title) { * the summary of the check run * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksOutputBuilder withSummary(final String summary) { this.summary = requireNonNull(summary); return this; @@ -120,6 +122,7 @@ public ChecksOutputBuilder withSummary(final String summary) { * the details description in Markdown * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksOutputBuilder withText(final String text) { this.text = requireNonNull(text); return this; @@ -132,6 +135,7 @@ public ChecksOutputBuilder withText(final String text) { * the annotations list * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksOutputBuilder withAnnotations(final List annotations) { this.annotations = new ArrayList<>(requireNonNull(annotations)); return this; @@ -155,6 +159,7 @@ public ChecksOutputBuilder addAnnotation(final ChecksAnnotation annotation) { * the images list * @return this builder */ + @SuppressWarnings("HiddenField") // builder pattern public ChecksOutputBuilder withImages(final List images) { this.images = new ArrayList<>(requireNonNull(images)); return this; diff --git a/src/main/java/io/jenkins/plugins/checks/api/ChecksPublisherFactory.java b/src/main/java/io/jenkins/plugins/checks/api/ChecksPublisherFactory.java index 50ecc2ab..22f00e93 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksPublisherFactory.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksPublisherFactory.java @@ -58,7 +58,7 @@ public static ChecksPublisher fromRun(final Run run) { * an item in the queue * @return a publisher suitable for the run */ - public static ChecksPublisher fromItem(Queue.Item item) { + public static ChecksPublisher fromItem(final Queue.Item item) { return findAllPublisherFactories().stream() .map(factory -> factory.createPublisher(item)) .filter(Optional::isPresent) diff --git a/src/test/java/io/jenkins/plugins/checks/api/ChecksPublisherFactoryITest.java b/src/test/java/io/jenkins/plugins/checks/api/ChecksPublisherFactoryITest.java index 45367ea7..7dcbf15c 100644 --- a/src/test/java/io/jenkins/plugins/checks/api/ChecksPublisherFactoryITest.java +++ b/src/test/java/io/jenkins/plugins/checks/api/ChecksPublisherFactoryITest.java @@ -31,6 +31,7 @@ public class ChecksPublisherFactoryITest { * @throws Exception if fails to create freestyle project or build */ @Test + @SuppressWarnings("PMD.SignatureDeclareThrowsException") public void shouldReturnNullChecksPublisherForRunWhenNoImplementationIsProvided() throws Exception { FreeStyleProject job = rule.createFreeStyleProject(); FreeStyleBuild run = rule.buildAndAssertSuccess(job); @@ -46,6 +47,7 @@ public void shouldReturnNullChecksPublisherForRunWhenNoImplementationIsProvided( * @throws Exception if fails to create freestyle project */ @Test + @SuppressWarnings("PMD.SignatureDeclareThrowsException") public void shouldReturnNullChecksPublisherForQueueItemWhenNoImplementationIsProvided() throws Exception { FreeStyleProject job = rule.createFreeStyleProject(); Queue.Item item = new Queue.WaitingItem(Calendar.getInstance(), job, Collections.emptyList());