forked from jenkinsci/analysis-model
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnsibleLintParser.java
More file actions
44 lines (36 loc) · 1.31 KB
/
AnsibleLintParser.java
File metadata and controls
44 lines (36 loc) · 1.31 KB
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
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.RegexpLineParser;
/**
* 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 {
private static final long serialVersionUID = 8481090596321427484L;
private static final String ANSIBLE_LINT_WARNING_PATTERN = "(.*)\\:([0-9]*)\\:\\s*\\[(.*)\\]\\s(.*)";
/**
* Creates a new instance of {@link AnsibleLintParser}.
*/
public AnsibleLintParser() {
super(ANSIBLE_LINT_WARNING_PATTERN);
}
@Override
protected boolean isLineInteresting(final String line) {
return line.contains("[");
}
@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
return builder.setFileName(matcher.group(1))
.setLineStart(matcher.group(2))
.setCategory(matcher.group(3))
.setMessage(matcher.group(4))
.buildOptional();
}
}