use of org.sonar.plugins.web.checks.WebIssue in project sonar-web by SonarSource.
the class WebSensor method saveMetrics.
private static void saveMetrics(SensorContext context, WebSourceCode sourceCode) {
InputFile inputFile = sourceCode.inputFile();
saveComplexityDistribution(context, sourceCode);
for (Map.Entry<Metric<Integer>, Integer> entry : sourceCode.getMeasures().entrySet()) {
context.<Integer>newMeasure().on(inputFile).forMetric(entry.getKey()).withValue(entry.getValue()).save();
}
for (WebIssue issue : sourceCode.getIssues()) {
NewIssue newIssue = context.newIssue().forRule(issue.ruleKey()).gap(issue.cost());
Integer line = issue.line();
NewIssueLocation location = newIssue.newLocation().on(inputFile).message(issue.message());
if (line != null) {
location.at(inputFile.selectLine(line));
}
newIssue.at(location);
newIssue.save();
}
}