Skip to content

Commit

Permalink
extract method getSeverity
Browse files Browse the repository at this point in the history
  • Loading branch information
ferkulat committed Nov 14, 2021
1 parent 5af5868 commit 9417a13
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/main/java/edu/hm/hafner/analysis/parser/CodeCheckerParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,30 @@ public CodeCheckerParser() {
@Override
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {
Severity priority;
if (matcher.group("severity").contains("CRITICAL")) {
priority = Severity.ERROR;
}
else if (matcher.group("severity").contains("HIGH")) {
priority = Severity.WARNING_HIGH;
}
else if (matcher.group("severity").contains("MEDIUM")) {
priority = Severity.WARNING_NORMAL;
}
else {
priority = Severity.WARNING_LOW;
}
Severity severity = getSeverity(matcher.group("severity"));
return builder.setFileName(matcher.group("path"))
.setSeverity(priority)
.setSeverity(severity)
.setLineStart(matcher.group("line"))
.setColumnStart(matcher.group("column"))
.setCategory(matcher.group("category"))
.setMessage(matcher.group("message"))
.buildOptional();
}

private Severity getSeverity(final String severityText) {
Severity severity;
if (severityText.contains("CRITICAL")) {
severity = Severity.ERROR;
}
else if (severityText.contains("HIGH")) {
severity = Severity.WARNING_HIGH;
}
else if (severityText.contains("MEDIUM")) {
severity = Severity.WARNING_NORMAL;
}
else {
severity = Severity.WARNING_LOW;
}
return severity;
}
}

0 comments on commit 9417a13

Please sign in to comment.