diff --git a/README.md b/README.md index 743186c64..f90c2bdd2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Static Analysis Model and Parsers Library [![Join the chat at https://gitter.im/jenkinsci/warnings-plugin](https://badges.gitter.im/jenkinsci/warnings-plugin.svg)](https://gitter.im/jenkinsci/warnings-plugin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Jenkins Plugin](https://img.shields.io/github/release/jenkinsci/analysis-model.svg?label=changelog)](https://github.com/jenkinsci/analysis-model/releases/latest) +[![ChangeLog](https://img.shields.io/github/release/jenkinsci/analysis-model.svg?label=changelog)](https://github.com/jenkinsci/analysis-model/releases/latest) [![Jenkins](https://ci.jenkins.io/job/Plugins/job/analysis-model/job/master/badge/icon?subject=Jenkins%20CI)](https://ci.jenkins.io/job/Plugins/job/analysis-model/job/master/) [![CI on all platforms](https://github.com/jenkinsci/analysis-model/workflows/GitHub%20CI/badge.svg?branch=master)](https://github.com/jenkinsci/analysis-model/actions) [![Codacy](https://api.codacy.com/project/badge/Grade/1b96405c72db49eeb0d67486f77f8f75)](https://app.codacy.com/app/uhafner/analysis-model?utm_source=github.com&utm_medium=referral&utm_content=jenkinsci/analysis-model&utm_campaign=Badge_Grade_Dashboard) diff --git a/codacy/checkstyle.xml b/codacy/checkstyle.xml index 43dca918d..65c3103e1 100644 --- a/codacy/checkstyle.xml +++ b/codacy/checkstyle.xml @@ -3,6 +3,7 @@ Checkstyle-Configuration: Ullrich Hafner Description: Ullrich Hafner's Checkstyle Rules. --> + @@ -26,25 +27,21 @@ + + + + - + + + - - - - - - - - - - @@ -122,7 +119,6 @@ - @@ -143,7 +139,7 @@ - + diff --git a/pom.xml b/pom.xml index 22f8d61f6..7eaac69f6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ edu.hm.hafner codingstyle-pom - 1.1.1 + 1.3.1 @@ -54,7 +54,7 @@ HEAD - 8.2.2 + 8.3.0 -SNAPSHOT UTF-8 ${source.encoding} @@ -65,7 +65,7 @@ https://repo.jenkins-ci.org/incrementals/ - 1.1.0 + 1.3.0 1.25 3.11 2.7 @@ -286,6 +286,16 @@ se.bjurr.violations.lib.reports.Parser Nobody should rely on these constants. + + java.annotation.removed + @edu.umd.cs.findbugs.annotations.Nullable + Annotation should be save to change. + + + java.annotation.added + @edu.umd.cs.findbugs.annotations.CheckForNull + Annotation should be save to change. + @@ -512,4 +522,4 @@ - \ No newline at end of file + diff --git a/src/main/java/edu/hm/hafner/analysis/Categories.java b/src/main/java/edu/hm/hafner/analysis/Categories.java index c344d30cb..88c742dc5 100644 --- a/src/main/java/edu/hm/hafner/analysis/Categories.java +++ b/src/main/java/edu/hm/hafner/analysis/Categories.java @@ -2,7 +2,7 @@ import org.apache.commons.lang3.StringUtils; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Provides convenience methods to detect categories. @@ -27,7 +27,7 @@ public final class Categories { * * @return warning category, empty string if unknown */ - public static String guessCategory(@Nullable final String message) { + public static String guessCategory(@CheckForNull final String message) { if (StringUtils.contains(message, "proprietary")) { return PROPRIETARY_API; } @@ -48,7 +48,7 @@ public static String guessCategory(@Nullable final String message) { * * @return the actual category */ - public static String guessCategoryIfEmpty(@Nullable final String category, @Nullable final String message) { + public static String guessCategoryIfEmpty(@CheckForNull final String category, @CheckForNull final String message) { String capitalized = StringUtils.capitalize(category); if (StringUtils.isEmpty(capitalized)) { capitalized = guessCategory(message); diff --git a/src/main/java/edu/hm/hafner/analysis/DuplicationGroup.java b/src/main/java/edu/hm/hafner/analysis/DuplicationGroup.java index 1acde1d73..35f4de589 100644 --- a/src/main/java/edu/hm/hafner/analysis/DuplicationGroup.java +++ b/src/main/java/edu/hm/hafner/analysis/DuplicationGroup.java @@ -6,7 +6,7 @@ import org.apache.commons.lang3.StringUtils; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Links all affected files of a duplicated code fragment. A code duplication could be reported by a code duplication @@ -24,7 +24,7 @@ public final class DuplicationGroup implements Serializable { * @param codeFragment * the copied code fragment */ - public DuplicationGroup(@Nullable final String codeFragment) { + public DuplicationGroup(@CheckForNull final String codeFragment) { setCodeFragment(codeFragment); } @@ -43,7 +43,7 @@ public DuplicationGroup() { * the copied code fragment */ @SuppressWarnings("InstanceVariableUsedBeforeInitialized") - public void setCodeFragment(@Nullable final String codeFragment) { + public void setCodeFragment(@CheckForNull final String codeFragment) { if (StringUtils.isBlank(this.codeFragment)) { this.codeFragment = StringUtils.defaultString(codeFragment); } diff --git a/src/main/java/edu/hm/hafner/analysis/FileReaderFactory.java b/src/main/java/edu/hm/hafner/analysis/FileReaderFactory.java index 121935664..6d953f114 100644 --- a/src/main/java/edu/hm/hafner/analysis/FileReaderFactory.java +++ b/src/main/java/edu/hm/hafner/analysis/FileReaderFactory.java @@ -17,7 +17,7 @@ import com.google.errorprone.annotations.MustBeClosed; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Provides a {@link ReaderFactory} that returns readers for a given file. @@ -27,7 +27,7 @@ public class FileReaderFactory extends ReaderFactory { private final Path file; private final String fileName; - @Nullable + @CheckForNull private Charset charset; private final boolean isCharsetUndetected; @@ -39,7 +39,7 @@ public class FileReaderFactory extends ReaderFactory { * @param charset * the charset to use when reading the file (or {@code null} if the charset should be detected) */ - public FileReaderFactory(final Path file, final @Nullable Charset charset) { + public FileReaderFactory(final Path file, final @CheckForNull Charset charset) { super(StandardCharsets.UTF_8); this.file = file; @@ -76,7 +76,7 @@ public Reader create() { } } - @Nullable + @CheckForNull private Charset detectCharset(final InputStream inputStream) throws IOException { try (Reader reader = new InputStreamReader(inputStream, StandardCharsets.US_ASCII)) { XMLStreamReader xmlStreamReader = new SecureXmlParserFactory().createXmlStreamReader(reader); diff --git a/src/main/java/edu/hm/hafner/analysis/Issue.java b/src/main/java/edu/hm/hafner/analysis/Issue.java index 2febf0a0e..c6c0a7844 100644 --- a/src/main/java/edu/hm/hafner/analysis/Issue.java +++ b/src/main/java/edu/hm/hafner/analysis/Issue.java @@ -13,7 +13,7 @@ import edu.hm.hafner.util.Ensure; import edu.hm.hafner.util.PathUtil; import edu.hm.hafner.util.TreeString; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** @@ -171,7 +171,7 @@ public static Predicate byType(final String type) { private final UUID id; // fixed - @Nullable + @CheckForNull private final Serializable additionalProperties; // fixed private String reference; // mutable, not part of equals @@ -248,13 +248,13 @@ public static Predicate byType(final String type) { @SuppressWarnings("ParameterNumber") Issue(final String pathName, final TreeString fileName, final int lineStart, final int lineEnd, final int columnStart, final int columnEnd, - @Nullable final Iterable lineRanges, - @Nullable final String category, @Nullable final String type, - final TreeString packageName, @Nullable final String moduleName, - @Nullable final Severity severity, + @CheckForNull final Iterable lineRanges, + @CheckForNull final String category, @CheckForNull final String type, + final TreeString packageName, @CheckForNull final String moduleName, + @CheckForNull final Severity severity, final TreeString message, final String description, - @Nullable final String origin, @Nullable final String reference, - @Nullable final String fingerprint, @Nullable final Serializable additionalProperties) { + @CheckForNull final String origin, @CheckForNull final String reference, + @CheckForNull final String fingerprint, @CheckForNull final Serializable additionalProperties) { this(pathName, fileName, lineStart, lineEnd, columnStart, columnEnd, lineRanges, category, type, packageName, moduleName, severity, message, description, origin, reference, fingerprint, additionalProperties, @@ -304,15 +304,15 @@ public static Predicate byType(final String type) { * the ID of this issue */ @SuppressWarnings("ParameterNumber") - Issue(@Nullable final String pathName, final TreeString fileName, final int lineStart, final int lineEnd, + Issue(@CheckForNull final String pathName, final TreeString fileName, final int lineStart, final int lineEnd, final int columnStart, - final int columnEnd, @Nullable final Iterable lineRanges, - @Nullable final String category, - @Nullable final String type, final TreeString packageName, - @Nullable final String moduleName, @Nullable final Severity severity, + final int columnEnd, @CheckForNull final Iterable lineRanges, + @CheckForNull final String category, + @CheckForNull final String type, final TreeString packageName, + @CheckForNull final String moduleName, @CheckForNull final Severity severity, final TreeString message, final String description, - @Nullable final String origin, @Nullable final String reference, - @Nullable final String fingerprint, @Nullable final Serializable additionalProperties, + @CheckForNull final String origin, @CheckForNull final String reference, + @CheckForNull final String fingerprint, @CheckForNull final Serializable additionalProperties, final UUID id) { this.pathName = normalizeFileName(pathName); @@ -390,7 +390,7 @@ protected Object readResolve() { return this; } - private String normalizeFileName(@Nullable final String platformFileName) { + private String normalizeFileName(@CheckForNull final String platformFileName) { if (platformFileName == null || UNDEFINED.equals(platformFileName) || StringUtils.isBlank(platformFileName)) { return UNDEFINED; } @@ -417,7 +417,7 @@ private int defaultInteger(final int integer) { * * @return the valid string or a default string if the specified string is not valid */ - private String defaultString(@Nullable final String string) { + private String defaultString(@CheckForNull final String string) { return StringUtils.defaultIfEmpty(string, UNDEFINED).intern(); } @@ -429,7 +429,7 @@ private String defaultString(@Nullable final String string) { * * @return the stripped string or the empty string if the specified string is {@code null} */ - private String stripToEmpty(@Nullable final String string) { + private String stripToEmpty(@CheckForNull final String string) { return StringUtils.stripToEmpty(string).intern(); } @@ -704,7 +704,7 @@ public String getModuleName() { * @param moduleName * the module name to set */ - void setModuleName(@Nullable final String moduleName) { + void setModuleName(@CheckForNull final String moduleName) { this.moduleName = stripToEmpty(moduleName); } @@ -754,7 +754,7 @@ public String getReference() { * @param reference * the reference */ - public void setReference(@Nullable final String reference) { + public void setReference(@CheckForNull final String reference) { this.reference = stripToEmpty(reference); } @@ -781,7 +781,7 @@ public String getFingerprint() { * * @see #getFingerprint() */ - void setFingerprint(@Nullable final String fingerprint) { + void setFingerprint(@CheckForNull final String fingerprint) { this.fingerprint = StringUtils.stripToEmpty(fingerprint); } @@ -800,7 +800,7 @@ public boolean hasFingerprint() { * * @return the additional properties */ - @Nullable + @CheckForNull public Serializable getAdditionalProperties() { return additionalProperties; } diff --git a/src/main/java/edu/hm/hafner/analysis/IssueBuilder.java b/src/main/java/edu/hm/hafner/analysis/IssueBuilder.java index 1d77e8ad6..554dc76f7 100644 --- a/src/main/java/edu/hm/hafner/analysis/IssueBuilder.java +++ b/src/main/java/edu/hm/hafner/analysis/IssueBuilder.java @@ -9,7 +9,7 @@ import edu.hm.hafner.util.PathUtil; import edu.hm.hafner.util.TreeString; import edu.hm.hafner.util.TreeStringBuilder; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import static edu.hm.hafner.util.IntegerParser.*; @@ -44,35 +44,35 @@ public class IssueBuilder { private int columnStart = 0; private int columnEnd = 0; - @Nullable + @CheckForNull private LineRangeList lineRanges; - @Nullable + @CheckForNull private String pathName; private TreeString fileName = UNDEFINED_TREE_STRING; private TreeString packageName = UNDEFINED_TREE_STRING; - @Nullable + @CheckForNull private String directory; - @Nullable + @CheckForNull private String category; - @Nullable + @CheckForNull private String type; - @Nullable + @CheckForNull private Severity severity; private TreeString message = EMPTY_TREE_STRING; private String description = EMPTY; - @Nullable + @CheckForNull private String moduleName; - @Nullable + @CheckForNull private String origin; - @Nullable + @CheckForNull private String reference; - @Nullable + @CheckForNull private String fingerprint; - @Nullable + @CheckForNull private Serializable additionalProperties; private UUID id = UUID.randomUUID(); @@ -99,7 +99,7 @@ public IssueBuilder setId(final UUID id) { * * @return this */ - public IssueBuilder setAdditionalProperties(@Nullable final Serializable additionalProperties) { + public IssueBuilder setAdditionalProperties(@CheckForNull final Serializable additionalProperties) { this.additionalProperties = additionalProperties; return this; } @@ -114,7 +114,7 @@ public IssueBuilder setAdditionalProperties(@Nullable final Serializable additio * * @return this */ - public IssueBuilder setFingerprint(@Nullable final String fingerprint) { + public IssueBuilder setFingerprint(@CheckForNull final String fingerprint) { this.fingerprint = fingerprint; return this; } @@ -128,13 +128,13 @@ public IssueBuilder setFingerprint(@Nullable final String fingerprint) { * * @return this */ - public IssueBuilder setFileName(@Nullable final String fileName) { + public IssueBuilder setFileName(@CheckForNull final String fileName) { this.fileName = internFileName(fileName); return this; } - TreeString internFileName(@Nullable final String unsafeFileName) { + TreeString internFileName(@CheckForNull final String unsafeFileName) { if (unsafeFileName == null || StringUtils.isEmpty(unsafeFileName)) { return UNDEFINED_TREE_STRING; } @@ -156,7 +156,7 @@ TreeString internFileName(@Nullable final String unsafeFileName) { * * @return this */ - public IssueBuilder setDirectory(@Nullable final String directory) { + public IssueBuilder setDirectory(@CheckForNull final String directory) { this.directory = directory; return this; } @@ -172,7 +172,7 @@ public IssueBuilder setDirectory(@Nullable final String directory) { * * @return this */ - public IssueBuilder setPathName(@Nullable final String pathName) { + public IssueBuilder setPathName(@CheckForNull final String pathName) { this.pathName = pathName; return this; } @@ -198,7 +198,7 @@ public IssueBuilder setLineStart(final int lineStart) { * * @return this */ - public IssueBuilder setLineStart(@Nullable final String lineStart) { + public IssueBuilder setLineStart(@CheckForNull final String lineStart) { this.lineStart = parseInt(lineStart); return this; } @@ -224,7 +224,7 @@ public IssueBuilder setLineEnd(final int lineEnd) { * * @return this */ - public IssueBuilder setLineEnd(@Nullable final String lineEnd) { + public IssueBuilder setLineEnd(@CheckForNull final String lineEnd) { this.lineEnd = parseInt(lineEnd); return this; } @@ -250,7 +250,7 @@ public IssueBuilder setColumnStart(final int columnStart) { * * @return this */ - public IssueBuilder setColumnStart(@Nullable final String columnStart) { + public IssueBuilder setColumnStart(@CheckForNull final String columnStart) { this.columnStart = parseInt(columnStart); return this; } @@ -276,7 +276,7 @@ public IssueBuilder setColumnEnd(final int columnEnd) { * * @return this */ - public IssueBuilder setColumnEnd(@Nullable final String columnEnd) { + public IssueBuilder setColumnEnd(@CheckForNull final String columnEnd) { this.columnEnd = parseInt(columnEnd); return this; } @@ -290,7 +290,7 @@ public IssueBuilder setColumnEnd(@Nullable final String columnEnd) { * * @return this */ - public IssueBuilder setCategory(@Nullable final String category) { + public IssueBuilder setCategory(@CheckForNull final String category) { this.category = category; return this; } @@ -304,7 +304,7 @@ public IssueBuilder setCategory(@Nullable final String category) { * * @return this */ - public IssueBuilder setType(@Nullable final String type) { + public IssueBuilder setType(@CheckForNull final String type) { this.type = type; return this; } @@ -317,13 +317,13 @@ public IssueBuilder setType(@Nullable final String type) { * * @return this */ - public IssueBuilder setPackageName(@Nullable final String packageName) { + public IssueBuilder setPackageName(@CheckForNull final String packageName) { this.packageName = internPackageName(packageName); return this; } - TreeString internPackageName(@Nullable final String unsafePackageName) { + TreeString internPackageName(@CheckForNull final String unsafePackageName) { if (unsafePackageName == null || StringUtils.isBlank(unsafePackageName)) { return UNDEFINED_TREE_STRING; } @@ -340,7 +340,7 @@ TreeString internPackageName(@Nullable final String unsafePackageName) { * * @return this */ - public IssueBuilder setModuleName(@Nullable final String moduleName) { + public IssueBuilder setModuleName(@CheckForNull final String moduleName) { this.moduleName = moduleName; return this; } @@ -353,7 +353,7 @@ public IssueBuilder setModuleName(@Nullable final String moduleName) { * * @return this */ - public IssueBuilder setOrigin(@Nullable final String origin) { + public IssueBuilder setOrigin(@CheckForNull final String origin) { this.origin = origin; return this; } @@ -366,7 +366,7 @@ public IssueBuilder setOrigin(@Nullable final String origin) { * * @return this */ - public IssueBuilder setReference(@Nullable final String reference) { + public IssueBuilder setReference(@CheckForNull final String reference) { this.reference = reference; return this; } @@ -379,7 +379,7 @@ public IssueBuilder setReference(@Nullable final String reference) { * * @return this */ - public IssueBuilder setSeverity(@Nullable final Severity severity) { + public IssueBuilder setSeverity(@CheckForNull final Severity severity) { this.severity = severity; return this; } @@ -393,7 +393,7 @@ public IssueBuilder setSeverity(@Nullable final Severity severity) { * * @return this */ - public IssueBuilder guessSeverity(@Nullable final String severityString) { + public IssueBuilder guessSeverity(@CheckForNull final String severityString) { severity = Severity.guessFromString(severityString); return this; } @@ -406,7 +406,7 @@ public IssueBuilder guessSeverity(@Nullable final String severityString) { * * @return this */ - public IssueBuilder setMessage(@Nullable final String message) { + public IssueBuilder setMessage(@CheckForNull final String message) { if (StringUtils.isBlank(message)) { this.message = EMPTY_TREE_STRING; } @@ -425,7 +425,7 @@ public IssueBuilder setMessage(@Nullable final String message) { * * @return this */ - public IssueBuilder setDescription(@Nullable final String description) { + public IssueBuilder setDescription(@CheckForNull final String description) { this.description = StringUtils.stripToEmpty(description); return this; } @@ -488,7 +488,7 @@ public Issue build() { return issue; } - private static String normalizeFileName(@Nullable final String platformFileName) { + private static String normalizeFileName(@CheckForNull final String platformFileName) { return defaultString(StringUtils.replace( StringUtils.strip(platformFileName), "\\", "/")); } @@ -501,7 +501,7 @@ private static String normalizeFileName(@Nullable final String platformFileName) * * @return the valid string or a default string if the specified string is not valid */ - private static String defaultString(@Nullable final String string) { + private static String defaultString(@CheckForNull final String string) { return StringUtils.defaultIfEmpty(string, UNDEFINED).intern(); } diff --git a/src/main/java/edu/hm/hafner/analysis/RegexpLineParser.java b/src/main/java/edu/hm/hafner/analysis/RegexpLineParser.java index f8d5ca903..56bc4c26e 100644 --- a/src/main/java/edu/hm/hafner/analysis/RegexpLineParser.java +++ b/src/main/java/edu/hm/hafner/analysis/RegexpLineParser.java @@ -4,7 +4,7 @@ import java.util.regex.Matcher; import edu.hm.hafner.util.LookaheadStream; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Parses a report file line by line for issues using a pre-defined regular expression. If the regular expression @@ -17,7 +17,7 @@ */ public abstract class RegexpLineParser extends LookaheadParser { private static final long serialVersionUID = 434000822024807289L; - @Nullable + @CheckForNull private LookaheadStream temporaryLookahead; private static final int MAX_LINE_LENGTH = 4000; // see JENKINS-55805 diff --git a/src/main/java/edu/hm/hafner/analysis/Severity.java b/src/main/java/edu/hm/hafner/analysis/Severity.java index 41eed2879..5c4d651d4 100644 --- a/src/main/java/edu/hm/hafner/analysis/Severity.java +++ b/src/main/java/edu/hm/hafner/analysis/Severity.java @@ -13,7 +13,7 @@ import edu.hm.hafner.util.Ensure; import edu.hm.hafner.util.StringContainsUtils; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Severity of an issue. The predefined set of severities consists of an error and 3 warnings with priorities high, @@ -74,7 +74,7 @@ public static Severity valueOf(final String name) { * * @return enumeration value */ - public static Severity valueOf(@Nullable final String severity, final Severity defaultValue) { + public static Severity valueOf(@CheckForNull final String severity, final Severity defaultValue) { if (severity == null || ALL_SEVERITIES.stream() .map(Severity::getName) .noneMatch(name -> name.equals(severity))) { @@ -92,7 +92,7 @@ public static Severity valueOf(@Nullable final String severity, final Severity d * * @return mapped level. */ - public static Severity guessFromString(@Nullable final String severity) { + public static Severity guessFromString(@CheckForNull final String severity) { if (StringContainsUtils.containsAnyIgnoreCase(severity, "error", "severe", "critical", "fatal")) { return Severity.ERROR; } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/AntJavacParser.java b/src/main/java/edu/hm/hafner/analysis/parser/AntJavacParser.java index f166ae641..9b022e23c 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/AntJavacParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/AntJavacParser.java @@ -35,9 +35,11 @@ public AntJavacParser() { @Override protected boolean isLineInteresting(final String line) { - return super.isLineInteresting(line) - && (line.contains("warning") || line.contains("error") || line.contains("\u8b66\u544a")) - && !line.contains("@"); + return super.isLineInteresting(line) && containsWarningPrefix(line) && !line.contains("@"); + } + + private boolean containsWarningPrefix(final String line) { + return line.contains("warning") || line.contains("error") || line.contains("\u8b66\u544a"); } @Override diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ClairParser.java b/src/main/java/edu/hm/hafner/analysis/parser/ClairParser.java index 8df10358d..f4fe17e33 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ClairParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ClairParser.java @@ -16,7 +16,7 @@ import edu.hm.hafner.analysis.ReaderFactory; 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; /** * A parser for clair scanner json output. @@ -52,7 +52,7 @@ public Report parse(final ReaderFactory readerFactory) throws ParsingException { return report; } - private Issue convertToIssue(final JSONObject jsonIssue, @Nullable final String image) { + private Issue convertToIssue(final JSONObject jsonIssue, @CheckForNull final String image) { final StringBuilder message = new StringBuilder(); appendIfNotEmpty(jsonIssue, message, "featurename", ""); appendIfNotEmpty(jsonIssue, message, "featureversion", ":"); @@ -78,7 +78,7 @@ private void appendIfNotEmpty(final JSONObject issue, final StringBuilder messag } } - private Severity toSeverity(@Nullable final String level) { + private Severity toSeverity(@CheckForNull final String level) { switch (String.valueOf(level).toLowerCase(Locale.ENGLISH)) { case "defcon1": return Severity.ERROR; @@ -96,13 +96,13 @@ private JSONArray optJsonArrayIgnoreCase(final JSONObject json, final String sea return result instanceof JSONArray ? (JSONArray) result : new JSONArray(); } - @Nullable + @CheckForNull private String optStringIgnoreCase(final JSONObject json, final String searchKey) { final Object result = optIgnoreCase(json, searchKey); return result instanceof String ? (String) result : null; } - @Nullable + @CheckForNull private Object optIgnoreCase(final JSONObject json, final String searchKey) { Object result = json.opt(searchKey); if (result == null) { @@ -111,7 +111,7 @@ private Object optIgnoreCase(final JSONObject json, final String searchKey) { return result; } - @Nullable + @CheckForNull private Object searchIgnoreCase(final JSONObject json, final String searchKey) { Object result = null; for (String key : json.keySet()) { diff --git a/src/main/java/edu/hm/hafner/analysis/parser/FindBugsParser.java b/src/main/java/edu/hm/hafner/analysis/parser/FindBugsParser.java index 897483186..f4f68d28a 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/FindBugsParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/FindBugsParser.java @@ -29,7 +29,7 @@ import edu.umd.cs.findbugs.Project; import edu.umd.cs.findbugs.SortedBugCollection; import edu.umd.cs.findbugs.SourceLineAnnotation; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.ba.SourceFile; import edu.umd.cs.findbugs.ba.SourceFinder; @@ -312,16 +312,16 @@ private Severity getPriorityByPriority(final BugInstance warning) { */ @SuppressWarnings("all") public static class XmlBugInstance { - @Nullable + @CheckForNull private String instanceHash; - @Nullable + @CheckForNull private String message; - @Nullable + @CheckForNull private String type; - @Nullable + @CheckForNull private String category; - @Nullable + @CheckForNull public String getInstanceHash() { return instanceHash; } @@ -330,7 +330,7 @@ public void setInstanceHash(final String instanceHash) { this.instanceHash = instanceHash; } - @Nullable + @CheckForNull public String getMessage() { return message; } @@ -339,7 +339,7 @@ public void setMessage(final String message) { this.message = message; } - @Nullable + @CheckForNull public String getType() { return type; } @@ -348,7 +348,7 @@ public void setType(final String type) { this.type = type; } - @Nullable + @CheckForNull public String getCategory() { return category; } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/SonarQubeParser.java b/src/main/java/edu/hm/hafner/analysis/parser/SonarQubeParser.java index bfd170c12..4585283bd 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/SonarQubeParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/SonarQubeParser.java @@ -14,7 +14,7 @@ import edu.hm.hafner.analysis.ReaderFactory; 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; /** * Base class for SonarQube parsers. @@ -60,7 +60,7 @@ public abstract class SonarQubeParser extends IssueParser { private static final String CATEGORY_SONAR_QUBE = "SonarQube"; /** The components array. */ - @Nullable + @CheckForNull private transient JSONArray components = new JSONArray(); @Override @@ -278,7 +278,7 @@ String parseModulePath(final JSONObject moduleKeyObject, final String componentK * * @return the desired JSONObject component, or null if it hasn't been found. */ - @Nullable + @CheckForNull private JSONObject findComponentByKey(final String key) { if (components != null && key != null) { for (Object component : components) { diff --git a/src/main/java/edu/hm/hafner/analysis/parser/TaglistParser.java b/src/main/java/edu/hm/hafner/analysis/parser/TaglistParser.java index bc31622d5..e56c0508f 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/TaglistParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/TaglistParser.java @@ -15,7 +15,7 @@ import edu.hm.hafner.analysis.ReaderFactory; import edu.hm.hafner.analysis.Report; import edu.hm.hafner.util.XmlElementUtil; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Parser for Taglist Maven Plugin output. During parse, class names are converted into assumed file system names, so @@ -72,7 +72,7 @@ private String class2file(final String clazz) { return clazz.replace('.', '/').concat(".java"); } - @Nullable + @CheckForNull private String class2package(final String clazz) { int idx = clazz.lastIndexOf('.'); return idx > 0 ? clazz.substring(0, idx) : null; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ccm/Metric.java b/src/main/java/edu/hm/hafner/analysis/parser/ccm/Metric.java index 67e84a2f4..b6e31cbf0 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ccm/Metric.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ccm/Metric.java @@ -23,7 +23,7 @@ */ package edu.hm.hafner.analysis.parser.ccm; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** *

Entity representing the Metric from CCM.exe output.

@@ -44,7 +44,7 @@ public class Metric { /** * String containing Class_Name::Method_Name */ - @Nullable + @CheckForNull private String unit; /** @@ -52,13 +52,13 @@ public class Metric { * there is no documentation on which values are used to determine a method's CC classification CCM Plugin only * outputs this value. But does not use the information as a constraint in any place. */ - @Nullable + @CheckForNull private String classification; /** * The file name (e.g.:\ascx\request\open\form.ascx.cs). */ - @Nullable + @CheckForNull private String file; /** @@ -79,7 +79,7 @@ public void setComplexity(int complexity) { this.complexity = complexity; } - @Nullable + @CheckForNull public String getUnit() { return unit; } @@ -88,7 +88,7 @@ public void setUnit(String unit) { this.unit = unit; } - @Nullable + @CheckForNull public String getClassification() { return classification; } @@ -97,7 +97,7 @@ public void setClassification(String classification) { this.classification = classification; } - @Nullable + @CheckForNull public String getFile() { return file; } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/CheckStyleParser.java b/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/CheckStyleParser.java index f70800f24..01a23500e 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/CheckStyleParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/CheckStyleParser.java @@ -13,7 +13,7 @@ import edu.hm.hafner.analysis.ReaderFactory; import edu.hm.hafner.analysis.Report; import edu.hm.hafner.analysis.SecureDigester; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * A parser for Checkstyle XML files. @@ -85,11 +85,11 @@ private Report convert(final CheckStyle collection) { return report; } - private String getCategory(@Nullable final String source) { + private String getCategory(@CheckForNull final String source) { return StringUtils.capitalize(getType(StringUtils.substringBeforeLast(source, "."))); } - private String getType(@Nullable final String source) { + private String getType(@CheckForNull final String source) { return StringUtils.substringAfterLast(source, "."); } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/Error.java b/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/Error.java index f91320e43..fcde4a745 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/Error.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/Error.java @@ -1,6 +1,6 @@ package edu.hm.hafner.analysis.parser.checkstyle; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Java Bean class for a violation of the Checkstyle format. @@ -9,11 +9,11 @@ */ @SuppressWarnings({"all", "JavaLangClash"}) public class Error { - @Nullable + @CheckForNull private String source; - @Nullable + @CheckForNull private String severity; - @Nullable + @CheckForNull private String message; private int line; private int column; @@ -26,7 +26,7 @@ public void setColumn(final int column) { this.column = column; } - @Nullable + @CheckForNull public String getSource() { return source; } @@ -35,7 +35,7 @@ public void setSource(final String source) { this.source = source; } - @Nullable + @CheckForNull public String getSeverity() { return severity; } @@ -44,7 +44,7 @@ public void setSeverity(final String severity) { this.severity = severity; } - @Nullable + @CheckForNull public String getMessage() { return message; } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/File.java b/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/File.java index 2fb3da84d..b22073cd2 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/File.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/checkstyle/File.java @@ -5,7 +5,7 @@ import java.util.Collections; import java.util.List; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Java Bean class for a file of the Checkstyle format. @@ -14,7 +14,7 @@ */ public class File { /** Name of the file. */ - @Nullable + @CheckForNull private String name; /** All errors of this file. */ private final List errors = new ArrayList<>(); @@ -44,7 +44,7 @@ public Collection getErrors() { * * @return the name of this file */ - @Nullable + @CheckForNull public String getName() { return name; } @@ -54,7 +54,7 @@ public String getName() { * * @param name the value to set */ - public void setName(final String name) { + public void setName(@CheckForNull final String name) { this.name = name; } } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/dry/cpd/Duplication.java b/src/main/java/edu/hm/hafner/analysis/parser/dry/cpd/Duplication.java index 0d2464e76..e8828268c 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/dry/cpd/Duplication.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/dry/cpd/Duplication.java @@ -5,7 +5,7 @@ import java.util.Collections; import java.util.List; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Java Bean class for a CPD duplication. @@ -19,7 +19,7 @@ public class Duplication { /** Number of duplicate tokens. */ private int tokens; /** The duplicated code fragment. */ - @Nullable + @CheckForNull private String codeFragment; /** All files of this duplication. */ @@ -86,7 +86,7 @@ public void setTokens(final int tokens) { * * @return the duplicate code fragment */ - @Nullable + @CheckForNull public String getCodeFragment() { return codeFragment; } @@ -96,7 +96,7 @@ public String getCodeFragment() { * * @param codeFragment the value to set */ - public void setCodeFragment(final String codeFragment) { + public void setCodeFragment(@CheckForNull final String codeFragment) { this.codeFragment = codeFragment; } } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/dry/cpd/SourceFile.java b/src/main/java/edu/hm/hafner/analysis/parser/dry/cpd/SourceFile.java index 2de465e5c..856a76119 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/dry/cpd/SourceFile.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/dry/cpd/SourceFile.java @@ -1,6 +1,6 @@ package edu.hm.hafner.analysis.parser.dry.cpd; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Java Bean class for a file of the PMD CPD format. @@ -12,7 +12,7 @@ public class SourceFile { /** Starting line number in file. */ private int line; /** Path of the file. */ - @Nullable + @CheckForNull private String path; /** @@ -20,7 +20,7 @@ public class SourceFile { * * @return the path of this file */ - @Nullable + @CheckForNull public String getPath() { return path; } @@ -31,7 +31,7 @@ public String getPath() { * @param path * the value to set */ - public void setPath(final String path) { + public void setPath(@CheckForNull final String path) { this.path = path; } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/dry/dupfinder/Fragment.java b/src/main/java/edu/hm/hafner/analysis/parser/dry/dupfinder/Fragment.java index c5b7149a0..0db2a7e35 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/dry/dupfinder/Fragment.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/dry/dupfinder/Fragment.java @@ -1,6 +1,6 @@ package edu.hm.hafner.analysis.parser.dry.dupfinder; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** @@ -10,13 +10,13 @@ */ @SuppressWarnings("PMD.DataClass") public class Fragment { - @Nullable + @CheckForNull private String fileName; - @Nullable + @CheckForNull private String text; - @Nullable + @CheckForNull private Range lineRange; - @Nullable + @CheckForNull private Range offsetRange; /** @@ -24,7 +24,7 @@ public class Fragment { * * @return the path of this file */ - @Nullable + @CheckForNull public String getFileName() { return fileName; } @@ -35,7 +35,7 @@ public String getFileName() { * @param fileName the value to set */ @SuppressFBWarnings("NM") - public void setFileName(final String fileName) { + public void setFileName(@CheckForNull final String fileName) { this.fileName = fileName; } @@ -44,7 +44,7 @@ public void setFileName(final String fileName) { * * @return the text */ - @Nullable + @CheckForNull public String getText() { return text; } @@ -54,7 +54,7 @@ public String getText() { * * @param text the value to set */ - public void setText(final String text) { + public void setText(@CheckForNull final String text) { this.text = text; } @@ -76,7 +76,7 @@ public Range getLineRange() { * * @param lineRange the value to set */ - public void setLineRange(final Range lineRange) { + public void setLineRange(@CheckForNull final Range lineRange) { this.lineRange = lineRange; } @@ -85,7 +85,7 @@ public void setLineRange(final Range lineRange) { * * @return the offset range */ - @Nullable + @CheckForNull public Range getOffsetRange() { return offsetRange; } @@ -96,7 +96,7 @@ public Range getOffsetRange() { * * @param offsetRange the value to set */ - public void setOffsetRange(final Range offsetRange) { + public void setOffsetRange(@CheckForNull final Range offsetRange) { this.offsetRange = offsetRange; } } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/dry/simian/Block.java b/src/main/java/edu/hm/hafner/analysis/parser/dry/simian/Block.java index 66bc8c1ce..98fff6952 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/dry/simian/Block.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/dry/simian/Block.java @@ -1,6 +1,6 @@ package edu.hm.hafner.analysis.parser.dry.simian; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Java Bean class for a duplicated block of a Simian duplication warning. @@ -9,7 +9,7 @@ */ @SuppressWarnings("PMD.DataClass") public class Block { - @Nullable + @CheckForNull private String sourceFile; private int startLineNumber; private int endLineNumber; @@ -19,7 +19,7 @@ public class Block { * * @return the file name */ - @Nullable + @CheckForNull public String getSourceFile() { return sourceFile; } @@ -30,7 +30,7 @@ public String getSourceFile() { * @param sourceFile * the value to set */ - public void setSourceFile(final String sourceFile) { + public void setSourceFile(@CheckForNull final String sourceFile) { this.sourceFile = sourceFile; } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopRule.java b/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopRule.java index 07fb8292f..02d3811ca 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopRule.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopRule.java @@ -1,6 +1,6 @@ package edu.hm.hafner.analysis.parser.fxcop; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Internal model for a FxCop rule. @@ -12,11 +12,11 @@ public class FxCopRule { private final String typeName; private final String category; private final String checkId; - @Nullable + @CheckForNull private String name; - @Nullable + @CheckForNull private String url; - @Nullable + @CheckForNull private String description; public FxCopRule(final String typeName, final String category, final String checkId) { @@ -25,7 +25,7 @@ public FxCopRule(final String typeName, final String category, final String chec this.checkId = checkId; } - @Nullable + @CheckForNull public String getName() { return name; } @@ -34,7 +34,7 @@ public void setName(final String name) { this.name = name; } - @Nullable + @CheckForNull public String getUrl() { return url; } @@ -43,7 +43,7 @@ public void setUrl(final String url) { this.url = url; } - @Nullable + @CheckForNull public String getDescription() { return description; } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopRuleSet.java b/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopRuleSet.java index a6068636c..d0e51a470 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopRuleSet.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopRuleSet.java @@ -8,7 +8,7 @@ import org.w3c.dom.Element; import edu.hm.hafner.util.XmlElementUtil; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Internal set containing rules for FxCop. @@ -77,7 +77,7 @@ public boolean contains(final String category, final String checkId) { * * @return the rule; null otherwise */ - @Nullable + @CheckForNull public FxCopRule getRule(final String category, final String checkId) { String key = getRuleKey(category, checkId); FxCopRule rule = null; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/gendarme/GendarmeRule.java b/src/main/java/edu/hm/hafner/analysis/parser/gendarme/GendarmeRule.java index 29a4bb062..3c45e17a7 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/gendarme/GendarmeRule.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/gendarme/GendarmeRule.java @@ -2,20 +2,20 @@ import java.net.URL; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; @SuppressWarnings("all") public class GendarmeRule { - @Nullable + @CheckForNull private String name; - @Nullable + @CheckForNull private String typeName; - @Nullable + @CheckForNull private GendarmeRuleType type; - @Nullable + @CheckForNull private URL url; - @Nullable + @CheckForNull public String getTypeName() { return typeName; } @@ -24,7 +24,7 @@ public void setTypeName(final String typeName) { this.typeName = typeName; } - @Nullable + @CheckForNull public String getName() { return name; } @@ -33,7 +33,7 @@ public void setName(final String name) { this.name = name; } - @Nullable + @CheckForNull public GendarmeRuleType getType() { return type; } @@ -42,12 +42,12 @@ public void setType(final GendarmeRuleType type) { this.type = type; } - @Nullable + @CheckForNull public URL getUrl() { return url; } - public void setUrl(@Nullable final URL url) { + public void setUrl(@CheckForNull final URL url) { this.url = url; } } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/jcreport/File.java b/src/main/java/edu/hm/hafner/analysis/parser/jcreport/File.java index f888f55fa..cea78ccb1 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/jcreport/File.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/jcreport/File.java @@ -4,7 +4,7 @@ import java.util.Collections; import java.util.List; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * File-Class. Stores field to create a warning. It represents the File-Tags within the report.xml. The @@ -14,11 +14,11 @@ */ @SuppressWarnings("PMD.DataClass") public class File { - @Nullable + @CheckForNull private String name; - @Nullable + @CheckForNull private String packageName; - @Nullable + @CheckForNull private String srcdir; private final List items = new ArrayList<>(); @@ -26,11 +26,11 @@ public class File { * These properties are not used to create Warnings. It was decided to keep them available when Jenkins is modified * and needs access to these fields; */ - @Nullable + @CheckForNull private String level; - @Nullable + @CheckForNull private String loc; - @Nullable + @CheckForNull private String classname; /** @@ -57,7 +57,7 @@ public void addItem(final Item item) { * * @return String className. */ - @Nullable + @CheckForNull public String getClassname() { return classname; } @@ -67,7 +67,7 @@ public String getClassname() { * * @param classname lassNamesetter */ - public void setClassname(final String classname) { + public void setClassname(@CheckForNull final String classname) { this.classname = classname; } @@ -76,7 +76,7 @@ public void setClassname(final String classname) { * * @return level */ - @Nullable + @CheckForNull public String getLevel() { return level; } @@ -87,7 +87,7 @@ public String getLevel() { * * @param level set level */ - public void setLevel(final String level) { + public void setLevel(@CheckForNull final String level) { this.level = level; } @@ -97,7 +97,7 @@ public void setLevel(final String level) { * * @return loc loc */ - @Nullable + @CheckForNull public String getLoc() { return loc; } @@ -107,7 +107,7 @@ public String getLoc() { * * @param loc locsetter */ - public void setLoc(final String loc) { + public void setLoc(@CheckForNull final String loc) { this.loc = loc; } @@ -117,7 +117,7 @@ public void setLoc(final String loc) { * * @return name name */ - @Nullable + @CheckForNull public String getName() { return name; } @@ -127,7 +127,7 @@ public String getName() { * * @param name name */ - public void setName(final String name) { + public void setName(@CheckForNull final String name) { this.name = name; } @@ -137,7 +137,7 @@ public void setName(final String name) { * * @return packageName packageName. */ - @Nullable + @CheckForNull public String getPackageName() { return packageName; } @@ -147,7 +147,7 @@ public String getPackageName() { * * @param packageName packageName Setter */ - public void setPackageName(final String packageName) { + public void setPackageName(@CheckForNull final String packageName) { this.packageName = packageName; } @@ -156,7 +156,7 @@ public void setPackageName(final String packageName) { * * @return srcdir srcdir. */ - @Nullable + @CheckForNull public String getSrcdir() { return srcdir; } @@ -166,8 +166,7 @@ public String getSrcdir() { * * @param srcdir srcdir */ - public void setSrcdir(final String srcdir) { + public void setSrcdir(@CheckForNull final String srcdir) { this.srcdir = srcdir; } - } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/jcreport/Item.java b/src/main/java/edu/hm/hafner/analysis/parser/jcreport/Item.java index d036e4a07..48253c23d 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/jcreport/Item.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/jcreport/Item.java @@ -1,6 +1,6 @@ package edu.hm.hafner.analysis.parser.jcreport; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * This the Item-Class The Java-Bean-Conformity was chosen due to the digesters style of assigning. It represents the @@ -11,26 +11,26 @@ @SuppressWarnings("PMD.DataClass") public class Item { - @Nullable + @CheckForNull private String column; - @Nullable + @CheckForNull private String findingtype; - @Nullable + @CheckForNull private String line; - @Nullable + @CheckForNull private String message; - @Nullable + @CheckForNull private String origin; - @Nullable + @CheckForNull private String severity; - @Nullable + @CheckForNull private String endcolumn; /** * Although this property is not used. It was decided to keep it available when Jenkins is modified and needs access * to this field; */ - @Nullable + @CheckForNull private String endline; /** @@ -38,7 +38,7 @@ public class Item { * * @return column string */ - @Nullable + @CheckForNull public String getColumn() { return column; } @@ -48,7 +48,7 @@ public String getColumn() { * * @param column setter */ - public void setColumn(final String column) { + public void setColumn(@CheckForNull final String column) { this.column = column; } @@ -57,7 +57,7 @@ public void setColumn(final String column) { * * @return findingtype getter */ - @Nullable + @CheckForNull public String getFindingtype() { return findingtype; } @@ -67,7 +67,7 @@ public String getFindingtype() { * * @param findingtype setter */ - public void setFindingtype(final String findingtype) { + public void setFindingtype(@CheckForNull final String findingtype) { this.findingtype = findingtype; } @@ -76,7 +76,7 @@ public void setFindingtype(final String findingtype) { * * @return line getter */ - @Nullable + @CheckForNull public String getLine() { return line; } @@ -86,7 +86,7 @@ public String getLine() { * * @param line setter */ - public void setLine(final String line) { + public void setLine(@CheckForNull final String line) { this.line = line; } @@ -95,7 +95,7 @@ public void setLine(final String line) { * * @return message getter */ - @Nullable + @CheckForNull public String getMessage() { return message; } @@ -105,7 +105,7 @@ public String getMessage() { * * @param message setter */ - public void setMessage(final String message) { + public void setMessage(@CheckForNull final String message) { this.message = message; } @@ -114,7 +114,7 @@ public void setMessage(final String message) { * * @return origin getter */ - @Nullable + @CheckForNull public String getOrigin() { return origin; } @@ -124,7 +124,7 @@ public String getOrigin() { * * @param origin setter */ - public void setOrigin(final String origin) { + public void setOrigin(@CheckForNull final String origin) { this.origin = origin; } @@ -133,7 +133,7 @@ public void setOrigin(final String origin) { * * @return severity getter */ - @Nullable + @CheckForNull public String getSeverity() { return severity; } @@ -143,7 +143,7 @@ public String getSeverity() { * * @param severity setter */ - public void setSeverity(final String severity) { + public void setSeverity(@CheckForNull final String severity) { this.severity = severity; } @@ -153,7 +153,7 @@ public void setSeverity(final String severity) { * * @return endline getter */ - @Nullable + @CheckForNull public String getEndline() { return endline; } @@ -164,7 +164,7 @@ public String getEndline() { * * @param endline setter */ - public void setEndline(final String endline) { + public void setEndline(@CheckForNull final String endline) { this.endline = endline; } @@ -173,7 +173,7 @@ public void setEndline(final String endline) { * * @return endcolumn getter */ - @Nullable + @CheckForNull public String getEndcolumn() { return endcolumn; } @@ -183,8 +183,7 @@ public String getEndcolumn() { * * @param endcolumn setter */ - public void setEndcolumn(final String endcolumn) { + public void setEndcolumn(@CheckForNull final String endcolumn) { this.endcolumn = endcolumn; } - } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/pmd/File.java b/src/main/java/edu/hm/hafner/analysis/parser/pmd/File.java index 82fa1b456..21865aee4 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/pmd/File.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/pmd/File.java @@ -5,7 +5,7 @@ import java.util.Collections; import java.util.List; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Java Bean class for a file of the PMD format. @@ -15,7 +15,7 @@ @SuppressWarnings("InstanceVariableMayNotBeInitialized") public class File { /** Name of the file. */ - @Nullable + @CheckForNull private String name; /** All violations of this file. */ private final List violations = new ArrayList<>(); @@ -45,7 +45,7 @@ public Collection getViolations() { * * @return the name of this file */ - @Nullable + @CheckForNull public String getName() { return name; } @@ -55,7 +55,7 @@ public String getName() { * * @param name the value to set */ - public void setName(final String name) { + public void setName(@CheckForNull final String name) { this.name = name; } } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/pmd/PmdError.java b/src/main/java/edu/hm/hafner/analysis/parser/pmd/PmdError.java index 346562ae3..f17f98283 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/pmd/PmdError.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/pmd/PmdError.java @@ -1,6 +1,6 @@ package edu.hm.hafner.analysis.parser.pmd; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** @@ -10,38 +10,38 @@ */ @SuppressWarnings({"InstanceVariableMayNotBeInitialized", "PMD.DataClass"}) public class PmdError { - @Nullable + @CheckForNull private String filename; - @Nullable + @CheckForNull private String msg; - @Nullable + @CheckForNull private String description; - @Nullable + @CheckForNull public String getFilename() { return filename; } @SuppressFBWarnings("NM") - public void setFilename(@Nullable final String filename) { + public void setFilename(@CheckForNull final String filename) { this.filename = filename; } - @Nullable + @CheckForNull public String getMsg() { return msg; } - public void setMsg(@Nullable final String msg) { + public void setMsg(@CheckForNull final String msg) { this.msg = msg; } - @Nullable + @CheckForNull public String getDescription() { return description; } - public void setDescription(@Nullable final String description) { + public void setDescription(@CheckForNull final String description) { this.description = description; } } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/pmd/Violation.java b/src/main/java/edu/hm/hafner/analysis/parser/pmd/Violation.java index 80bbb8c8d..214585161 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/pmd/Violation.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/pmd/Violation.java @@ -1,6 +1,6 @@ package edu.hm.hafner.analysis.parser.pmd; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Java Bean class for a violation of the PMD format. @@ -10,18 +10,18 @@ @SuppressWarnings("all") public class Violation { /** Type of warning. */ - @Nullable + @CheckForNull private String rule; /** Category of warning. */ - @Nullable + @CheckForNull private String ruleset; - @Nullable + @CheckForNull private String externalInfoUrl; - @Nullable + @CheckForNull private String javaPackage; private int priority; - @Nullable + @CheckForNull private String message; private int beginline; private int endline; @@ -29,28 +29,28 @@ public class Violation { private int endcolumn; // CHECKSTYLE:OFF - @Nullable + @CheckForNull public String getRule() { return rule; } public void setRule(final String rule) { this.rule = rule; } - @Nullable + @CheckForNull public String getRuleset() { return ruleset; } public void setRuleset(final String ruleset) { this.ruleset = ruleset; } - @Nullable + @CheckForNull public String getExternalInfoUrl() { return externalInfoUrl; } public void setExternalInfoUrl(final String externalInfoUrl) { this.externalInfoUrl = externalInfoUrl; } - @Nullable + @CheckForNull public String getPackage() { return javaPackage; } @@ -63,7 +63,7 @@ public int getPriority() { public void setPriority(final int priority) { this.priority = priority; } - @Nullable + @CheckForNull public String getMessage() { return message; } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/violations/PitAdapter.java b/src/main/java/edu/hm/hafner/analysis/parser/violations/PitAdapter.java index 2791d9358..e7c0ae095 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/violations/PitAdapter.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/violations/PitAdapter.java @@ -2,7 +2,7 @@ import edu.hm.hafner.analysis.IssueBuilder; import edu.hm.hafner.analysis.Severity; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import se.bjurr.violations.lib.model.SEVERITY; import se.bjurr.violations.lib.model.Violation; @@ -33,7 +33,7 @@ Severity convertSeverity(final SEVERITY severity, final Violation violation) { return "SURVIVED".equals(getSpecifics(violation, STATUS)) ? Severity.WARNING_HIGH : Severity.WARNING_NORMAL; } - @Nullable + @CheckForNull private String getSpecifics(final Violation violation, final String key) { return violation.getSpecifics().get(key); } diff --git a/src/main/java/edu/hm/hafner/util/IntegerParser.java b/src/main/java/edu/hm/hafner/util/IntegerParser.java index b9218ae4a..832be1d37 100644 --- a/src/main/java/edu/hm/hafner/util/IntegerParser.java +++ b/src/main/java/edu/hm/hafner/util/IntegerParser.java @@ -2,7 +2,7 @@ import org.apache.commons.lang3.StringUtils; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Parses integers from string values. @@ -20,7 +20,7 @@ public final class IntegerParser { * @return the converted number * @see Integer#parseInt(String) */ - public static int parseInt(@Nullable final String number) { + public static int parseInt(@CheckForNull final String number) { if (StringUtils.isNotBlank(number)) { try { return Integer.parseInt(number); diff --git a/src/main/java/edu/hm/hafner/util/XmlElementUtil.java b/src/main/java/edu/hm/hafner/util/XmlElementUtil.java index 04f09d8c0..f88cf9702 100644 --- a/src/main/java/edu/hm/hafner/util/XmlElementUtil.java +++ b/src/main/java/edu/hm/hafner/util/XmlElementUtil.java @@ -8,7 +8,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Provides some useful methods to process the DOM. @@ -64,7 +64,7 @@ public static Optional getFirstChildElementByName(final Element parent, * * @return list of elements. */ - public static List nodeListToList(@Nullable final NodeList nodeList) { + public static List nodeListToList(@CheckForNull final NodeList nodeList) { if (nodeList == null) { return new ArrayList<>(); } diff --git a/src/test/java/edu/hm/hafner/analysis/IssueTest.java b/src/test/java/edu/hm/hafner/analysis/IssueTest.java index da4ef3f05..c9465b4c2 100644 --- a/src/test/java/edu/hm/hafner/analysis/IssueTest.java +++ b/src/test/java/edu/hm/hafner/analysis/IssueTest.java @@ -3,14 +3,13 @@ import java.io.IOException; import java.util.UUID; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import edu.hm.hafner.analysis.assertions.SoftAssertions; import edu.hm.hafner.util.SerializableTest; import edu.hm.hafner.util.TreeString; import edu.hm.hafner.util.TreeStringBuilder; -import edu.umd.cs.findbugs.annotations.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import static edu.hm.hafner.analysis.assertions.Assertions.*; @@ -98,11 +97,11 @@ class IssueTest extends SerializableTest { @SuppressWarnings("ParameterNumber") protected Issue createIssue(final String pathName, final TreeString fileName, final int lineStart, final int lineEnd, final int columnStart, final int columnEnd, - @Nullable final String category, @Nullable final String type, - final TreeString packageName, @Nullable final String moduleName, - @Nullable final Severity priority, final TreeString message, - final String description, @Nullable final String origin, - @Nullable final String reference, @Nullable final String fingerprint, + @CheckForNull final String category, @CheckForNull final String type, + final TreeString packageName, @CheckForNull final String moduleName, + @CheckForNull final Severity priority, final TreeString message, + final String description, @CheckForNull final String origin, + @CheckForNull final String reference, @CheckForNull final String fingerprint, final String additionalProperties) { return new Issue(pathName, fileName, lineStart, lineEnd, columnStart, columnEnd, LINE_RANGES, category, type, packageName, diff --git a/src/test/java/edu/hm/hafner/analysis/ModuleDetectorTest.java b/src/test/java/edu/hm/hafner/analysis/ModuleDetectorTest.java index 0aceb2ddd..79a0fb8bb 100644 --- a/src/test/java/edu/hm/hafner/analysis/ModuleDetectorTest.java +++ b/src/test/java/edu/hm/hafner/analysis/ModuleDetectorTest.java @@ -18,7 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.any; import static org.mockito.Mockito.*; /** diff --git a/src/test/java/edu/hm/hafner/analysis/SeverityTest.java b/src/test/java/edu/hm/hafner/analysis/SeverityTest.java index f9e4dac88..9543ff47a 100644 --- a/src/test/java/edu/hm/hafner/analysis/SeverityTest.java +++ b/src/test/java/edu/hm/hafner/analysis/SeverityTest.java @@ -36,7 +36,7 @@ void shouldAssignSeverities() { assertThat(Severity.guessFromString("[NOTE]")).isEqualTo(Severity.WARNING_LOW); } - @Test @SuppressWarnings("PMD.PositionLiteralsFirstInCaseInsensitiveComparisons") + @Test @SuppressWarnings("PMD.LiteralsFirstInComparisons") void shouldCreateNewSeverityThatOverridesEqualsAndToString() { String name = "severity"; Severity severity = new Severity(name);