Skip to content

Commit

Permalink
Remove deprecated base class.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Mar 19, 2021
1 parent 604f86f commit 33979d8
Show file tree
Hide file tree
Showing 53 changed files with 273 additions and 225 deletions.
2 changes: 1 addition & 1 deletion SUPPORTED-FORMATS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--- DO NOT EDIT - Generated by ParserRegistry at 2021-03-15T01:05:28.200255-->
<!--- DO NOT EDIT - Generated by ParserRegistry at 2021-03-19T16:00:27.655881-->
# Supported Report Formats

The static analysis model supports the following report formats.
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/edu/hm/hafner/analysis/LookaheadParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public abstract class LookaheadParser extends IssueParser {
private static final String CMAKE_PREFIX = "-- Build files have";
private static final Pattern CMAKE_PATH = Pattern.compile(CMAKE_PREFIX + " been written to: (?<dir>.*)");

private static final int MAX_LINE_LENGTH = 4000; // see JENKINS-55805

private final Pattern pattern;

/**
Expand Down Expand Up @@ -113,7 +115,7 @@ protected abstract Optional<Issue> createIssue(Matcher matcher, LookaheadStream
* line does not contain a warning.
*/
protected boolean isLineInteresting(final String line) {
return true;
return line.length() < MAX_LINE_LENGTH; // skip long lines, see JENKINS-55805
}

/**
Expand Down
57 changes: 0 additions & 57 deletions src/main/java/edu/hm/hafner/analysis/RegexpLineParser.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.util.LookaheadStream;

import static edu.hm.hafner.analysis.Categories.*;

Expand All @@ -14,7 +15,7 @@
*
* @author jerryshea
*/
public class AcuCobolParser extends RegexpLineParser {
public class AcuCobolParser extends LookaheadParser {
private static final long serialVersionUID = -894639209290549425L;

private static final String ACU_COBOL_WARNING_PATTERN = "^\\s*(\\[.*\\])?\\s*?(.*), line ([0-9]*): Warning: (.*)$";
Expand All @@ -32,7 +33,8 @@ protected boolean isLineInteresting(final String line) {
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
return builder.setFileName(matcher.group(2))
.setLineStart(matcher.group(3))
.setCategory(guessCategory(matcher.group(4)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.util.LookaheadStream;

/**
* A parser for Ansible Lint warnings.
*
*
* The parser expects the Ansible Lint output to be in a "parseable output in the format of pep8".
* Pass the argument {@code -p} to Ansible Lint to get a compatible output.
*
* @author Ce Qi
*/
public class AnsibleLintParser extends RegexpLineParser {
public class AnsibleLintParser extends LookaheadParser {
private static final long serialVersionUID = 8481090596321427484L;

private static final String ANSIBLE_LINT_WARNING_PATTERN = "(.*)\\:([0-9]*)\\:\\s*\\[(.*)\\]\\s(.*)";
Expand All @@ -33,7 +34,8 @@ protected boolean isLineInteresting(final String line) {
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
return builder.setFileName(matcher.group(1))
.setLineStart(matcher.group(2))
.setCategory(matcher.group(3))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.util.LookaheadStream;

import static edu.hm.hafner.analysis.Categories.*;

Expand All @@ -17,7 +18,7 @@
*
* @author Ullrich Hafner
*/
public class AntJavacParser extends RegexpLineParser {
public class AntJavacParser extends LookaheadParser {
private static final long serialVersionUID = 1737791073711198075L;

private static final String ANT_JAVAC_WARNING_PATTERN = ANT_TASK + "\\s*(.*java):(\\d*):\\s*"
Expand All @@ -43,7 +44,8 @@ private boolean containsWarningPrefix(final String line) {
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
builder.setSeverity(mapSeverity(matcher.group(3)));
if (StringUtils.isNotBlank(matcher.group(8))) {
return builder.setFileName(matcher.group(8))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.util.LookaheadStream;

/**
* A parser for armcc5 compiler warnings.
*
* @author Dmytro Kutianskyi
*/
public class Armcc5CompilerParser extends RegexpLineParser {
public class Armcc5CompilerParser extends LookaheadParser {
private static final long serialVersionUID = -2677728927938443701L;

private static final String ARMCC5_WARNING_PATTERN = "^(.+)\\((\\d+)\\): (warning|error): #(.+): (.+)$";
Expand All @@ -31,7 +32,8 @@ protected boolean isLineInteresting(final String line) {
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
String type = matcher.group(3);
Severity priority;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.util.LookaheadStream;

import static edu.hm.hafner.util.IntegerParser.*;

Expand All @@ -15,7 +16,7 @@
*
* @author Emanuele Zattin
*/
public class ArmccCompilerParser extends RegexpLineParser {
public class ArmccCompilerParser extends LookaheadParser {
private static final long serialVersionUID = -2677728927938443703L;

private static final String ARMCC_WARNING_PATTERN = "^\"(.+)\", line (\\d+): ([A-Z][a-z]+):\\D*(\\d+)\\D*?:\\s+(.+)$";
Expand All @@ -28,7 +29,8 @@ public ArmccCompilerParser() {
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
String type = matcher.group(3);
int errorCode = parseInt(matcher.group(4));
Severity priority;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.util.LookaheadStream;

import static edu.hm.hafner.analysis.Categories.*;

Expand All @@ -15,7 +16,7 @@
*
* @author Johannes Utzig
*/
public class BuckminsterParser extends RegexpLineParser {
public class BuckminsterParser extends LookaheadParser {
private static final long serialVersionUID = -3723799140297979579L;

private static final String BUCKMINSTER_WARNING_PATTERN = "^.*(Warning|Error): file (.*?)(, line )?(\\d*): (.*)$";
Expand All @@ -28,7 +29,8 @@ public BuckminsterParser() {
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
Severity priority = equalsIgnoreCase(matcher.group(1), "Error") ? Severity.WARNING_HIGH : Severity.WARNING_NORMAL;
return builder.setFileName(matcher.group(2)).setLineStart(matcher.group(4))
.setCategory(guessCategory(matcher.group(5))).setMessage(matcher.group(5))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.util.LookaheadStream;

import static edu.hm.hafner.util.IntegerParser.*;

Expand All @@ -22,7 +23,7 @@
*
* @author Andrew 'Necromant' Andrianov
*/
public class CadenceIncisiveParser extends RegexpLineParser {
public class CadenceIncisiveParser extends LookaheadParser {
private static final long serialVersionUID = -3251791089328958452L;

private static final String SLASH = "/";
Expand All @@ -41,7 +42,8 @@ public CadenceIncisiveParser() {
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
String tool;
String type;
String category;
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/edu/hm/hafner/analysis/parser/ClangParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.util.LookaheadStream;

/**
* A parser for the Clang compiler warnings.
*
* @author Neil Davis
*/
public class ClangParser extends RegexpLineParser {
public class ClangParser extends LookaheadParser {
private static final long serialVersionUID = -3015592762345283182L;

private static final String CLANG_WARNING_PATTERN = "^\\s*(?:\\d+%)?([^%]*?):(\\d+):(?:(\\d+):)?" + "(?:"
Expand All @@ -29,7 +30,8 @@ public ClangParser() {
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
String message = matcher.group(5);
if (IGNORE_FORMAT.matcher(message).matches()) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.util.LookaheadStream;

/**
* A parser for the clang-tidy static analysis warnings.
*
* @author Ryan Schaefer
*/
public class ClangTidyParser extends RegexpLineParser {
public class ClangTidyParser extends LookaheadParser {
private static final long serialVersionUID = -3015592762345283182L;
private static final String CLANG_TIDY_WARNING_PATTERN =
"([^\\s]+):(\\d+):(\\d+): (warning|error): (.*?) \\[([^\\s]*?)\\]$";
Expand All @@ -28,7 +29,8 @@ public ClangTidyParser() {
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
Severity priority;
if (matcher.group(4).contains("error")) {
priority = Severity.WARNING_HIGH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.analysis.RegexpLineParser;
import edu.hm.hafner.util.LookaheadStream;

/**
* A parser for the CodeAnalysis compiler warnings.
*
* @author Rafal Jasica
*/
public class CodeAnalysisParser extends RegexpLineParser {
public class CodeAnalysisParser extends LookaheadParser {
private static final long serialVersionUID = -125874563249851L;

private static final String WARNING_PATTERN = ANT_TASK + "((MSBUILD)|((.+)\\((\\d+)\\)))"
Expand All @@ -31,7 +32,8 @@ public CodeAnalysisParser() {
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
if (StringUtils.isNotBlank(matcher.group(2))) {
return builder.setFileName(matcher.group(11))
.setLineStart(0)
Expand Down
Loading

0 comments on commit 33979d8

Please sign in to comment.