forked from jenkinsci/analysis-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoLintParser.java
42 lines (34 loc) · 1.26 KB
/
GoLintParser.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
package edu.hm.hafner.analysis.parser;
import java.util.Optional;
import java.util.regex.Matcher;
import static edu.hm.hafner.analysis.Categories.guessCategory;
import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.RegexpLineParser;
/**
* A parser for the golint tool in the Go toolchain.
*
* @author Ryan Cox
*/
public class GoLintParser extends RegexpLineParser {
private static final long serialVersionUID = -5895416507693444713L;
// conn.go:360:3: should replace c.writeSeq += 1 with c.writeSeq++
private static final String GOLINT_WARNING_PATTERN = "^(.*?):(\\d+?):(\\d*?):\\s*(.*)$";
/**
* Creates a new instance of {@link GoLintParser}.
*/
public GoLintParser() {
super(GOLINT_WARNING_PATTERN);
}
@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
String message = matcher.group(4);
String category = guessCategory(message);
return builder.setFileName(matcher.group(1))
.setLineStart(matcher.group(2))
.setColumnStart(matcher.group(3))
.setCategory(category)
.setMessage(message)
.buildOptional();
}
}