forked from jenkinsci/analysis-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQacSourceCodeAnalyserParser.java
51 lines (42 loc) · 1.5 KB
/
QacSourceCodeAnalyserParser.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
49
50
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.Severity;
import edu.hm.hafner.analysis.RegexpLineParser;
/**
* A parser for PRQA QA-C Sourcecode Analyser warnings.
*
* @author Sven Lübke
*/
public class QacSourceCodeAnalyserParser extends RegexpLineParser {
private static final long serialVersionUID = -8104046102312005968L;
/** Pattern of QA-C Sourcecode Analyser warnings. */
private static final String QAC_WARNING_PATTERN = "^(.+?)\\((\\d+),(\\d+)\\): (Err|Msg)\\((\\d+):(\\d+)\\) (.+?)$";
/**
* Creates a new instance of {@code QACSourceCodeAnalyserParser}.
*/
public QacSourceCodeAnalyserParser() {
super(QAC_WARNING_PATTERN);
}
@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
Severity priority;
String category;
if ("err".equalsIgnoreCase(matcher.group(4))) {
priority = Severity.WARNING_HIGH;
category = "ERROR";
}
else {
priority = Severity.WARNING_NORMAL;
category = "Warning";
}
return builder.setFileName(matcher.group(1))
.setLineStart(matcher.group(2))
.setCategory(category)
.setMessage(matcher.group(7))
.setSeverity(priority)
.buildOptional();
}
}