forked from jenkinsci/analysis-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGradleErrorProneParser.java
48 lines (40 loc) · 1.54 KB
/
GradleErrorProneParser.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package edu.hm.hafner.analysis.parser;
import java.util.Optional;
import java.util.regex.Matcher;
import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.analysis.ParsingException;
import edu.hm.hafner.util.LookaheadStream;
import static edu.hm.hafner.analysis.parser.ErrorProneParser.*;
/**
* A parser for ErrorProne warnings during a Gradle build.
*
* @author Ullrich Hafner
*/
public class GradleErrorProneParser extends LookaheadParser {
private static final long serialVersionUID = -3776472281369602440L;
private static final String WARNINGS_PATTERN
= "^(?<file>.+):"
+ "\\s*(?<line>\\d+)\\s*:"
+ "\\s*(?<severity>warning|error)\\s*:"
+ "\\s*\\[(?<type>\\w+)\\]\\s+"
+ "(?<message>.*)$";
/**
* Creates a new instance of {@link GradleErrorProneParser}.
*/
public GradleErrorProneParser() {
super(WARNINGS_PATTERN);
}
@Override
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) throws ParsingException {
builder.setFileName(matcher.group("file"))
.setLineStart(matcher.group("line"))
.setType(matcher.group("type"))
.setMessage(matcher.group("message"))
.guessSeverity(matcher.group("severity"))
.setDescription(createDescription(lookahead));
return builder.buildOptional();
}
}