Skip to content

Commit

Permalink
Suppress warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
XiongKezhi committed Aug 1, 2020
1 parent 6d4656b commit 3bbee7a
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/jenkins/plugins/checks/api/ChecksAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/io/jenkins/plugins/checks/api/ChecksAnnotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/jenkins/plugins/checks/api/ChecksDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,6 +26,7 @@ public class ChecksDetails {
private final ChecksOutput output;
private final List<ChecksAction> 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<ChecksAction> actions) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<ChecksAction> actions) {
this.actions = new ArrayList<>(requireNonNull(actions));
return this;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/jenkins/plugins/checks/api/ChecksImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<ChecksAnnotation> annotations) {
this.annotations = new ArrayList<>(requireNonNull(annotations));
return this;
Expand All @@ -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<ChecksImage> images) {
this.images = new ArrayList<>(requireNonNull(images));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand Down

0 comments on commit 3bbee7a

Please sign in to comment.