我正在通过以下代码创建传感器问题:
NewIssue newIssue = context.newIssue();
RuleKey ruleKey = RuleKey.of("horus", "H0001");
newIssue.forRule(ruleKey).at(newIssue.newLocation().on(file).at(file.selectLine(linea))).save();
但我无法想象如何将问题描述从默认描述覆盖为:"指标的值是xxx,大于允许的yyy"。任何线索?
答案 0 :(得分:2)
NewLocation类包含方法message(string message)
https://github.com/SonarSource/sonarqube/blob/master/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssueLocation.java#L54
因此,您可以将代码更改为:
newIssue.forRule(ruleKey).at(newIssue.newLocation().message("My Message").on(file).at(file.selectLine(linea))).save();