use of org.sonar.api.batch.sensor.issue.NewIssueLocation in project sonar-web by SonarSource.
the class HtmlSensor method locationForIssue.
private static NewIssueLocation locationForIssue(InputFile inputFile, HtmlIssue issue, NewIssue newIssue) {
NewIssueLocation location = newIssue.newLocation().on(inputFile).message(issue.message());
Integer line = issue.line();
if (issue instanceof PreciseHtmlIssue) {
PreciseHtmlIssue preciseHtmlIssue = (PreciseHtmlIssue) issue;
location.at(inputFile.newRange(issue.line(), preciseHtmlIssue.startColumn(), preciseHtmlIssue.endLine(), preciseHtmlIssue.endColumn()));
} else if (line != null) {
location.at(inputFile.selectLine(line));
}
return location;
}
use of org.sonar.api.batch.sensor.issue.NewIssueLocation in project sonar-web by SonarSource.
the class HtmlSensor method saveMetrics.
private static void saveMetrics(SensorContext context, HtmlSourceCode sourceCode) {
InputFile inputFile = sourceCode.inputFile();
for (Map.Entry<Metric<Integer>, Integer> entry : sourceCode.getMeasures().entrySet()) {
context.<Integer>newMeasure().on(inputFile).forMetric(entry.getKey()).withValue(entry.getValue()).save();
}
for (HtmlIssue issue : sourceCode.getIssues()) {
NewIssue newIssue = context.newIssue().forRule(issue.ruleKey()).gap(issue.cost());
NewIssueLocation location = locationForIssue(inputFile, issue, newIssue);
newIssue.at(location);
newIssue.save();
}
}
Aggregations