diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-07-22 19:06:08 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-07-24 17:00:40 +0200 |
commit | 0d9baa81b9c819e1ded0e841be00ef10d4f6fc0e (patch) | |
tree | 9871febeb4a42dbc8422e8e32e39197aa0cf7a51 /sonar-batch/src | |
parent | 94c8b938393edc30d7bcd1693c125113a9327a58 (diff) | |
download | sonarqube-0d9baa81b9c819e1ded0e841be00ef10d4f6fc0e.tar.gz sonarqube-0d9baa81b9c819e1ded0e841be00ef10d4f6fc0e.zip |
SONAR-6368 Remove deprecated violation API
Diffstat (limited to 'sonar-batch/src')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java | 23 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java | 56 |
2 files changed, 0 insertions, 79 deletions
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; @@ -172,28 +171,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<Violation> 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); |