diff --git a/src/main/java/edu/hm/hafner/analysis/Issue.java b/src/main/java/edu/hm/hafner/analysis/Issue.java index f4cb3229a..36ae7bbf8 100644 --- a/src/main/java/edu/hm/hafner/analysis/Issue.java +++ b/src/main/java/edu/hm/hafner/analysis/Issue.java @@ -375,7 +375,7 @@ public static Predicate byType(final String type) { } /** - * Called after de-serialization to improve the memory usage. + * Called after deserialization to improve the memory usage. * * @return this */ diff --git a/src/main/java/edu/hm/hafner/analysis/IssueParser.java b/src/main/java/edu/hm/hafner/analysis/IssueParser.java index 6441cbf2f..865f30a00 100644 --- a/src/main/java/edu/hm/hafner/analysis/IssueParser.java +++ b/src/main/java/edu/hm/hafner/analysis/IssueParser.java @@ -7,7 +7,7 @@ import org.apache.commons.lang3.StringUtils; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.util.SecureXmlParserFactory; import edu.umd.cs.findbugs.annotations.CheckForNull; @@ -19,7 +19,7 @@ @SuppressWarnings("checkstyle:JavadocVariable") public abstract class IssueParser implements Serializable { @Serial - private static final long serialVersionUID = 200992696185460268L; + private static final long serialVersionUID = 5L; // release 13.0.0 protected static final String ADDITIONAL_PROPERTIES = "additionalProperties"; protected static final String CATEGORY = "category"; @@ -41,44 +41,78 @@ public abstract class IssueParser implements Serializable { protected static final String SEVERITY = "severity"; protected static final String TYPE = "type"; + private String defaultId = StringUtils.EMPTY; + private String defaultName = StringUtils.EMPTY; + /** - * Parses the specified file for issues. + * Parses a report (given by the reader factory) for issues. * * @param readerFactory - * provides a reader to the reports + * factory to read input reports with a specific locale * - * @return the issues + * @return the report containing the found issues * @throws ParsingException - * Signals that during parsing a non-recoverable error has been occurred + * signals that during parsing a non-recoverable error has been occurred * @throws ParsingCanceledException - * Signals that the user has aborted the parsing + * signals that the user has aborted the parsing */ - public abstract Report parse(ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException; - - public Type getType() { - return Type.WARNING; + public Report parse(final ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException { + return parse(readerFactory, defaultId, defaultName); } /** - * Parses the specified file for issues. Invokes the parser using {@link #parse(ReaderFactory)} and sets the file - * name of the report. + * Parses a report (given by the reader factory) for issues. * * @param readerFactory - * provides a reader to the reports + * factory to read input reports with a specific locale + * @param id + * the ID for the returned report + * @param name + * a human-readable name for the returned report * - * @return the issues + * @return the report containing the found issues * @throws ParsingException - * Signals that during parsing a non-recoverable error has been occurred + * signals that during parsing a non-recoverable error has been occurred * @throws ParsingCanceledException - * Signals that the user has aborted the parsing + * signals that the user has aborted the parsing */ - public Report parseFile(final ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException { - var report = parse(readerFactory); + public Report parse(final ReaderFactory readerFactory, final String id, final String name) throws ParsingException, ParsingCanceledException { + var report = parseReport(readerFactory); + report.setOriginReportFile(readerFactory.getFileName()); - report.setType(getType()); + report.setElementType(getType()); + report.setOrigin(id, name); + return report; } + /** + * Parses a report (given by the reader factory) for issues. + * + * @param readerFactory + * factory to read input reports with a specific locale + * + * @return the report containing the found issues + * @throws ParsingException + * signals that during parsing a non-recoverable error has been occurred + * @throws ParsingCanceledException + * signals that the user has aborted the parsing + */ + protected abstract Report parseReport(ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException; + + public final void setDefaultId(final String defaultId) { + this.defaultId = defaultId; + } + + public final void setDefaultName(final String defaultName) { + this.defaultName = defaultName; + } + + // FIXME: back to descriptor? + public IssueType getType() { + return IssueType.WARNING; + } + /** * Returns whether this parser accepts the specified file as valid input. Parsers may reject a file if it is in the * wrong format to avoid exceptions during parsing. @@ -134,7 +168,7 @@ protected boolean isXmlFile(final ReaderFactory readerFactory) { * @return {@code true} if the CharSequences are equal (case-insensitive), or both {@code null} */ public static boolean equalsIgnoreCase(@CheckForNull final String a, @CheckForNull final String b) { - return StringUtils.equals(normalize(a), normalize(b)); + return StringUtils.equalsIgnoreCase(normalize(a), normalize(b)); } private static String normalize(@CheckForNull final String input) { diff --git a/src/main/java/edu/hm/hafner/analysis/LookaheadParser.java b/src/main/java/edu/hm/hafner/analysis/LookaheadParser.java index ebef38c3d..2e8c67c6d 100644 --- a/src/main/java/edu/hm/hafner/analysis/LookaheadParser.java +++ b/src/main/java/edu/hm/hafner/analysis/LookaheadParser.java @@ -57,7 +57,7 @@ protected LookaheadParser(final String pattern) { } @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException { var report = new Report(); try (Stream lines = readerFactory.readStream()) { try (var lookahead = new LookaheadStream(lines, readerFactory.getFileName())) { diff --git a/src/main/java/edu/hm/hafner/analysis/Report.java b/src/main/java/edu/hm/hafner/analysis/Report.java index deefd3e25..112101b1e 100644 --- a/src/main/java/edu/hm/hafner/analysis/Report.java +++ b/src/main/java/edu/hm/hafner/analysis/Report.java @@ -43,6 +43,8 @@ import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import static edu.hm.hafner.analysis.Severity.*; + /** * A report contains a set of unique {@link Issue issues}: it contains no duplicate elements, i.e., it models the * mathematical set abstraction. This report provides a total ordering on its elements. I.e., the issues @@ -69,7 +71,7 @@ public class Report implements Iterable, Serializable { private String originReportFile; private String icon = StringUtils.EMPTY; // since 13.0.0 private String parserId = DEFAULT_ID; // since 13.0.0 - private Type type = Type.WARNING; // since 13.0.0 + private IssueType elementType = IssueType.WARNING; // since 13.0.0 private List subReports = new ArrayList<>(); // almost final @@ -251,16 +253,16 @@ public Set getOriginReportFiles() { } /** - * Returns the type of the report. The type might be used to customize reports in the UI. + * Returns the type of the issues in the report. The type might be used to customize reports in the UI. * - * @return the type of the parser + * @return the type of the issues in the report */ - public Type getType() { - return type; + public IssueType getElementType() { + return elementType; } - public void setType(final Type type) { - this.type = type; + public void setElementType(final IssueType elementType) { + this.elementType = elementType; } /** @@ -424,7 +426,7 @@ protected Object readResolve() { if (parserId == null) { // release 13.0.0 parserId = DEFAULT_ID; icon = DEFAULT_ID; - type = Type.WARNING; + elementType = IssueType.WARNING; } return this; } @@ -649,8 +651,47 @@ public int getSizeOf(final Severity severity) { @Override public String toString() { - return String.format(Locale.ENGLISH, "%s (%s): %s%s", getEffectiveName(), getEffectiveId(), - getItemName(size()), getDuplicates()); + var summary = String.format(Locale.ENGLISH, "%s%s%s", getNamePrefix(), getSummary(), getDuplicates()); + + var details = getPredefinedValues() + .stream() + .map(this::reportSeverity) + .flatMap(Optional::stream) + .collect(Collectors.joining(", ")); + if (StringUtils.isEmpty(details)) { + return summary; + } + return summary + " (" + details + ")"; + } + + /** + * Returns a string representation of this report that shows the number of issues and their distribution. + * + * @return a string representation of this report + */ + public String getSummary() { + return getItemName(size()); + } + + private String getNamePrefix() { + if (isEmptyOrDefault(getName()) && isEmptyOrDefault(getId())) { + return StringUtils.EMPTY; + } + else { + return String.format(Locale.ENGLISH, "%s (%s): ", getName(), getId()); + } + } + + private boolean isEmptyOrDefault(final String value) { + return StringUtils.isEmpty(value) || DEFAULT_ID.equals(value); + } + + private Optional reportSeverity(final Severity severity) { + var size = getSizeOf(severity); + if (size > 0) { + return Optional.of(String.format(Locale.ENGLISH, "%s: %d", StringUtils.lowerCase(severity.getName()), size)); + } + return Optional.empty(); } private String getItemName(final int size) { @@ -664,14 +705,15 @@ private String getItemName(final int size) { // Open as API? private String getItemCount(final int count) { if (count == 1) { - return switch (getType()) { + return switch (getElementType()) { case WARNING -> "warning"; case BUG -> "bug"; case DUPLICATION -> "duplication"; case VULNERABILITY -> "vulnerability"; }; - } else { - return switch (getType()) { + } + else { + return switch (getElementType()) { case WARNING -> "warnings"; case BUG -> "bugs"; case DUPLICATION -> "duplications"; @@ -687,13 +729,6 @@ private String getDuplicates() { return StringUtils.EMPTY; } - private static String plural(final int score) { - if (score == 1) { - return StringUtils.EMPTY; - } - return "s"; - } - /** * Prints all issues of the report. * @@ -1077,7 +1112,7 @@ public boolean equals(final Object o) { && Objects.equals(id, issues.id) && Objects.equals(name, issues.name) && Objects.equals(icon, issues.icon) - && Objects.equals(type, issues.type) + && Objects.equals(elementType, issues.elementType) && Objects.equals(parserId, issues.parserId) && Objects.equals(originReportFile, issues.originReportFile) && Objects.equals(subReports, issues.subReports) @@ -1090,7 +1125,7 @@ public boolean equals(final Object o) { @Override @Generated public int hashCode() { - return Objects.hash(id, name, icon, type, parserId, originReportFile, subReports, elements, + return Objects.hash(id, name, icon, elementType, parserId, originReportFile, subReports, elements, infoMessages, errorMessages, countersByKey, duplicatesSize); } @@ -1109,7 +1144,7 @@ private void writeObject(final ObjectOutputStream output) throws IOException { output.writeUTF(name); output.writeUTF(icon); output.writeUTF(parserId); - output.writeObject(type); + output.writeObject(elementType); output.writeUTF(originReportFile); output.writeInt(subReports.size()); @@ -1167,7 +1202,7 @@ private void readObject(final ObjectInputStream input) throws IOException, Class icon = input.readUTF(); parserId = input.readUTF(); - type = (Type) input.readObject(); + elementType = (IssueType) input.readObject(); originReportFile = input.readUTF(); subReports = new ArrayList<>(); @@ -1345,7 +1380,7 @@ public static class IssueFilterBuilder { private final Collection> includeFilters = new ArrayList<>(); private final Collection> excludeFilters = new ArrayList<>(); - /** Type of the filter: include or exclude elements. */ + /** IssueType of the filter: include or exclude elements. */ enum FilterType { INCLUDE, EXCLUDE @@ -1625,7 +1660,7 @@ public IssueFilterBuilder setExcludeCategoryFilter(final String... patterns) { // - // + // /** * Add a new filter for {@code Issue::getCategory}. @@ -1749,7 +1784,7 @@ private void addMessageFilter(final Collection patterns, final FilterTyp /** * Returns the type of the issues. The type is used to customize reports in the UI. */ - public enum Type { + public enum IssueType { /** A parser that scans the output of a build tool to find warnings. */ WARNING, /** A parser that scans the output of a build tool to find bugs. */ diff --git a/src/main/java/edu/hm/hafner/analysis/parser/AjcParser.java b/src/main/java/edu/hm/hafner/analysis/parser/AjcParser.java index 732ddf25f..4a6404397 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/AjcParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/AjcParser.java @@ -28,7 +28,7 @@ public class AjcParser extends IssueParser { static final String ADVICE = "Advice"; @Override - public Report parse(final ReaderFactory reader) throws ParsingException { + public Report parseReport(final ReaderFactory reader) throws ParsingException { try (Stream lines = reader.readStream()) { return parse(lines); } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/CargoCheckParser.java b/src/main/java/edu/hm/hafner/analysis/parser/CargoCheckParser.java index ea3c69ca7..c18f362d4 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/CargoCheckParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/CargoCheckParser.java @@ -69,7 +69,7 @@ public class CargoCheckParser extends IssueParser { private static final String MESSAGE_SPAN_COLUMN_END = "column_end"; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException { var report = new Report(); try (Stream lines = readerFactory.readStream(); var issueBuilder = new IssueBuilder()) { 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 635a1975d..81da720e3 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ClairParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ClairParser.java @@ -8,7 +8,7 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; import edu.hm.hafner.analysis.Report; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.Severity; import edu.umd.cs.findbugs.annotations.CheckForNull; @@ -23,8 +23,8 @@ public class ClairParser extends JsonIssueParser { private static final long serialVersionUID = 371390072777545322L; @Override - public Type getType() { - return Type.VULNERABILITY; + public IssueType getType() { + return IssueType.VULNERABILITY; } @Override diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ClangAnalyzerPlistParser.java b/src/main/java/edu/hm/hafner/analysis/parser/ClangAnalyzerPlistParser.java index 8dd64bbc4..78c0be321 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ClangAnalyzerPlistParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ClangAnalyzerPlistParser.java @@ -38,7 +38,7 @@ public boolean accepts(final ReaderFactory readerFactory) { } @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { try (var issueBuilder = new IssueBuilder()) { var doc = readerFactory.readDocument(); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/CodeGeneratorParser.java b/src/main/java/edu/hm/hafner/analysis/parser/CodeGeneratorParser.java index f3425ecac..a10c14ec0 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/CodeGeneratorParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/CodeGeneratorParser.java @@ -44,8 +44,8 @@ private String getCategory(final String line) { else if (line.contains("does not support multiword aliases")) { return "Multiword Aliases not Supported by Code Generation"; } - else if (line.contains("Unnecessary Data Type Conversion")) { - return "Unnecessary Data Type Conversion"; + else if (line.contains("Unnecessary Data IssueType Conversion")) { + return "Unnecessary Data IssueType Conversion"; } else if (line.contains("Cannot close the model")) { return "Model Cannot be Closed"; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/EclipseXMLParser.java b/src/main/java/edu/hm/hafner/analysis/parser/EclipseXMLParser.java index e54b6f255..61d7c8a84 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/EclipseXMLParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/EclipseXMLParser.java @@ -50,7 +50,7 @@ public boolean accepts(final ReaderFactory readerFactory) { } @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { try (var issueBuilder = new IssueBuilder()) { var doc = readerFactory.readDocument(); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/EmbeddedEngineerParser.java b/src/main/java/edu/hm/hafner/analysis/parser/EmbeddedEngineerParser.java index e8572c267..d643ddcef 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/EmbeddedEngineerParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/EmbeddedEngineerParser.java @@ -35,7 +35,7 @@ public class EmbeddedEngineerParser extends IssueParser { "^\\[([^\\]]*)\\]\\s(?Error|Warn)\\s-\\s(?[^:]*)" + "(:\\s|\\s\\()(?.+)"); @Override - public Report parse(final ReaderFactory reader) throws ParsingException { + public Report parseReport(final ReaderFactory reader) throws ParsingException { try (Stream lines = reader.readStream()) { try (var lookahead = new LookaheadStream(lines, reader.getFileName())) { return parse(lookahead); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ErrorProneParser.java b/src/main/java/edu/hm/hafner/analysis/parser/ErrorProneParser.java index a0edc84d8..76bd20e40 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ErrorProneParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ErrorProneParser.java @@ -11,7 +11,7 @@ import edu.hm.hafner.analysis.IssueBuilder; import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.ParsingException; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.util.LookaheadStream; import static j2html.TagCreator.*; @@ -44,8 +44,8 @@ public ErrorProneParser() { } @Override - public Type getType() { - return Type.BUG; + public IssueType getType() { + return IssueType.BUG; } @Override diff --git a/src/main/java/edu/hm/hafner/analysis/parser/FlawfinderParser.java b/src/main/java/edu/hm/hafner/analysis/parser/FlawfinderParser.java index 1fef12336..a62ab2357 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/FlawfinderParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/FlawfinderParser.java @@ -7,7 +7,7 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; import edu.hm.hafner.analysis.LookaheadParser; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.Severity; import edu.hm.hafner.analysis.util.IntegerParser; import edu.hm.hafner.util.LookaheadStream; @@ -35,8 +35,8 @@ public FlawfinderParser() { } @Override - public Type getType() { - return Type.VULNERABILITY; + public IssueType getType() { + return IssueType.VULNERABILITY; } @Override diff --git a/src/main/java/edu/hm/hafner/analysis/parser/GhsMultiParser.java b/src/main/java/edu/hm/hafner/analysis/parser/GhsMultiParser.java index 5728bdcff..f1796da14 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/GhsMultiParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/GhsMultiParser.java @@ -22,7 +22,7 @@ public class GhsMultiParser extends LookaheadParser { private static final long serialVersionUID = 8149238560432255036L; /** - * Regex Pattern to match start of Warning / Error. Groups are used to identify FileName, StartLine, Type, Category, + * Regex Pattern to match start of Warning / Error. Groups are used to identify FileName, StartLine, IssueType, Category, * Start of message. */ private static final String GHS_MULTI_WARNING_PATTERN = "\"(?.*)\"\\," diff --git a/src/main/java/edu/hm/hafner/analysis/parser/IdeaInspectionParser.java b/src/main/java/edu/hm/hafner/analysis/parser/IdeaInspectionParser.java index 4b8353bad..79baf5bb2 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/IdeaInspectionParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/IdeaInspectionParser.java @@ -29,7 +29,7 @@ public class IdeaInspectionParser extends IssueParser { private static final String ERROR = "ERROR"; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { var document = readerFactory.readDocument(); var rootElement = (Element) document.getElementsByTagName("problems").item(0); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/JsonIssueParser.java b/src/main/java/edu/hm/hafner/analysis/parser/JsonIssueParser.java index 9dd504230..49e63f0d9 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/JsonIssueParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/JsonIssueParser.java @@ -24,7 +24,7 @@ public abstract class JsonIssueParser extends IssueParser { private static final long serialVersionUID = -4062256623915009878L; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { var report = new Report(); try (var reader = readerFactory.create(); var issueBuilder = new IssueBuilder()) { var parsedValue = new JSONTokener(reader).nextValue(); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/JsonLogParser.java b/src/main/java/edu/hm/hafner/analysis/parser/JsonLogParser.java index dc6df85f0..c82ef12f6 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/JsonLogParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/JsonLogParser.java @@ -28,7 +28,7 @@ public boolean accepts(final ReaderFactory readerFactory) { } @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { try (Stream lines = readerFactory.readStream()) { var report = new Report(); lines.map(String::trim) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/JsonParser.java b/src/main/java/edu/hm/hafner/analysis/parser/JsonParser.java index e617f91a8..4c828996c 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/JsonParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/JsonParser.java @@ -32,7 +32,7 @@ public boolean accepts(final ReaderFactory readerFactory) { } @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { try (var reader = readerFactory.create(); var builder = new IssueBuilder()) { var jsonReport = (JSONObject) new JSONTokener(reader).nextValue(); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/LintParser.java b/src/main/java/edu/hm/hafner/analysis/parser/LintParser.java index 044440574..09868a712 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/LintParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/LintParser.java @@ -25,7 +25,7 @@ public class LintParser extends IssueParser { private static final String FILE = "file"; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { var report = new Report(); readerFactory.parse(new JSLintXmlSaxParser(report)); return report; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/OwaspDependencyCheckParser.java b/src/main/java/edu/hm/hafner/analysis/parser/OwaspDependencyCheckParser.java index 491c17fe0..3465c8925 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/OwaspDependencyCheckParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/OwaspDependencyCheckParser.java @@ -7,7 +7,7 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; import edu.hm.hafner.analysis.Report; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.Severity; import edu.umd.cs.findbugs.annotations.CheckForNull; @@ -32,8 +32,8 @@ public class OwaspDependencyCheckParser extends JsonIssueParser { private static final String DESCRIPTION = "description"; @Override - public Type getType() { - return Type.VULNERABILITY; + public IssueType getType() { + return IssueType.VULNERABILITY; } @Override diff --git a/src/main/java/edu/hm/hafner/analysis/parser/PnpmAuditParser.java b/src/main/java/edu/hm/hafner/analysis/parser/PnpmAuditParser.java index 033e948d1..6f9b68009 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/PnpmAuditParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/PnpmAuditParser.java @@ -10,7 +10,7 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; import edu.hm.hafner.analysis.Report; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.Severity; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -41,8 +41,8 @@ public class PnpmAuditParser extends JsonIssueParser { private static final long serialVersionUID = 4140706319863200922L; @Override - public Type getType() { - return Type.VULNERABILITY; + public IssueType getType() { + return IssueType.VULNERABILITY; } @Override diff --git a/src/main/java/edu/hm/hafner/analysis/parser/PolyspaceParser.java b/src/main/java/edu/hm/hafner/analysis/parser/PolyspaceParser.java index 1f356b9e7..3078d191d 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/PolyspaceParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/PolyspaceParser.java @@ -33,7 +33,7 @@ public class PolyspaceParser extends IssueParser { */ @Override - public Report parse(final ReaderFactory reader) throws ParsingException { + public Report parseReport(final ReaderFactory reader) throws ParsingException { try (Stream lines = reader.readStream()) { return parse(lines); } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/QtTranslationParser.java b/src/main/java/edu/hm/hafner/analysis/parser/QtTranslationParser.java index b3e4da8e4..1ffba75e2 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/QtTranslationParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/QtTranslationParser.java @@ -45,7 +45,7 @@ public class QtTranslationParser extends IssueParser { + "so that \"lupdate\" can find it."; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { var report = new Report(); readerFactory.parse(new QtTranslationSaxParser(report, readerFactory.getFileName())); return report; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/RfLintParser.java b/src/main/java/edu/hm/hafner/analysis/parser/RfLintParser.java index 3bcaf786f..9f1571b7c 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/RfLintParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/RfLintParser.java @@ -159,7 +159,7 @@ public static RfLintRuleName fromName(final String name) { private static final Pattern FILE_PATTERN = Pattern.compile("\\+\\s(?.*)"); @Override - public Report parse(final ReaderFactory readerFactory) { + public Report parseReport(final ReaderFactory readerFactory) { try (Stream lines = readerFactory.readStream(); var builder = new IssueBuilder()) { var warnings = new Report(); lines.forEach(line -> parseLine(builder, warnings, line)); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/SimulinkCheckParser.java b/src/main/java/edu/hm/hafner/analysis/parser/SimulinkCheckParser.java index 0877730ec..061492702 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/SimulinkCheckParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/SimulinkCheckParser.java @@ -35,7 +35,7 @@ public class SimulinkCheckParser extends IssueParser { private static final String SW_PREFIX = "SW"; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { try (var issueBuilder = new IssueBuilder(); var reader = readerFactory.create(); var targetStream = ReaderInputStream.builder().setReader(reader).setCharset(readerFactory.getCharset()).get()) { diff --git a/src/main/java/edu/hm/hafner/analysis/parser/StyleCopParser.java b/src/main/java/edu/hm/hafner/analysis/parser/StyleCopParser.java index 9e12bef1e..b6f2fa16a 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/StyleCopParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/StyleCopParser.java @@ -25,7 +25,7 @@ public class StyleCopParser extends IssueParser { private static final long serialVersionUID = 7846052338159003458L; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { var document = readerFactory.readDocument(); // Pre v4.3 uses SourceAnalysisViolations as the parent node name 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 1138879ef..1ab949963 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/TaglistParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/TaglistParser.java @@ -28,7 +28,7 @@ public class TaglistParser extends IssueParser { private static final long serialVersionUID = 1L; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { try (var issueBuilder = new IssueBuilder()) { var xPathFactory = XPathFactory.newInstance(); var xPath = xPathFactory.newXPath(); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/TrivyParser.java b/src/main/java/edu/hm/hafner/analysis/parser/TrivyParser.java index 8a4481b50..beaa8cb54 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/TrivyParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/TrivyParser.java @@ -8,7 +8,7 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; import edu.hm.hafner.analysis.Report; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.Severity; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -33,8 +33,8 @@ public class TrivyParser extends JsonIssueParser { private static final String TRIVY_VULNERABILITY_LEVEL_TAG_LOW = "low"; @Override - public Type getType() { - return Type.VULNERABILITY; + public IssueType getType() { + return IssueType.VULNERABILITY; } /** diff --git a/src/main/java/edu/hm/hafner/analysis/parser/XmlParser.java b/src/main/java/edu/hm/hafner/analysis/parser/XmlParser.java index 43294d2b5..4337e5e35 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/XmlParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/XmlParser.java @@ -71,7 +71,7 @@ public boolean accepts(final ReaderFactory readerFactory) { } @Override @SuppressFBWarnings("XPATH_INJECTION") - public Report parse(final ReaderFactory readerFactory) { + public Report parseReport(final ReaderFactory readerFactory) { try (var issueBuilder = new IssueBuilder()) { var doc = readerFactory.readDocument(); var xPathFactory = XPathFactory.newInstance(); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java b/src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java index 4ec44aece..d2734480f 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/YoctoScannerParser.java @@ -8,7 +8,7 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; import edu.hm.hafner.analysis.Report; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.Severity; import static j2html.TagCreator.*; @@ -25,8 +25,8 @@ public class YoctoScannerParser extends JsonIssueParser { private static final Double INVALID_SCORE = -1.0; @Override - public Type getType() { - return Type.VULNERABILITY; + public IssueType getType() { + return IssueType.VULNERABILITY; } @Override diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ccm/CcmParser.java b/src/main/java/edu/hm/hafner/analysis/parser/ccm/CcmParser.java index 6d7112d9a..7648a7d50 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ccm/CcmParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ccm/CcmParser.java @@ -25,7 +25,7 @@ public class CcmParser extends IssueParser { private static final long serialVersionUID = -5172155190810975806L; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { var report = parseCcmXmlFile(readerFactory); return convert(report); 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 1685c2f6f..9f7a3b4c9 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 @@ -24,7 +24,7 @@ public class CheckStyleParser extends IssueParser { private static final long serialVersionUID = -3187275729854832128L; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { var digester = new SecureDigester(CheckStyleParser.class); var rootXPath = "checkstyle"; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/dry/AbstractDryParser.java b/src/main/java/edu/hm/hafner/analysis/parser/dry/AbstractDryParser.java index 6d7d6dacd..e998078bb 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/dry/AbstractDryParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/dry/AbstractDryParser.java @@ -14,7 +14,7 @@ import edu.hm.hafner.analysis.ParsingException; import edu.hm.hafner.analysis.ReaderFactory; import edu.hm.hafner.analysis.Report; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.SecureDigester; import edu.hm.hafner.analysis.Severity; @@ -50,8 +50,8 @@ protected AbstractDryParser(final int highThreshold, final int normalThreshold) } @Override - public Type getType() { - return Type.DUPLICATION; + public IssueType getType() { + return IssueType.DUPLICATION; } /** @@ -73,7 +73,7 @@ protected Severity getPriority(final int lines) { } @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingCanceledException, ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingCanceledException, ParsingException { var digester = new SecureDigester(AbstractDryParser.class); configureParser(digester); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsParser.java b/src/main/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsParser.java index e724baee7..3ffab0c60 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsParser.java @@ -18,7 +18,7 @@ import edu.hm.hafner.analysis.ParsingException; import edu.hm.hafner.analysis.ReaderFactory; import edu.hm.hafner.analysis.Report; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.SecureDigester; import edu.hm.hafner.analysis.Severity; import edu.hm.hafner.util.LineRange; @@ -79,12 +79,12 @@ public FindBugsParser(final PriorityProperty priorityProperty) { } @Override - public Type getType() { - return Type.BUG; + public IssueType getType() { + return IssueType.BUG; } @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { try (var builder = new IssueBuilder()) { List sources = new ArrayList<>(); var moduleRoot = StringUtils.substringBefore(readerFactory.getFileName(), "/target/"); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopParser.java b/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopParser.java index 49055f4ee..a90615050 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/fxcop/FxCopParser.java @@ -22,7 +22,7 @@ public class FxCopParser extends IssueParser { private static final int CAPACITY = 1024; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException { return new XmlParser().parse(readerFactory); } diff --git a/src/main/java/edu/hm/hafner/analysis/parser/gendarme/GendarmeParser.java b/src/main/java/edu/hm/hafner/analysis/parser/gendarme/GendarmeParser.java index 50761662a..b2522814d 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/gendarme/GendarmeParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/gendarme/GendarmeParser.java @@ -36,7 +36,7 @@ public class GendarmeParser extends IssueParser { private static final String ASSEMBLY = "Assembly"; @Override - public Report parse(final ReaderFactory factory) throws ParsingException { + public Report parseReport(final ReaderFactory factory) throws ParsingException { var document = factory.readDocument(); var mainNode = document.getElementsByTagName("gendarme-output"); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/jcreport/JcReportParser.java b/src/main/java/edu/hm/hafner/analysis/parser/jcreport/JcReportParser.java index 9976ece9c..d45a9e461 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/jcreport/JcReportParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/jcreport/JcReportParser.java @@ -22,7 +22,7 @@ public class JcReportParser extends IssueParser { private static final long serialVersionUID = -1302787609831475403L; @Override - public Report parse(final ReaderFactory reader) { + public Report parseReport(final ReaderFactory reader) { try (var issueBuilder = new IssueBuilder()) { var report = createReport(reader); var warnings = new Report(); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/pmd/PmdParser.java b/src/main/java/edu/hm/hafner/analysis/parser/pmd/PmdParser.java index 5743f8fee..bdcee9a43 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/pmd/PmdParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/pmd/PmdParser.java @@ -29,7 +29,7 @@ public class PmdParser extends IssueParser { private static final int PMD_PRIORITY_MAPPED_TO_LOW_PRIORITY = 4; @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException { var issues = parseIssues(readerFactory); parseErrors(readerFactory).stream().forEach(issues::add); return issues; 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 ddecd23fc..d016713eb 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 @@ -9,7 +9,7 @@ */ @SuppressWarnings("all") public class Violation { - /** Type of warning. */ + /** IssueType of warning. */ @CheckForNull private String rule; /** Category of warning. */ diff --git a/src/main/java/edu/hm/hafner/analysis/parser/pvsstudio/PvsStudioParser.java b/src/main/java/edu/hm/hafner/analysis/parser/pvsstudio/PvsStudioParser.java index c048e8885..00a5a3a1c 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/pvsstudio/PvsStudioParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/pvsstudio/PvsStudioParser.java @@ -39,7 +39,7 @@ else if (SEVERITY_LOW.equals(level)) { } @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException { + public Report parseReport(final ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException { try (var issueBuilder = new IssueBuilder()) { var report = new Report(); var parser = new PlogMessagesReader(); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/violations/AbstractViolationAdapter.java b/src/main/java/edu/hm/hafner/analysis/parser/violations/AbstractViolationAdapter.java index 1e57b2984..4b362f9c1 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/violations/AbstractViolationAdapter.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/violations/AbstractViolationAdapter.java @@ -33,7 +33,7 @@ public abstract class AbstractViolationAdapter extends IssueParser { @SuppressWarnings({"illegalcatch", "OverlyBroadCatchBlock"}) @Override - public Report parse(final ReaderFactory readerFactory) + public Report parseReport(final ReaderFactory readerFactory) throws ParsingCanceledException, ParsingException { try { var parser = createParser(); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/violations/JUnitAdapter.java b/src/main/java/edu/hm/hafner/analysis/parser/violations/JUnitAdapter.java index 350dc209e..2c48cc809 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/violations/JUnitAdapter.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/violations/JUnitAdapter.java @@ -34,8 +34,8 @@ JUnitParser createParser() { } @Override - public Report parse(final ReaderFactory readerFactory) throws ParsingCanceledException, ParsingException { - var report = super.parse(readerFactory); + public Report parseReport(final ReaderFactory readerFactory) throws ParsingCanceledException, ParsingException { + var report = super.parseReport(readerFactory); int total = count(readerFactory, " should be parameterized") + "IssueType safety: The method toArray(Object[]) belongs to the raw type ArrayList. References to generic type ArrayList should be parameterized") .hasFileName( "/var/lib/hudson/jobs/MailApp/workspace/plugins/org.eclipse.buckminster.tutorial.mailapp/src/org/eclipse/buckminster/tutorial/mailapp/NavigationView.java"); softly.assertThat(report.get(2)).hasSeverity(Severity.WARNING_NORMAL) diff --git a/src/test/java/edu/hm/hafner/analysis/parser/CheckStyleParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/CheckStyleParserTest.java index 24f842d58..d74a16aef 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/CheckStyleParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/CheckStyleParserTest.java @@ -54,7 +54,7 @@ void issue25511() { assertThat(report).hasSize(2); assertThat(report.get(0)).hasMessage("',' is not followed by whitespace."); - assertThat(report.get(1)).hasMessage("Type hint \"kEvent\" missing for $event at position 1"); + assertThat(report.get(1)).hasMessage("IssueType hint \"kEvent\" missing for $event at position 1"); } /** diff --git a/src/test/java/edu/hm/hafner/analysis/parser/CodeGeneratorParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/CodeGeneratorParserTest.java index b9da7861f..b344287a4 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/CodeGeneratorParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/CodeGeneratorParserTest.java @@ -28,9 +28,9 @@ protected void assertThatIssuesArePresent(final Report report, final SoftAsserti softly.assertThat(report.get(1)) .hasCategory("Multiword Aliases not Supported by Code Generation"); softly.assertThat(report.get(2)) - .hasCategory("Unnecessary Data Type Conversion"); + .hasCategory("Unnecessary Data IssueType Conversion"); softly.assertThat(report.get(3)) - .hasCategory("Unnecessary Data Type Conversion"); + .hasCategory("Unnecessary Data IssueType Conversion"); softly.assertThat(report.get(4)) .hasCategory("Model Cannot be Closed"); softly.assertThat(report.get(5)) diff --git a/src/test/java/edu/hm/hafner/analysis/parser/DScannerParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/DScannerParserTest.java index 2ad347ffa..ac19fd098 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/DScannerParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/DScannerParserTest.java @@ -58,7 +58,7 @@ protected void assertThatIssuesArePresent(final Report report, final SoftAsserti @Test void shouldHandleIncompleteReports() { - var report = createParser().parse(createReaderFactory("dscanner-incomplete-report.json")); + var report = createParser().parseReport(createReaderFactory("dscanner-incomplete-report.json")); assertThat(report).hasSize(2); assertThat(report.getErrorMessages()).isEmpty(); } diff --git a/src/test/java/edu/hm/hafner/analysis/parser/EclipseParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/EclipseParserTest.java index 8b82bc9bf..fd3d95cef 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/EclipseParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/EclipseParserTest.java @@ -112,7 +112,7 @@ void issue7077() { .hasLineStart(90) .hasLineEnd(90) .hasMessage( - "Type safety: The method setBoHandler(BoHandler) belongs to the raw type BoQuickSearchControl.Builder. References to generic type BoQuickSearchControl.Builder should be parameterized") + "IssueType safety: The method setBoHandler(BoHandler) belongs to the raw type BoQuickSearchControl.Builder. References to generic type BoQuickSearchControl.Builder should be parameterized") .hasFileName( "/ige/hudson/work/jobs/esvclient__development/workspace/target/rcp-build/plugins/ch.ipi.esv.client.customer/src/main/java/ch/ipi/esv/client/customer/search/CustomerQuickSearch.java") .hasCategory(Categories.OTHER); @@ -120,7 +120,7 @@ void issue7077() { .hasLineStart(90) .hasLineEnd(90) .hasMessage( - "Type safety: The expression of type BoQuickSearchControl needs unchecked conversion to conform to BoQuickSearchControl") + "IssueType safety: The expression of type BoQuickSearchControl needs unchecked conversion to conform to BoQuickSearchControl") .hasFileName( "/ige/hudson/work/jobs/esvclient__development/workspace/target/rcp-build/plugins/ch.ipi.esv.client.customer/src/main/java/ch/ipi/esv/client/customer/search/CustomerQuickSearch.java") .hasCategory(Categories.OTHER); @@ -178,7 +178,7 @@ void infoLogLevel() { .hasLineStart(8) .hasLineEnd(8) .hasFileName("C:/devenv/workspace/x/y/src/main/java/y/ECE.java") - .hasMessage("Type mismatch: cannot convert from float to Integer") + .hasMessage("IssueType mismatch: cannot convert from float to Integer") .hasCategory(Categories.OTHER); softly.assertThat(report.get(1)) diff --git a/src/test/java/edu/hm/hafner/analysis/parser/EclipseXMLParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/EclipseXMLParserTest.java index be50b0219..4b309a987 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/EclipseXMLParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/EclipseXMLParserTest.java @@ -35,7 +35,7 @@ protected void assertThatIssuesArePresent(final Report report, final SoftAsserti .hasColumnStart(0) .hasColumnEnd(0) .hasFileName("C:/devenv/workspace/x/y/src/main/java/y/ECE.java") - .hasMessage("Type mismatch: cannot convert from float to Integer") + .hasMessage("IssueType mismatch: cannot convert from float to Integer") .hasCategory(EclipseXMLParser.TYPE); softly.assertThat(report.get(1)) diff --git a/src/test/java/edu/hm/hafner/analysis/parser/Gcc4CompilerParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/Gcc4CompilerParserTest.java index c2e69db8b..6b08c7c2b 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/Gcc4CompilerParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/Gcc4CompilerParserTest.java @@ -253,7 +253,7 @@ void shouldNotReportGccWarnings() { @Test void shouldResolveAbsolutePaths() { - var warnings = createParser().parse(createReaderFactory("absolute-paths.txt")); + var warnings = createParser().parseReport(createReaderFactory("absolute-paths.txt")); assertThat(warnings).hasSize(188); @@ -269,7 +269,7 @@ void shouldResolveAbsolutePaths() { */ @Test void issue66835() { - var warnings = createParser().parse(createReaderFactory("issue66835.makefile.log")); + var warnings = createParser().parseReport(createReaderFactory("issue66835.makefile.log")); assertThat(warnings).hasSize(3); @@ -293,7 +293,7 @@ void issue66835() { */ @Test void issue66923() { - var warnings = createParser().parse(createReaderFactory("issue66923.txt")); + var warnings = createParser().parseReport(createReaderFactory("issue66923.txt")); assertThat(warnings).hasSize(0); assertThat(warnings).doesNotHaveErrors(); @@ -306,7 +306,7 @@ void issue66923() { */ @Test void issue69242() { - var warnings = createParser().parse(createReaderFactory("issue69242.txt")); + var warnings = createParser().parseReport(createReaderFactory("issue69242.txt")); assertThat(warnings).hasSize(2); assertThat(warnings).doesNotHaveErrors(); diff --git a/src/test/java/edu/hm/hafner/analysis/parser/IarCstatParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/IarCstatParserTest.java index 38509189a..8f76edf08 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/IarCstatParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/IarCstatParserTest.java @@ -35,7 +35,7 @@ protected void assertThatIssuesArePresent(final Report report, final SoftAsserti .hasCategory("MISRAC2012-Rule-14.4_c") .hasLineStart(129) .hasLineEnd(129) - .hasMessage("Type of if condition is not boolean. MISRAC2012-Rule-14.4") + .hasMessage("IssueType of if condition is not boolean. MISRAC2012-Rule-14.4") .hasFileName("src/main/hal/HalAdc.c"); softly.assertThat(iterator.next()) .hasSeverity(Severity.WARNING_LOW) diff --git a/src/test/java/edu/hm/hafner/analysis/parser/IarParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/IarParserTest.java index 3b3e8f64f..71f22eed1 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/IarParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/IarParserTest.java @@ -87,7 +87,7 @@ protected void assertThatIssuesArePresent(final Report report, final SoftAsserti */ @Test void issue58159Utf8() { - var warnings = createParser().parse( + var warnings = createParser().parseReport( new FileReaderFactory(getResourceAsFile("issue58159-2.txt"))); var collect = warnings.stream().map(Objects::toString).collect(Collectors.joining("\n")); diff --git a/src/test/java/edu/hm/hafner/analysis/parser/JsonLogParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/JsonLogParserTest.java index 62192af86..4a69439fe 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/JsonLogParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/JsonLogParserTest.java @@ -99,7 +99,7 @@ void shouldReportLineBreak() { @Test void emptyReport() { var parser = createParser(); - var report = parser.parse(createReaderFactory("json-issues-empty.txt")); + var report = parser.parseReport(createReaderFactory("json-issues-empty.txt")); assertThat(report).hasSize(0); } diff --git a/src/test/java/edu/hm/hafner/analysis/parser/ParserBenchmark.java b/src/test/java/edu/hm/hafner/analysis/parser/ParserBenchmark.java index b0448d6ad..af6b80b51 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/ParserBenchmark.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/ParserBenchmark.java @@ -39,7 +39,7 @@ public class ParserBenchmark extends AbstractBenchmark { */ @Benchmark public void benchmarkCheckStyleParser(final BenchmarkState state, final Blackhole blackhole) { - var report = new CheckStyleParser().parse(state.getCheckstyleFileReaderFactory()); + var report = new CheckStyleParser().parseReport(state.getCheckstyleFileReaderFactory()); blackhole.consume(report); } @@ -54,7 +54,7 @@ public void benchmarkCheckStyleParser(final BenchmarkState state, final Blackhol */ @Benchmark public void benchmarkPmdParser(final BenchmarkState state, final Blackhole blackhole) { - var report = new PmdParser().parse(state.getPmdFileReaderFactory()); + var report = new PmdParser().parseReport(state.getPmdFileReaderFactory()); blackhole.consume(report); } diff --git a/src/test/java/edu/hm/hafner/analysis/parser/XmlParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/XmlParserTest.java index 370061eb8..7ecf6f739 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/XmlParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/XmlParserTest.java @@ -63,7 +63,7 @@ protected XmlParser createParser() { @Test void shouldParseWithCustomPath() { var parser = new XmlParser(CUSTOM_PATH); - var report = parser.parse(createReaderFactory(ISSUES_CUSTOM_PATH_FILE)); + var report = parser.parseReport(createReaderFactory(ISSUES_CUSTOM_PATH_FILE)); var iterator = report.iterator(); try (var softly = new SoftAssertions()) { softly.assertThat(report) @@ -113,7 +113,7 @@ void shouldAcceptSampleFile() { @Test void shouldProduceIssuesEvenIfThereAreIncompatibleValues() { - var report = createParser().parse(createReaderFactory(ISSUES_INCOMPATIBLE_VALUE)); + var report = createParser().parseReport(createReaderFactory(ISSUES_INCOMPATIBLE_VALUE)); Iterator iterator = report.iterator(); try (var softly = new SoftAssertions()) { softly.assertThat(report) diff --git a/src/test/java/edu/hm/hafner/analysis/parser/dry/cpd/CpdParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/dry/cpd/CpdParserTest.java index 895f40f02..fefb65080 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/dry/cpd/CpdParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/dry/cpd/CpdParserTest.java @@ -5,7 +5,7 @@ import edu.hm.hafner.analysis.DuplicationGroup; import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.Report; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.Severity; import edu.hm.hafner.analysis.assertions.SoftAssertions; import edu.hm.hafner.analysis.registry.AbstractParserTest; @@ -124,8 +124,8 @@ void shouldAssignPriority() { private Report parse(final int highThreshold, final int normalThreshold) { var parser = new CpdParser(highThreshold, normalThreshold); - assertThat(parser).hasType(Type.DUPLICATION); - return parser.parse(createReaderFactory("issue12516.xml")); + assertThat(parser).hasType(IssueType.DUPLICATION); + return parser.parseReport(createReaderFactory("issue12516.xml")); } /** diff --git a/src/test/java/edu/hm/hafner/analysis/parser/dry/dupfinder/DupFinderParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/dry/dupfinder/DupFinderParserTest.java index 636b053be..bb0d33ba4 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/dry/dupfinder/DupFinderParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/dry/dupfinder/DupFinderParserTest.java @@ -126,6 +126,6 @@ void shouldAssignPriority() { private Report parse(final int highThreshold, final int normalThreshold) { var parser = new DupFinderParser(highThreshold, normalThreshold); - return parser.parse(createReaderFactory("without-sourcecode.xml")); + return parser.parseReport(createReaderFactory("without-sourcecode.xml")); } } diff --git a/src/test/java/edu/hm/hafner/analysis/parser/dry/simian/SimianParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/dry/simian/SimianParserTest.java index 0b5a2af09..94a0ef9ed 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/dry/simian/SimianParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/dry/simian/SimianParserTest.java @@ -149,6 +149,6 @@ void shouldAssignPriority() { private Report parse(final int highThreshold, final int normalThreshold) { var parser = new SimianParser(highThreshold, normalThreshold); - return parser.parse(createReaderFactory("twofile.xml")); + return parser.parseReport(createReaderFactory("twofile.xml")); } } diff --git a/src/test/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsParserTest.java index cf614487e..14494c0de 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsParserTest.java @@ -3,17 +3,15 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; -import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.Test; import edu.hm.hafner.analysis.Issue; -import edu.hm.hafner.analysis.IssueBuilder; import edu.hm.hafner.analysis.ReaderFactory; import edu.hm.hafner.analysis.Report; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.Severity; import edu.hm.hafner.analysis.assertions.SoftAssertions; import edu.hm.hafner.analysis.parser.findbugs.FindBugsParser.PriorityProperty; @@ -36,10 +34,10 @@ private Report parseFile(final String fileName, final PriorityProperty priorityP var readerFactory = mock(ReaderFactory.class); when(readerFactory.create()).thenAnswer( mock -> new InputStreamReader(read(fileName), StandardCharsets.UTF_8)); + when(readerFactory.getFileName()).thenReturn(fileName); var parser = new FindBugsParser(priorityProperty); - assertThat(parser).hasType(Type.BUG); - return parser.parse(readerFactory, - Collections.emptyList(), new IssueBuilder()); + assertThat(parser).hasType(IssueType.BUG); + return parser.parse(readerFactory, "spotbugs", "FindBugs"); } private InputStream read(final String fileName) { @@ -57,13 +55,15 @@ void shouldAssignCorrectSeverity() { assertThat(confidenceReport).hasSize(12); assertThatReportHasSeverities(confidenceReport, 0, 1, 11, 0); + assertThat(confidenceReport).hasToString( + "FindBugs (spotbugs): 12 bugs (high: 1, normal: 11)"); var rankReport = parseFile("findbugs-severities.xml", RANK); assertThat(rankReport).hasSize(12); assertThatReportHasSeverities(rankReport, 0, 0, 0, 12); assertThat(rankReport).hasToString( - "FindBugs: 12 warnings (12 low)"); + "FindBugs (spotbugs): 12 bugs (low: 12)"); } private void assertThatReportHasSeverities(final Report report, final int expectedSizeError, diff --git a/src/test/java/edu/hm/hafner/analysis/registry/AbstractParserTest.java b/src/test/java/edu/hm/hafner/analysis/registry/AbstractParserTest.java index 600733bfa..3a9a7d8f5 100644 --- a/src/test/java/edu/hm/hafner/analysis/registry/AbstractParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/registry/AbstractParserTest.java @@ -85,7 +85,7 @@ void shouldRegisterParser() { Set> parsers = parserRegistry.getAllDescriptors() .stream() - .map(ParserDescriptor::createParser) + .map(ParserDescriptor::create) .map(IssueParser::getClass) .collect(Collectors.toSet()); @@ -171,7 +171,7 @@ void shouldHandleEmptyFile() { * @return the found issues */ protected Report parse(final String fileName) { - return createParser().parseFile(createReaderFactory(fileName)); + return createParser().parse(createReaderFactory(fileName)); } /** diff --git a/src/test/java/edu/hm/hafner/analysis/registry/ParserRegistryTest.java b/src/test/java/edu/hm/hafner/analysis/registry/ParserRegistryTest.java index d1fd29c8f..e6edda328 100644 --- a/src/test/java/edu/hm/hafner/analysis/registry/ParserRegistryTest.java +++ b/src/test/java/edu/hm/hafner/analysis/registry/ParserRegistryTest.java @@ -8,7 +8,7 @@ import edu.hm.hafner.analysis.FileReaderFactory; import edu.hm.hafner.analysis.IssueParser; -import edu.hm.hafner.analysis.Report.Type; +import edu.hm.hafner.analysis.Report.IssueType; import edu.hm.hafner.analysis.Severity; import edu.hm.hafner.analysis.registry.ParserDescriptor.Option; import edu.hm.hafner.util.ResourceTest; @@ -47,13 +47,13 @@ void shouldThrowExceptionIfParserNotFound() { void shouldAssignCorrectParserType() { var parserRegistry = new ParserRegistry(); var typeCountMap = parserRegistry.getAllDescriptors().stream() - .map(ParserDescriptor::createParser) + .map(ParserDescriptor::create) .collect(Collectors.groupingBy(IssueParser::getType, Collectors.counting())); assertThat(typeCountMap) - .containsEntry(Type.WARNING, WARNING_PARSERS_COUNT) - .containsEntry(Type.BUG, BUG_PARSERS_COUNT) - .containsEntry(Type.VULNERABILITY, VULNERABILITY_PARSERS_COUNT) - .containsEntry(Type.DUPLICATION, DUPLICATION_PARSERS_COUNT); + .containsEntry(IssueType.WARNING, WARNING_PARSERS_COUNT) + .containsEntry(IssueType.BUG, BUG_PARSERS_COUNT) + .containsEntry(IssueType.VULNERABILITY, VULNERABILITY_PARSERS_COUNT) + .containsEntry(IssueType.DUPLICATION, DUPLICATION_PARSERS_COUNT); } @Test @@ -67,7 +67,7 @@ void shouldFindSomeParsers() { assertThat(parserRegistry.contains("nothing")).isFalse(); List descriptors = parserRegistry.getAllDescriptors(); assertThat(descriptors).filteredOn(d -> "spotbugs".equals(d.getId())).hasSize(1); - descriptors.forEach(d -> assertThat(d.createParser()).isNotNull()); + descriptors.forEach(d -> assertThat(d.create()).isNotNull()); } @Test @@ -75,19 +75,19 @@ void shouldConfigureCpdParser() { var parserRegistry = new ParserRegistry(); var cpdDescriptor = parserRegistry.get("cpd"); - var parser = cpdDescriptor.createParser(); + var parser = cpdDescriptor.create(); var report = parser.parse(new FileReaderFactory(getResourceAsFile("one-cpd.xml"))); assertThat(report).hasSize(2).hasSeverities(Severity.WARNING_NORMAL); - var highParser = cpdDescriptor.createParser( + var highParser = cpdDescriptor.create( new Option(CpdDescriptor.HIGH_OPTION_KEY, "20"), new Option(CpdDescriptor.NORMAL_OPTION_KEY, "10")); var highReport = highParser.parse(new FileReaderFactory(getResourceAsFile("one-cpd.xml"))); assertThat(highReport).hasSize(2).hasSeverities(Severity.WARNING_HIGH); - var lowParser = cpdDescriptor.createParser( + var lowParser = cpdDescriptor.create( new Option(CpdDescriptor.HIGH_OPTION_KEY, "100"), new Option(CpdDescriptor.NORMAL_OPTION_KEY, "50")); @@ -106,7 +106,7 @@ private void verifyPriority(final String type, final int expectedHighSize, final var parserRegistry = new ParserRegistry(); var findbugsDescriptor = parserRegistry.get("findbugs"); - var parser = findbugsDescriptor.createParser(new Option(FindBugsDescriptor.PRIORITY_OPTION_KEY, type)); + var parser = findbugsDescriptor.create(new Option(FindBugsDescriptor.PRIORITY_OPTION_KEY, type)); var confidenceReport = parser.parse(new FileReaderFactory(getResourceAsFile("findbugs-severities.xml"))); assertThat(confidenceReport).hasSize(12); diff --git a/src/test/java/edu/hm/hafner/analysis/registry/ParsersTest.java b/src/test/java/edu/hm/hafner/analysis/registry/ParsersTest.java index bf8fc8215..3b15b3eeb 100644 --- a/src/test/java/edu/hm/hafner/analysis/registry/ParsersTest.java +++ b/src/test/java/edu/hm/hafner/analysis/registry/ParsersTest.java @@ -877,7 +877,7 @@ private Report findIssuesOfTool(final int expectedSizeOfIssues, final String too var allIssues = new Report(); for (String fileName : fileNames) { - var parser = descriptor.createParser(); + var parser = descriptor.create(); var report = parser.parse(new FileReaderFactory(getResourceAsFile("../parser/").resolve(fileName))); allIssues.addAll(report); }