Skip to content

Commit

Permalink
Bump analysis-pom from 5.9.0 to 5.17.0 (#137)
Browse files Browse the repository at this point in the history
* Bump analysis-pom from 5.9.0 to 5.17.0

Bumps [analysis-pom](https://github.com/jenkinsci/analysis-pom-plugin) from 5.9.0 to 5.17.0.
- [Release notes](https://github.com/jenkinsci/analysis-pom-plugin/releases)
- [Changelog](https://github.com/jenkinsci/analysis-pom-plugin/blob/master/CHANGELOG.md)
- [Commits](jenkinsci/analysis-pom-plugin@v5.9.0...v5.17.0)

---
updated-dependencies:
- dependency-name: org.jvnet.hudson.plugins:analysis-pom
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix some JavaDoc warnings.

* Fix some JavaDoc and PMD warnings. Enable PMD quality gate in build.

* Restore old exception message.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ulli Hafner <ullrich.hafner@gmail.com>
  • Loading branch information
dependabot[bot] and uhafner authored Jan 25, 2022
1 parent bbc5ab3 commit d6e1b74
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 132 deletions.
13 changes: 6 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/*
See the documentation for more options:
https://github.com/jenkins-infra/pipeline-library/
*/
def configurations = [
[ platform: "linux", jdk: "8", jenkins: null ],
[ platform: "linux", jdk: "11", jenkins: null, javaLevel: "8" ]
[ platform: "linux", jdk: "11" ],
[ platform: "windows", jdk: "11" ]
]
buildPlugin(configurations: configurations, useAci: true)

buildPlugin(failFast: false, configurations: configurations,
checkstyle: [qualityGates: [[threshold: 1, type: 'NEW', unstable: true]]],
pmd: [qualityGates: [[threshold: 1, type: 'NEW', unstable: true]]] )
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>5.9.0</version>
<version>5.17.0</version>
<relativePath />
</parent>

Expand All @@ -23,7 +23,7 @@
<changelist>-SNAPSHOT</changelist>

<!-- Jenkins Plug-in Dependencies Versions -->
<plugin-util-api.version>2.4.0</plugin-util-api.version>
<plugin-util-api.version>2.6.0</plugin-util-api.version>
<pipeline-stage-step.version>2.5</pipeline-stage-step.version>
</properties>

Expand Down
2 changes: 0 additions & 2 deletions spotbugs-exclusion-filter.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.jenkins.plugins.checks.api;

import edu.umd.cs.findbugs.annotations.CheckForNull;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

import static java.util.Objects.requireNonNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import static java.util.Objects.*;

/**
* Details of a check. This class is a top class which contains all parameters needed for a check.
Expand Down Expand Up @@ -134,6 +134,7 @@ public String toString() {
/**
* Builder for {@link ChecksDetails}.
*/
@SuppressWarnings("ParameterHidesMemberVariable")
public static class ChecksDetailsBuilder {
@CheckForNull
private String name;
Expand Down Expand Up @@ -165,7 +166,7 @@ public ChecksDetailsBuilder() {
* <p>
* Note that for GitHub check runs, the name shown on GitHub UI will be the same as this attribute and
* GitHub uses this attribute to identify a check run, so make sure this name is unique, e.g. "Coverage".
* <p>
* </p>
*
* @param name
* the check's name
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/io/jenkins/plugins/checks/api/ChecksOutput.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.jenkins.plugins.checks.api;

import edu.umd.cs.findbugs.annotations.CheckForNull;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

import static java.util.Objects.requireNonNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import static java.util.Objects.*;

/**
* An output of a check. The output usually contains the most useful information like summary, description,
Expand Down Expand Up @@ -101,6 +101,7 @@ public String toString() {
/**
* Builder for {@link ChecksOutput}.
*/
@SuppressWarnings("ParameterHidesMemberVariable")
public static class ChecksOutputBuilder {
@CheckForNull
private String title;
Expand Down Expand Up @@ -139,7 +140,7 @@ public ChecksOutputBuilder withTitle(final String title) {
*
* <p>
* Note that for the GitHub check runs, the {@code summary} supports Markdown.
* <p>
* </p>
*
* @param summary
* the summary of the check run
Expand All @@ -155,7 +156,7 @@ public ChecksOutputBuilder withSummary(final String summary) {
*
* <p>
* Note that for the GitHub check runs, the {@code summary} supports Markdown.
* <p>
* </p>
*
* @param summary
* the summary of the check run as a {@link TruncatedString}
Expand All @@ -172,7 +173,7 @@ public ChecksOutputBuilder withSummary(final TruncatedString summary) {
*
* <p>
* Note that for a GitHub check run, the {@code text} supports Markdown.
* <p>
* </p>
*
* @param text
* the details description in Markdown
Expand All @@ -188,7 +189,7 @@ public ChecksOutputBuilder withText(final String text) {
*
* <p>
* Note that for a GitHub check run, the {@code text} supports Markdown.
* <p>
* </p>
*
* @param text
* the details description in Markdown as a {@link TruncatedString}
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/io/jenkins/plugins/checks/api/TruncatedString.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
package io.jenkins.plugins.checks.api;

import edu.umd.cs.findbugs.annotations.NonNull;

import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;

import edu.umd.cs.findbugs.annotations.NonNull;

/**
* Utility wrapper that silently truncates output with a message at a certain size.
* <p>
* The GitHub Checks API has a size limit on text fields. Because it also accepts markdown, it is not trivial to
* truncate to the required length as this could lead to unterminated syntax. The use of this class allows for adding
* chunks of complete markdown until an overflow is detected, at which point a message will be added and all future
* additions will be silently discarded.
* </p>
*/
public class TruncatedString {

Expand All @@ -27,7 +33,6 @@ public class TruncatedString {
private final boolean truncateStart;
private final boolean chunkOnNewlines;


private TruncatedString(@NonNull final List<String> chunks, @NonNull final String truncationText, final boolean truncateStart, final boolean chunkOnNewlines) {
this.chunks = Collections.unmodifiableList(Objects.requireNonNull(chunks));
this.truncationText = Objects.requireNonNull(truncationText);
Expand Down Expand Up @@ -109,10 +114,10 @@ private String build(final int maxSize, final boolean chunkOnChars) {
return String.join("", truncatedParts);
}


/**
* Builder for {@link TruncatedString}.
*/
@SuppressWarnings({"ParameterHidesMemberVariable", "UnusedReturnValue"})
public static class Builder {
private String truncationText = "Output truncated.";
private boolean truncateStart = false;
Expand Down Expand Up @@ -170,11 +175,9 @@ public Builder setChunkOnNewlines() {
this.chunkOnNewlines = true;
return this;
}

}

private static class Joiner implements Collector<String, Joiner.Accumulator, List<String>> {

private final int maxLength;
private final String truncationText;
private final boolean chunkOnChars;
Expand Down Expand Up @@ -250,5 +253,4 @@ List<String> truncate() {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import hudson.model.Job;

/**
* Extension points for implementations to provide status checks properties.
*
* When no implementations is provided for a job, a {@link DefaultStatusCheckProperties} will be used.
* Extension points for implementations to provide status checks properties. When no implementations is provided for a
* job, a {@link DefaultStatusCheckProperties} will be used.
*/
public abstract class AbstractStatusChecksProperties implements ExtensionPoint {
/**
* Returns whether the implementation is applicable for the {@code job}.
*
* @param job
* A jenkins job.
*
* @return true if applicable
*/
public abstract boolean isApplicable(Job<?, ?> job);
Expand All @@ -23,6 +23,7 @@ public abstract class AbstractStatusChecksProperties implements ExtensionPoint {
*
* @param job
* A jenkins job.
*
* @return the name of the status check
*/
public abstract String getName(Job<?, ?> job);
Expand All @@ -32,17 +33,18 @@ public abstract class AbstractStatusChecksProperties implements ExtensionPoint {
*
* @param job
* A jenkins job.
*
* @return true if skip
*/
public abstract boolean isSkipped(Job<?, ?> job);

/**
* Whether to conclude an unstable build as {@link io.jenkins.plugins.checks.api.ChecksConclusion#NEUTRAL},
* else it would be concluded as {@link io.jenkins.plugins.checks.api.ChecksConclusion#FAILURE};
* the default is false.
* Whether to conclude an unstable build as {@link io.jenkins.plugins.checks.api.ChecksConclusion#NEUTRAL}, else it
* would be concluded as {@link io.jenkins.plugins.checks.api.ChecksConclusion#FAILURE}; the default is false.
*
* @param job
* A jenkins job.
*
* @return false to treat a unstable build as failure.
*/
public boolean isUnstableBuildNeutral(final Job<?, ?> job) {
Expand All @@ -54,6 +56,7 @@ public boolean isUnstableBuildNeutral(final Job<?, ?> job) {
*
* @param job
* A jenkins job.
*
* @return true if logs should be suppressed from checks output.
*/
public boolean isSuppressLogs(final Job<?, ?> job) {
Expand All @@ -66,6 +69,7 @@ public boolean isSuppressLogs(final Job<?, ?> job) {
*
* @param job
* A jenkins job.
*
* @return true if progress updates should be skipped.
*/
public boolean isSkipProgressUpdates(final Job<?, ?> job) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
package io.jenkins.plugins.checks.status;

import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import org.jenkinsci.plugins.workflow.actions.LabelAction;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.flow.GraphListener;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import hudson.Extension;
import hudson.FilePath;
import hudson.model.Computer;
Expand All @@ -15,32 +28,20 @@
import hudson.model.queue.QueueListener;
import hudson.scm.SCM;
import hudson.scm.SCMRevisionState;

import io.jenkins.plugins.checks.api.ChecksConclusion;
import io.jenkins.plugins.checks.api.ChecksDetails.ChecksDetailsBuilder;
import io.jenkins.plugins.checks.api.ChecksOutput;
import io.jenkins.plugins.checks.api.ChecksPublisher;
import io.jenkins.plugins.checks.api.ChecksPublisherFactory;
import io.jenkins.plugins.checks.api.ChecksStatus;
import io.jenkins.plugins.util.JenkinsFacade;
import org.jenkinsci.plugins.workflow.actions.LabelAction;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.flow.GraphListener;
import org.jenkinsci.plugins.workflow.graph.FlowNode;

import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;

/**
* A publisher which publishes different statuses through the checks API based on the stage of the {@link Queue.Item}
* or {@link Run}.
*/
public final class BuildStatusChecksPublisher {

private static final Logger LOGGER = Logger.getLogger(BuildStatusChecksPublisher.class.getName());

private BuildStatusChecksPublisher() {
Expand Down Expand Up @@ -118,11 +119,7 @@ static ChecksOutput getOutput(final Run<?, ?> run, final FlowExecution execution
}

/**
* {@inheritDoc}
*
* <p>
* Listens to the queue and publishes checks in "queued" state for entering items.
* </p>
*/
@Extension
public static class JobScheduledListener extends QueueListener {
Expand All @@ -147,17 +144,14 @@ public void onEnterWaiting(final Queue.WaitingItem wi) {
}

@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
private void runAsync(Runnable run) {
@SuppressWarnings("PMD.DoNotUseThreads")
private void runAsync(final Runnable run) {
Computer.threadPoolForRemoting.submit(run);
}
}

/**
* {@inheritDoc}
*
* <p>
* Listens to the SCM checkout and publishes checks.
* </p>
*/
@Extension
public static class JobCheckoutListener extends SCMListener {
Expand All @@ -178,11 +172,7 @@ public void onCheckout(final Run<?, ?> run, final SCM scm, final FilePath worksp


/**
* {@inheritDoc}
*
* <p>
* Listens to the run and publishes checks.
* </p>
*/
@Extension
public static class JobCompletedListener extends RunListener<Run<?, ?>> {
Expand All @@ -199,6 +189,7 @@ public void onCompleted(final Run run, @CheckForNull final TaskListener listener
ChecksStatus.COMPLETED, extractConclusion(run), checksName, getOutput(run)));
}

@SuppressWarnings("PMD.CyclomaticComplexity")
private ChecksConclusion extractConclusion(final Run<?, ?> run) {
Result result = run.getResult();
if (result == null) {
Expand Down Expand Up @@ -228,11 +219,7 @@ else if (result.isBetterOrEqualTo(Result.ABORTED)) {
}

/**
* {@inheritDoc}
*
* <p>
* As a job progresses, record a representation of the flow graph.
* </p>
*/
@Extension
public static class ChecksGraphListener implements GraphListener {
Expand Down
Loading

0 comments on commit d6e1b74

Please sign in to comment.