From 0d9baa81b9c819e1ded0e841be00ef10d4f6fc0e Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Wed, 22 Jul 2015 19:06:08 +0200 Subject: SONAR-6368 Remove deprecated violation API --- .../batch/deprecated/DeprecatedSensorContext.java | 23 --------- .../java/org/sonar/batch/index/DefaultIndex.java | 56 ---------------------- 2 files changed, 79 deletions(-) (limited to 'sonar-batch/src') diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java index 0a33396354a..32837480dbe 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java @@ -41,7 +41,6 @@ import org.sonar.api.resources.Directory; import org.sonar.api.resources.File; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; -import org.sonar.api.rules.Violation; import org.sonar.api.utils.SonarException; import org.sonar.batch.sensor.DefaultSensorContext; import org.sonar.batch.sensor.coverage.CoverageExclusions; @@ -171,28 +170,6 @@ public class DeprecatedSensorContext extends DefaultSensorContext implements Sen } } - @Override - public void saveViolation(Violation violation, boolean force) { - if (violation.getResource() == null) { - violation.setResource(resourceOrProject(violation.getResource())); - } - index.addViolation(violation, force); - } - - @Override - public void saveViolation(Violation violation) { - saveViolation(violation, false); - } - - @Override - public void saveViolations(Collection violations) { - if (violations != null) { - for (Violation violation : violations) { - saveViolation(violation); - } - } - } - @Override public Dependency saveDependency(Dependency dependency) { return null; diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java index 753012f438d..88f0d47ba0e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java @@ -37,11 +37,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.batch.SonarIndex; import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.api.batch.fs.InputDir; -import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.measure.MetricFinder; -import org.sonar.api.batch.sensor.issue.NewIssueLocation; -import org.sonar.api.batch.sensor.issue.internal.DefaultIssue; import org.sonar.api.design.Dependency; import org.sonar.api.measures.Measure; import org.sonar.api.measures.MeasuresFilter; @@ -52,9 +48,6 @@ import org.sonar.api.resources.Project; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Resource; import org.sonar.api.resources.ResourceUtils; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.Violation; import org.sonar.api.scan.filesystem.PathResolver; import org.sonar.batch.DefaultProjectTree; import org.sonar.batch.scan.measure.MeasureCache; @@ -190,55 +183,6 @@ public class DefaultIndex extends SonarIndex { return buckets.keySet(); } - // - // - // - // VIOLATIONS - // - // - // - - @Override - public void addViolation(Violation violation, boolean force) { - // Reload - Resource resource = getResource(violation.getResource()); - if (resource == null) { - LOG.warn("Resource is not indexed. Ignoring violation {}", violation); - return; - } - BatchComponent component = componentCache.get(resource); - - Rule rule = violation.getRule(); - if (rule == null) { - LOG.warn("Rule is null. Ignoring violation {}", violation); - return; - } - - // keep a limitation (bug?) of deprecated violations api : severity is always - // set by sonar. The severity set by plugins is overridden. - // This is not the case with issue api. - - DefaultIssue newIssue = new DefaultIssue(sensorStorage); - NewIssueLocation newLocation = newIssue.newLocation(); - if (component.isProjectOrModule()) { - newLocation.onProject(); - } else if (component.isDir()) { - newLocation.onDir((InputDir) component.inputPath()); - } else if (component.isFile()) { - InputFile inputFile = (InputFile) component.inputPath(); - newLocation.onFile(inputFile); - if (violation.hasLineId()) { - newLocation.at(inputFile.selectLine(violation.getLineId())); - } - } - newLocation.message(violation.getMessage()); - - newIssue.addLocation(newLocation) - .forRule(RuleKey.of(violation.getRule().getRepositoryKey(), violation.getRule().getKey())) - .effortToFix(violation.getCost()) - .save(); - } - @Override public String getSource(Resource reference) { Resource resource = getResource(reference); -- cgit v1.2.3