@Test public void should_parse_gometalinter_report_warning_line() { String line = "SelfAssignement.go:4:6:warning: exported type User should have comment or be unexported (golint)"; org.sonar.go.externalreport.ExternalIssue issue = new GoMetaLinterReportSensor().parse(line); assertThat(issue).isNotNull(); assertThat(issue.linter).isEqualTo("golint"); assertThat(issue.type).isEqualTo(RuleType.CODE_SMELL); assertThat(issue.ruleKey).isEqualTo("Exported"); assertThat(issue.filename).isEqualTo("SelfAssignement.go"); assertThat(issue.lineNumber).isEqualTo(4); assertThat(issue.message).isEqualTo("exported type User should have comment or be unexported"); }
@Nullable @Override ExternalIssue parse(String line) { Matcher matcher = GO_META_LINTER_REGEX.matcher(line); if (matcher.matches()) { String linter = mapLinterName(matcher.group("linter").trim()); RuleType type = "error".equals(matcher.group("severity")) ? RuleType.BUG : RuleType.CODE_SMELL; String filename = matcher.group("file").trim(); int lineNumber = Integer.parseInt(matcher.group("line").trim()); String message = matcher.group("message").trim(); Matcher ruleKeyMatcher = RULE_KEY_REGEX.matcher(message); String ruleKey = null; if (ruleKeyMatcher.find()) { ruleKey = ruleKeyMatcher.group("ruleKey"); message = message.substring(0, ruleKeyMatcher.start()).trim(); } return new ExternalIssue(linter, type, ruleKey, filename, lineNumber, message); } else { LOG.debug(logPrefix() + "Unexpected line: " + line); } return null; }
GoMetaLinterReportSensor extends AbstractReportSensor { @Nullable @Override ExternalIssue parse(String line) { Matcher matcher = GO_META_LINTER_REGEX.matcher(line); if (matcher.matches()) { String linter = mapLinterName(matcher.group("linter").trim()); RuleType type = "error".equals(matcher.group("severity")) ? RuleType.BUG : RuleType.CODE_SMELL; String filename = matcher.group("file").trim(); int lineNumber = Integer.parseInt(matcher.group("line").trim()); String message = matcher.group("message").trim(); Matcher ruleKeyMatcher = RULE_KEY_REGEX.matcher(message); String ruleKey = null; if (ruleKeyMatcher.find()) { ruleKey = ruleKeyMatcher.group("ruleKey"); message = message.substring(0, ruleKeyMatcher.start()).trim(); } return new ExternalIssue(linter, type, ruleKey, filename, lineNumber, message); } else { LOG.debug(logPrefix() + "Unexpected line: " + line); } return null; } }
GoMetaLinterReportSensor extends AbstractReportSensor { @Nullable @Override ExternalIssue parse(String line) { Matcher matcher = GO_META_LINTER_REGEX.matcher(line); if (matcher.matches()) { String linter = mapLinterName(matcher.group("linter").trim()); RuleType type = "error".equals(matcher.group("severity")) ? RuleType.BUG : RuleType.CODE_SMELL; String filename = matcher.group("file").trim(); int lineNumber = Integer.parseInt(matcher.group("line").trim()); String message = matcher.group("message").trim(); Matcher ruleKeyMatcher = RULE_KEY_REGEX.matcher(message); String ruleKey = null; if (ruleKeyMatcher.find()) { ruleKey = ruleKeyMatcher.group("ruleKey"); message = message.substring(0, ruleKeyMatcher.start()).trim(); } return new ExternalIssue(linter, type, ruleKey, filename, lineNumber, message); } else { LOG.debug(logPrefix() + "Unexpected line: " + line); } return null; }  }
GoMetaLinterReportSensor extends AbstractReportSensor { @Nullable @Override ExternalIssue parse(String line) { Matcher matcher = GO_META_LINTER_REGEX.matcher(line); if (matcher.matches()) { String linter = mapLinterName(matcher.group("linter").trim()); RuleType type = "error".equals(matcher.group("severity")) ? RuleType.BUG : RuleType.CODE_SMELL; String filename = matcher.group("file").trim(); int lineNumber = Integer.parseInt(matcher.group("line").trim()); String message = matcher.group("message").trim(); Matcher ruleKeyMatcher = RULE_KEY_REGEX.matcher(message); String ruleKey = null; if (ruleKeyMatcher.find()) { ruleKey = ruleKeyMatcher.group("ruleKey"); message = message.substring(0, ruleKeyMatcher.start()).trim(); } return new ExternalIssue(linter, type, ruleKey, filename, lineNumber, message); } else { LOG.debug(logPrefix() + "Unexpected line: " + line); } return null; }   }
GoMetaLinterReportSensor extends AbstractReportSensor { @Nullable @Override ExternalIssue parse(String line) { Matcher matcher = GO_META_LINTER_REGEX.matcher(line); if (matcher.matches()) { String linter = mapLinterName(matcher.group("linter").trim()); RuleType type = "error".equals(matcher.group("severity")) ? RuleType.BUG : RuleType.CODE_SMELL; String filename = matcher.group("file").trim(); int lineNumber = Integer.parseInt(matcher.group("line").trim()); String message = matcher.group("message").trim(); Matcher ruleKeyMatcher = RULE_KEY_REGEX.matcher(message); String ruleKey = null; if (ruleKeyMatcher.find()) { ruleKey = ruleKeyMatcher.group("ruleKey"); message = message.substring(0, ruleKeyMatcher.start()).trim(); } return new ExternalIssue(linter, type, ruleKey, filename, lineNumber, message); } else { LOG.debug(logPrefix() + "Unexpected line: " + line); } return null; }   static final String PROPERTY_KEY; }