From ef0bff8eb48bcec374566fa39c9a8d61b124f43f Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Mon, 24 Aug 2020 11:38:39 +0200 Subject: [PATCH] Replace `Nullable` with `CheckForNull`. `CheckForNull` is now supported by NullAway as well: See https://github.com/uber/NullAway/pull/397 --- plugin/pom.xml | 12 +++++++++--- .../analysis/core/model/AggregationAction.java | 8 ++++---- .../plugins/analysis/core/model/AnalysisHistory.java | 4 ++-- .../plugins/analysis/core/model/AnalysisResult.java | 12 ++++++------ .../plugins/analysis/core/model/JobAction.java | 4 ++-- .../analysis/core/model/LabelProviderFactory.java | 4 ++-- .../analysis/core/model/ReportScanningTool.java | 6 +++--- .../analysis/core/model/ResetReferenceAction.java | 8 ++++---- .../plugins/analysis/core/model/ResultAction.java | 4 ++-- .../core/model/StaticAnalysisLabelProvider.java | 10 +++++----- .../analysis/core/restapi/AnalysisResultApi.java | 4 ++-- .../plugins/analysis/core/steps/AnnotatedReport.java | 10 +++++----- .../plugins/analysis/core/steps/IssuesRecorder.java | 8 ++++---- .../analysis/core/steps/PublishIssuesStep.java | 10 +++++----- .../analysis/core/steps/RecordIssuesStep.java | 10 +++++----- .../analysis/core/steps/ScanForIssuesStep.java | 6 +++--- .../plugins/analysis/core/util/ModelValidation.java | 4 ++-- .../plugins/analysis/core/util/QualityGate.java | 4 ++-- .../plugins/analysis/warnings/tasks/TaskScanner.java | 7 +++---- .../analysis/core/model/FileNameRendererTest.java | 4 ++-- .../analysis/warnings/steps/pageobj/SummaryBox.java | 6 +++--- 21 files changed, 75 insertions(+), 70 deletions(-) diff --git a/plugin/pom.xml b/plugin/pom.xml index 589472428f..4a4716b0f3 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -26,7 +26,8 @@ ${project.groupId}.warnings.ng ${jenkins.baseline}.6 - + + 1.4.0 8.2.1 ${analysis-model-api.version} 0.7.0 @@ -625,10 +626,15 @@ java.missing.* Dependencies are not being checked, so they are reported as missing + + java.annotation.removed + @edu.umd.cs.findbugs.annotations.Nullable + Annotation should be save to change. + java.annotation.added - org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted - Annotation should be save to add. + @edu.umd.cs.findbugs.annotations.CheckForNull + Annotation should be save to change. diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AggregationAction.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AggregationAction.java index 46ce7bc18d..bba3eafede 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AggregationAction.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AggregationAction.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.stream.Collectors; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.model.Action; @@ -28,19 +28,19 @@ public class AggregationAction implements RunAction2, LastBuildAction { private transient Run owner; - @Nullable + @CheckForNull @Override public String getIconFileName() { return null; // No UI representation up to now } - @Nullable + @CheckForNull @Override public String getDisplayName() { return Messages.Aggregation_Name(); } - @Nullable + @CheckForNull @Override public String getUrlName() { return "warnings-ng"; diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AnalysisHistory.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AnalysisHistory.java index 920a81dfc4..11b0d0db76 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AnalysisHistory.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AnalysisHistory.java @@ -6,8 +6,8 @@ import edu.hm.hafner.analysis.Report; import edu.hm.hafner.echarts.BuildResult; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; -import edu.umd.cs.findbugs.annotations.Nullable; import hudson.model.Result; import hudson.model.Run; @@ -151,7 +151,7 @@ private Optional getPreviousAction() { return Optional.empty(); } - private static Optional> getRunWithResult(final @Nullable Run start, + private static Optional> getRunWithResult(final @CheckForNull Run start, final ResultSelector selector, final QualityGateEvaluationMode qualityGateEvaluationMode, final JobResultEvaluationMode jobResultEvaluationMode) { diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AnalysisResult.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AnalysisResult.java index 80e85cdf93..0df0a57015 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AnalysisResult.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AnalysisResult.java @@ -23,7 +23,7 @@ import edu.hm.hafner.analysis.Severity; import edu.hm.hafner.echarts.Build; import edu.hm.hafner.util.VisibleForTesting; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted; @@ -75,27 +75,27 @@ public class AnalysisResult implements Serializable, StaticAnalysisRun { /** * All outstanding issues: i.e. all issues, that are part of the current and reference report. */ - @Nullable + @CheckForNull private transient WeakReference outstandingIssuesReference; /** * All new issues: i.e. all issues, that are part of the current report but have not been shown up in the reference * report. */ - @Nullable + @CheckForNull private transient WeakReference newIssuesReference; /** * All fixed issues: i.e. all issues, that are part of the reference report but are not present in the current * report anymore. */ - @Nullable + @CheckForNull private transient WeakReference fixedIssuesReference; /** All SCM blames. Provides a mapping of file names to SCM commit information like author, email or commit ID. */ - @Nullable + @CheckForNull private transient WeakReference blamesReference; /** Statistics for all files. Provides a mapping of file names to SCM statistics like #authors, #commits, etc. */ - @Nullable + @CheckForNull private transient WeakReference repositoryStatistics; /** Determines since which build we have zero warnings. */ diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/JobAction.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/JobAction.java index 6535281812..9123392760 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/JobAction.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/JobAction.java @@ -6,7 +6,7 @@ import edu.hm.hafner.echarts.ChartModelConfiguration; import edu.hm.hafner.echarts.JacksonFacade; import edu.hm.hafner.echarts.LinesChartModel; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; @@ -135,7 +135,7 @@ public History createBuildHistory() { * @return the icon URL for the side-panel in the job screen */ @Override - @Nullable + @CheckForNull public String getIconFileName() { return createBuildHistory().getBaselineResult() .map(result -> Jenkins.RESOURCE_PATH + labelProvider.getSmallIconUrl()) diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/LabelProviderFactory.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/LabelProviderFactory.java index 4d92245cc9..96a2436458 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/LabelProviderFactory.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/LabelProviderFactory.java @@ -5,7 +5,7 @@ import org.apache.commons.lang3.StringUtils; import edu.hm.hafner.util.VisibleForTesting; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.DescriptorExtensionList; import hudson.ExtensionPoint; @@ -57,7 +57,7 @@ public StaticAnalysisLabelProvider create(final String id) { * @return The label provider of the selected static analysis tool. If the tool is not found then a default label * provider is returned. */ - public StaticAnalysisLabelProvider create(final String id, @Nullable final String name) { + public StaticAnalysisLabelProvider create(final String id, @CheckForNull final String name) { DescriptorExtensionList extensions = jenkins.getDescriptorsFor(Tool.class); for (ToolDescriptor descriptor : extensions) { if (descriptor.getId().equals(id)) { diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ReportScanningTool.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ReportScanningTool.java index 35012642bd..b32c334651 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ReportScanningTool.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ReportScanningTool.java @@ -10,7 +10,7 @@ import edu.hm.hafner.analysis.ParsingException; import edu.hm.hafner.analysis.Report; import edu.hm.hafner.util.Ensure; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.kohsuke.stapler.AncestorInPath; import org.kohsuke.stapler.DataBoundSetter; @@ -62,7 +62,7 @@ public void setPattern(final String pattern) { this.pattern = pattern; } - @Nullable + @CheckForNull public String getPattern() { return pattern; } @@ -110,7 +110,7 @@ public void setReportEncoding(final String reportEncoding) { this.reportEncoding = reportEncoding; } - @Nullable + @CheckForNull public String getReportEncoding() { return reportEncoding; } diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ResetReferenceAction.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ResetReferenceAction.java index d5275c5f75..e853025334 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ResetReferenceAction.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ResetReferenceAction.java @@ -1,6 +1,6 @@ package io.jenkins.plugins.analysis.core.model; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.model.Action; @@ -30,19 +30,19 @@ public String getId() { return id; } - @Nullable + @CheckForNull @Override public String getIconFileName() { return null; } - @Nullable + @CheckForNull @Override public String getDisplayName() { return null; } - @Nullable + @CheckForNull @Override public String getUrlName() { return null; diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ResultAction.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ResultAction.java index cf702fdf2e..76d35285cf 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ResultAction.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ResultAction.java @@ -7,7 +7,7 @@ import org.apache.commons.lang3.StringUtils; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.kohsuke.stapler.StaplerProxy; @@ -188,7 +188,7 @@ public String getAbsoluteUrl() { } @Override - @Nullable + @CheckForNull public HealthReport getBuildHealth() { return new HealthReportBuilder().computeHealth(healthDescriptor, getLabelProvider(), getResult().getSizePerSeverity()); diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/StaticAnalysisLabelProvider.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/StaticAnalysisLabelProvider.java index a66ad1ad36..b7b0d2183d 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/StaticAnalysisLabelProvider.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/StaticAnalysisLabelProvider.java @@ -8,7 +8,7 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.Report; import edu.hm.hafner.util.VisibleForTesting; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import j2html.tags.ContainerTag; import j2html.tags.DomContent; @@ -44,7 +44,7 @@ public class StaticAnalysisLabelProvider implements DescriptionProvider { static final String INFO_ICON = "info-circle"; private final String id; - @Nullable + @CheckForNull private String name; private final JenkinsFacade jenkins; @@ -66,12 +66,12 @@ public StaticAnalysisLabelProvider(final String id) { * @param name * the name of the static analysis tool */ - public StaticAnalysisLabelProvider(final String id, @Nullable final String name) { + public StaticAnalysisLabelProvider(final String id, @CheckForNull final String name) { this(id, name, new JenkinsFacade()); } @VisibleForTesting - StaticAnalysisLabelProvider(final String id, @Nullable final String name, final JenkinsFacade jenkins) { + StaticAnalysisLabelProvider(final String id, @CheckForNull final String name, final JenkinsFacade jenkins) { this.id = id; this.name = SANITIZER.render(name); this.jenkins = jenkins; @@ -153,7 +153,7 @@ public String getName() { * * @return the name */ - public StaticAnalysisLabelProvider setName(@Nullable final String name) { + public StaticAnalysisLabelProvider setName(@CheckForNull final String name) { if (StringUtils.isNotBlank(name)) { // don't overwrite with empty this.name = name; } diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/restapi/AnalysisResultApi.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/restapi/AnalysisResultApi.java index 7aeccf0464..75768b6ace 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/restapi/AnalysisResultApi.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/restapi/AnalysisResultApi.java @@ -2,7 +2,7 @@ import java.util.List; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; @@ -62,7 +62,7 @@ public QualityGateStatus getQualityGateStatus() { } @Exported - @Nullable + @CheckForNull public Run getReferenceBuild() { return result.getReferenceBuild().orElse(null); } diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/AnnotatedReport.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/AnnotatedReport.java index 9a00c51f98..12380e0148 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/AnnotatedReport.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/AnnotatedReport.java @@ -9,7 +9,7 @@ import com.google.errorprone.annotations.FormatMethod; import edu.hm.hafner.analysis.Report; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted; @@ -51,7 +51,7 @@ public AnnotatedReport(final String id) { * @param report * report with issues */ - public AnnotatedReport(@Nullable final String id, final Report report) { + public AnnotatedReport(@CheckForNull final String id, final Report report) { this(id, report, new Blames(), new RepositoryStatistics()); } @@ -67,7 +67,7 @@ public AnnotatedReport(@Nullable final String id, final Report report) { * @param statistics * repository statistics for affected files */ - public AnnotatedReport(@Nullable final String id, final Report report, final Blames blames, + public AnnotatedReport(@CheckForNull final String id, final Report report, final Blames blames, final RepositoryStatistics statistics) { this(id); @@ -82,7 +82,7 @@ public AnnotatedReport(@Nullable final String id, final Report report, final Bla * @param reports * the reports to aggregate */ - public AnnotatedReport(@Nullable final String id, final List reports) { + public AnnotatedReport(@CheckForNull final String id, final List reports) { this(id); addAllReports(reports); @@ -96,7 +96,7 @@ public AnnotatedReport(@Nullable final String id, final List re * @param reports * the reports to aggregate */ - public AnnotatedReport(@Nullable final String id, final Iterable reports) { + public AnnotatedReport(@CheckForNull final String id, final Iterable reports) { this(id); addAllReports(reports); diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/IssuesRecorder.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/IssuesRecorder.java index b7359d8653..9754fc6972 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/IssuesRecorder.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/IssuesRecorder.java @@ -10,8 +10,8 @@ import org.apache.commons.lang3.StringUtils; import edu.hm.hafner.analysis.Severity; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; -import edu.umd.cs.findbugs.annotations.Nullable; import org.kohsuke.stapler.AncestorInPath; import org.kohsuke.stapler.DataBoundConstructor; @@ -227,7 +227,7 @@ public String getName() { * @see #getTools * @deprecated this method is only intended to be called by the UI */ - @Nullable + @CheckForNull @Deprecated public List getToolProxies() { return analysisTools.stream().map(ToolProxy::new).collect(Collectors.toList()); @@ -284,7 +284,7 @@ public List getTools() { return new ArrayList<>(analysisTools); } - @Nullable + @CheckForNull public String getSourceCodeEncoding() { return sourceCodeEncoding; } @@ -533,7 +533,7 @@ public void setUnhealthy(final int unhealthy) { this.unhealthy = unhealthy; } - @Nullable + @CheckForNull public String getMinimumSeverity() { return minimumSeverity.getName(); } diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/PublishIssuesStep.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/PublishIssuesStep.java index e8e8a775cb..17a25ac38d 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/PublishIssuesStep.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/PublishIssuesStep.java @@ -10,8 +10,8 @@ import org.eclipse.collections.impl.factory.Sets; import edu.hm.hafner.analysis.Severity; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; -import edu.umd.cs.findbugs.annotations.Nullable; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -82,7 +82,7 @@ public class PublishIssuesStep extends Step implements Serializable { * if the array of issues is {@code null} or empty */ @DataBoundConstructor - public PublishIssuesStep(@Nullable final List issues) { + public PublishIssuesStep(@CheckForNull final List issues) { super(); if (issues == null) { @@ -235,7 +235,7 @@ public String getReferenceBuildId() { return referenceBuildId; } - @Nullable + @CheckForNull public String getSourceCodeEncoding() { return sourceCodeEncoding; } @@ -281,13 +281,13 @@ public void setUnhealthy(final int unhealthy) { this.unhealthy = unhealthy; } - @Nullable + @CheckForNull @SuppressWarnings("unused") // Used by Stapler public String getMinimumSeverity() { return minimumSeverity.getName(); } - @Nullable + @CheckForNull @SuppressWarnings("WeakerAccess") // Required by Stapler public Severity getMinimumSeverityAsSeverity() { return minimumSeverity; diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/RecordIssuesStep.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/RecordIssuesStep.java index adb0bf9f50..f14eb740ae 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/RecordIssuesStep.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/RecordIssuesStep.java @@ -12,8 +12,8 @@ import org.eclipse.collections.impl.factory.Sets; import edu.hm.hafner.analysis.Severity; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; -import edu.umd.cs.findbugs.annotations.Nullable; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -585,7 +585,7 @@ public String getName() { * @see #getTools * @deprecated this method is only intended to be called by the UI */ - @Nullable + @CheckForNull @Deprecated public List getToolProxies() { return analysisTools.stream().map(ToolProxy::new).collect(Collectors.toList()); @@ -678,12 +678,12 @@ public void setTool(final Tool tool) { * * @return {@code null} */ - @Nullable + @CheckForNull public Tool getTool() { return null; } - @Nullable + @CheckForNull public String getSourceCodeEncoding() { return sourceCodeEncoding; } @@ -933,7 +933,7 @@ public void setUnhealthy(final int unhealthy) { this.unhealthy = unhealthy; } - @Nullable + @CheckForNull public String getMinimumSeverity() { return minimumSeverity.getName(); } diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java index d414ff9e6e..2211cf471a 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java @@ -8,8 +8,8 @@ import org.apache.commons.lang3.StringUtils; import org.eclipse.collections.impl.factory.Sets; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; -import edu.umd.cs.findbugs.annotations.Nullable; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; @@ -51,7 +51,7 @@ public ScanForIssuesStep() { // empty constructor required for Stapler } - @Nullable + @CheckForNull public Tool getTool() { return tool; } @@ -106,7 +106,7 @@ public void setForensicsDisabled(final boolean forensicsDisabled) { isForensicsDisabled = forensicsDisabled; } - @Nullable + @CheckForNull public String getSourceCodeEncoding() { return sourceCodeEncoding; } diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/util/ModelValidation.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/util/ModelValidation.java index 5e12cbf5e2..5200a78405 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/util/ModelValidation.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/util/ModelValidation.java @@ -12,7 +12,7 @@ import edu.hm.hafner.analysis.Severity; import edu.hm.hafner.util.PathUtil; import edu.hm.hafner.util.VisibleForTesting; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.kohsuke.stapler.AncestorInPath; import org.kohsuke.stapler.QueryParameter; @@ -70,7 +70,7 @@ public ComboBoxModel getAllCharsets() { * * @return the default charset for the specified encoding string */ - public Charset getCharset(@Nullable final String charset) { + public Charset getCharset(@CheckForNull final String charset) { try { if (StringUtils.isNotBlank(charset)) { return Charset.forName(charset); diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/util/QualityGate.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/util/QualityGate.java index ec592b30a0..b409d6f904 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/util/QualityGate.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/util/QualityGate.java @@ -7,7 +7,7 @@ import java.util.Objects; import java.util.function.Function; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; @@ -183,7 +183,7 @@ public QualityGateStatus getStatus() { * @return the list of quality gates */ @SuppressWarnings({"deprecation", "PMD.NPathComplexity", "PMD.CyclomaticComplexity"}) - public static List map(@Nullable final Thresholds thresholds) { + public static List map(@CheckForNull final Thresholds thresholds) { if (thresholds == null) { return Collections.emptyList(); } diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/tasks/TaskScanner.java b/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/tasks/TaskScanner.java index 075a06e992..b983f2ac5d 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/tasks/TaskScanner.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/tasks/TaskScanner.java @@ -22,7 +22,7 @@ import edu.hm.hafner.analysis.IssueBuilder; import edu.hm.hafner.analysis.Report; import edu.hm.hafner.analysis.Severity; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import io.jenkins.plugins.analysis.core.util.LocalizedSeverity; @@ -73,9 +73,8 @@ public enum MatcherMode { * @param matcherMode * if tag identifiers should be treated as regular expression */ - TaskScanner(final @Nullable String highTags, final @Nullable String normalTags, - final @Nullable String lowTags, - final CaseMode caseMode, final MatcherMode matcherMode) { + TaskScanner(@CheckForNull final String highTags, @CheckForNull final String normalTags, + @CheckForNull final String lowTags, final CaseMode caseMode, final MatcherMode matcherMode) { this.isUppercase = caseMode == CaseMode.IGNORE_CASE; if (StringUtils.isNotBlank(highTags)) { patterns.put(Severity.WARNING_HIGH, compile(highTags, caseMode, matcherMode)); diff --git a/plugin/src/test/java/io/jenkins/plugins/analysis/core/model/FileNameRendererTest.java b/plugin/src/test/java/io/jenkins/plugins/analysis/core/model/FileNameRendererTest.java index 360931a4c2..7dc54c56a3 100644 --- a/plugin/src/test/java/io/jenkins/plugins/analysis/core/model/FileNameRendererTest.java +++ b/plugin/src/test/java/io/jenkins/plugins/analysis/core/model/FileNameRendererTest.java @@ -4,7 +4,7 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.model.Run; @@ -78,7 +78,7 @@ private FileNameRenderer createRenderer(final boolean isAccessible) { return new FileNameRenderer(createBuildStub(), createBuildFolderStub(isAccessible)); } - @Nullable + @CheckForNull private Run createBuildStub() { return mock(Run.class); } diff --git a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/pageobj/SummaryBox.java b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/pageobj/SummaryBox.java index dec23a7277..bf97a25ca9 100644 --- a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/pageobj/SummaryBox.java +++ b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/pageobj/SummaryBox.java @@ -10,7 +10,7 @@ import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Page Object for the static analysis summary box on the build page. @@ -18,9 +18,9 @@ * @author Ullrich Hafner */ public class SummaryBox { - @Nullable + @CheckForNull private final DomElement summary; - @Nullable + @CheckForNull private final DomElement title; private final List items;