Search in sources :

Example 1 with HtmlIssue

use of org.sonar.plugins.html.checks.HtmlIssue 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();
    }
}
Also used : NewIssueLocation(org.sonar.api.batch.sensor.issue.NewIssueLocation) NewIssue(org.sonar.api.batch.sensor.issue.NewIssue) Metric(org.sonar.api.measures.Metric) PreciseHtmlIssue(org.sonar.plugins.html.checks.PreciseHtmlIssue) HtmlIssue(org.sonar.plugins.html.checks.HtmlIssue) Map(java.util.Map) InputFile(org.sonar.api.batch.fs.InputFile)

Aggregations

Map (java.util.Map)1 InputFile (org.sonar.api.batch.fs.InputFile)1 NewIssue (org.sonar.api.batch.sensor.issue.NewIssue)1 NewIssueLocation (org.sonar.api.batch.sensor.issue.NewIssueLocation)1 Metric (org.sonar.api.measures.Metric)1 HtmlIssue (org.sonar.plugins.html.checks.HtmlIssue)1 PreciseHtmlIssue (org.sonar.plugins.html.checks.PreciseHtmlIssue)1