use of org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue.Severity in project sonarlint-core by SonarSource.
the class ProxyIssueListener method handle.
@Override
public void handle(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue issue) {
Severity severity;
ClientInputFile inputFile = issue.getInputFile();
switch(issue.getSeverity()) {
case "MINOR":
severity = Severity.MINOR;
break;
case "BLOCKER":
severity = Severity.BLOCKER;
break;
case "INFO":
severity = Severity.INFO;
break;
case "CRITICAL":
severity = Severity.CRITICAL;
break;
case "MAJOR":
default:
severity = Severity.MAJOR;
break;
}
Type type = Type.CODE_SMELL;
if (issue.getType() != null) {
switch(StringUtils.lowerCase(issue.getType())) {
case "bug":
type = Type.BUG;
break;
case "vulnerability":
type = Type.VULNERABILITY;
break;
case "code_smell":
default:
type = Type.CODE_SMELL;
break;
}
}
Issue.Builder builder = Issue.newBuilder();
builder.setRuleKey(issue.getRuleKey()).setRuleName(issue.getRuleName()).setMessage(issue.getMessage()).setSeverity(severity).setType(type).setStartLine(issue.getStartLine() != null ? issue.getStartLine() : 0).setStartLineOffset(issue.getStartLineOffset() != null ? issue.getStartLineOffset() : 0).setEndLine(issue.getEndLine() != null ? issue.getEndLine() : 0).setEndLineOffset(issue.getEndLineOffset() != null ? issue.getEndLineOffset() : 0);
if (inputFile != null) {
builder.setFilePath(inputFile.getPath());
if (inputFile.getClientObject() != null) {
builder.setUserObject((String) inputFile.getClientObject());
}
}
observer.onNext(builder.build());
}
Aggregations