aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-01-07 22:01:59 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-01-07 22:07:30 +0100
commitd3dd88adf13034f9972a5a673280709cca95f935 (patch)
treeff1caadf8801ad142431b6bd36e77ab19e68bdce
parentc698fdc1b308fef1a7af5767e42e6b7e82fb502e (diff)
downloadsonarqube-d3dd88adf13034f9972a5a673280709cca95f935.tar.gz
sonarqube-d3dd88adf13034f9972a5a673280709cca95f935.zip
SONAR-6014 Drop deprecated violations
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java17
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/ViolationFilters.java60
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java83
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedViolations.java75
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java42
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java10
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java29
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/ViolationFiltersTest.java68
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java93
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedViolationsTest.java89
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/IssueFiltersTest.java33
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/ModuleIssuesTest.java19
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java22
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java27
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rules/ViolationFilter.java41
19 files changed, 76 insertions, 642 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java
index fe7cdd7f57c..1fa2a1b6450 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java
@@ -37,7 +37,6 @@ 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.api.violations.ViolationQuery;
import org.sonar.batch.duplication.DuplicationCache;
import org.sonar.batch.duplication.DuplicationUtils;
import org.sonar.batch.scan.measure.MeasureCache;
@@ -207,22 +206,6 @@ public class DefaultDecoratorContext implements DecoratorContext {
return this;
}
- /**
- * {@inheritDoc}
- */
- @Override
- public List<Violation> getViolations(ViolationQuery violationQuery) {
- return sonarIndex.getViolations(violationQuery);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<Violation> getViolations() {
- return sonarIndex.getViolations(resource);
- }
-
@Override
public Dependency saveDependency(Dependency dependency) {
checkReadOnly("addDependency");
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ViolationFilters.java b/sonar-batch/src/main/java/org/sonar/batch/ViolationFilters.java
deleted file mode 100644
index 2e24b348f26..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/ViolationFilters.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.rules.Violation;
-import org.sonar.api.rules.ViolationFilter;
-
-public class ViolationFilters {
-
- private static final Logger LOG = LoggerFactory.getLogger(ViolationFilters.class);
-
- private ViolationFilter[] filters;
-
- public ViolationFilters(ViolationFilter[] filters) {
- this.filters = filters;
- }
-
- public ViolationFilters() {
- this(new ViolationFilter[0]);
- }
-
- public boolean isEmpty() {
- return filters.length==0;
- }
-
- /**
- * Return true if the violation must be saved. If false then it is ignored.
- */
- public boolean isIgnored(Violation violation) {
- boolean ignored = false;
- int index = 0;
- while (!ignored && index < filters.length) {
- ignored = filters[index].isIgnored(violation);
- if (ignored && LOG.isDebugEnabled()) {
- LOG.debug("Violation {} is excluded by the filter {}", violation, filters[index]);
- }
- index++;
- }
- return ignored;
- }
-}
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 59dab76609b..d0d99bc4beb 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
@@ -48,9 +48,7 @@ import org.sonar.api.rules.Rule;
import org.sonar.api.rules.Violation;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.SonarException;
-import org.sonar.api.violations.ViolationQuery;
import org.sonar.batch.ProjectTree;
-import org.sonar.batch.issue.DeprecatedViolations;
import org.sonar.batch.issue.ModuleIssues;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.batch.scan2.DefaultSensorContext;
@@ -85,7 +83,6 @@ public class DefaultIndex extends SonarIndex {
private Map<Resource, Map<Resource, Dependency>> outgoingDependenciesByResource = Maps.newLinkedHashMap();
private Map<Resource, Map<Resource, Dependency>> incomingDependenciesByResource = Maps.newLinkedHashMap();
private ProjectTree projectTree;
- private final DeprecatedViolations deprecatedViolations;
private ModuleIssues moduleIssues;
private final MeasureCache measureCache;
private final ResourceKeyMigration migration;
@@ -95,14 +92,24 @@ public class DefaultIndex extends SonarIndex {
public DefaultIndex(ResourceCache resourceCache, DependencyPersister dependencyPersister,
LinkPersister linkPersister, EventPersister eventPersister, ProjectTree projectTree, MetricFinder metricFinder,
- DeprecatedViolations deprecatedViolations, ResourceKeyMigration migration, MeasureCache measureCache) {
+ ResourceKeyMigration migration, MeasureCache measureCache) {
this.resourceCache = resourceCache;
this.dependencyPersister = dependencyPersister;
this.linkPersister = linkPersister;
this.eventPersister = eventPersister;
this.projectTree = projectTree;
this.metricFinder = metricFinder;
- this.deprecatedViolations = deprecatedViolations;
+ this.migration = migration;
+ this.measureCache = measureCache;
+ }
+
+ public DefaultIndex(ResourceCache resourceCache, ProjectTree projectTree, MetricFinder metricFinder, ResourceKeyMigration migration, MeasureCache measureCache) {
+ this.resourceCache = resourceCache;
+ this.dependencyPersister = null;
+ this.linkPersister = null;
+ this.eventPersister = null;
+ this.projectTree = projectTree;
+ this.metricFinder = metricFinder;
this.migration = migration;
this.measureCache = measureCache;
}
@@ -264,7 +271,7 @@ public class DefaultIndex extends SonarIndex {
addDependency(parentDependency);
}
- if (registerDependency(dependency)) {
+ if (registerDependency(dependency) && dependencyPersister != null) {
dependencyPersister.saveDependency(currentProject, from, to, dependency, parentDependency);
}
return dependency;
@@ -361,51 +368,6 @@ public class DefaultIndex extends SonarIndex {
//
//
- /**
- * {@inheritDoc}
- */
- @Override
- public List<Violation> getViolations(ViolationQuery violationQuery) {
- Resource resource = violationQuery.getResource();
- if (resource == null) {
- throw new IllegalArgumentException("A resource must be set on the ViolationQuery in order to search for violations.");
- }
-
- if (!Scopes.isHigherThanOrEquals(resource, Scopes.FILE)) {
- return Collections.emptyList();
- }
-
- Bucket bucket = buckets.get(resource);
- if (bucket == null) {
- return Collections.emptyList();
- }
-
- List<Violation> violations = deprecatedViolations.get(bucket.getResource().getEffectiveKey());
- if (violationQuery.getSwitchMode() == ViolationQuery.SwitchMode.BOTH) {
- return violations;
- }
-
- List<Violation> filteredViolations = Lists.newArrayList();
- for (Violation violation : violations) {
- if (isFiltered(violation, violationQuery.getSwitchMode())) {
- filteredViolations.add(violation);
- }
- }
- return filteredViolations;
- }
-
- private static boolean isFiltered(Violation violation, ViolationQuery.SwitchMode mode) {
- return mode == ViolationQuery.SwitchMode.BOTH || isSwitchOff(violation, mode) || isSwitchOn(violation, mode);
- }
-
- private static boolean isSwitchOff(Violation violation, ViolationQuery.SwitchMode mode) {
- return mode == ViolationQuery.SwitchMode.OFF && violation.isSwitchedOff();
- }
-
- private static boolean isSwitchOn(Violation violation, ViolationQuery.SwitchMode mode) {
- return mode == ViolationQuery.SwitchMode.ON && !violation.isSwitchedOff();
- }
-
@Override
public void addViolation(Violation violation, boolean force) {
Resource resource = violation.getResource();
@@ -446,12 +408,16 @@ public class DefaultIndex extends SonarIndex {
@Override
public void addLink(ProjectLink link) {
- linkPersister.saveLink(currentProject, link);
+ if (linkPersister != null) {
+ linkPersister.saveLink(currentProject, link);
+ }
}
@Override
public void deleteLink(String key) {
- linkPersister.deleteLink(currentProject, key);
+ if (linkPersister != null) {
+ linkPersister.deleteLink(currentProject, key);
+ }
}
//
@@ -469,12 +435,17 @@ public class DefaultIndex extends SonarIndex {
if (reload == null) {
return Collections.emptyList();
}
+ if (eventPersister == null) {
+ throw new UnsupportedOperationException("Event are not available in preview mode");
+ }
return eventPersister.getEvents(reload);
}
@Override
public void deleteEvent(Event event) {
- eventPersister.deleteEvent(event);
+ if (eventPersister != null) {
+ eventPersister.deleteEvent(event);
+ }
}
@Override
@@ -483,7 +454,9 @@ public class DefaultIndex extends SonarIndex {
event.setDate(date);
event.setCreatedAt(new Date());
- eventPersister.saveEvent(resource, event);
+ if (eventPersister != null) {
+ eventPersister.saveEvent(resource, event);
+ }
return null;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedViolations.java b/sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedViolations.java
deleted file mode 100644
index 13e03a3f9c6..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedViolations.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.issue;
-
-import com.google.common.collect.Lists;
-import org.sonar.api.BatchComponent;
-import org.sonar.api.issue.internal.DefaultIssue;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.rules.RulePriority;
-import org.sonar.api.rules.Violation;
-import org.sonar.batch.index.ResourceCache;
-
-import java.util.List;
-
-/**
- * Bridge with violations, that have been deprecated in 3.6.
- *
- * @since 3.6
- */
-public class DeprecatedViolations implements BatchComponent {
-
- private final IssueCache issueCache;
- private final RuleFinder ruleFinder;
- private final ResourceCache resourceCache;
-
- public DeprecatedViolations(IssueCache issueCache, RuleFinder ruleFinder, ResourceCache resourceCache) {
- this.issueCache = issueCache;
- this.ruleFinder = ruleFinder;
- this.resourceCache = resourceCache;
- }
-
- public List<Violation> get(String componentKey) {
- Iterable<DefaultIssue> issues = issueCache.byComponent(componentKey);
- List<Violation> violations = Lists.newArrayList();
- for (DefaultIssue issue : issues) {
- violations.add(toViolation(issue));
- }
- return violations;
- }
-
- public Violation toViolation(DefaultIssue issue) {
- Rule rule = ruleFinder.findByKey(issue.ruleKey());
- Resource resource = resourceCache.get(issue.componentKey()).resource();
- Violation violation = new Violation(rule, resource);
- violation.setNew(issue.isNew());
- violation.setChecksum(issue.checksum());
- violation.setMessage(issue.message());
- violation.setCost(issue.effortToFix());
- violation.setLineId(issue.line());
- violation.setCreatedAt(issue.creationDate());
- violation.setManual(issue.reporter() != null);
- violation.setSeverity(RulePriority.valueOf(issue.severity()));
- violation.setSwitchedOff(issue.resolution() != null);
- return violation;
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java
index a6987f2368e..469a65cb909 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java
@@ -22,58 +22,30 @@ package org.sonar.batch.issue;
import org.sonar.api.BatchComponent;
import org.sonar.api.issue.batch.IssueFilter;
import org.sonar.api.issue.internal.DefaultIssue;
-import org.sonar.api.rules.Violation;
-import org.sonar.batch.ViolationFilters;
-
-import javax.annotation.Nullable;
public class IssueFilters implements BatchComponent {
- private final ViolationFilters deprecatedFilters;
- private final DeprecatedViolations deprecatedViolations;
private final org.sonar.api.issue.IssueFilter[] exclusionFilters;
private final IssueFilter[] filters;
- public IssueFilters(@Nullable ViolationFilters deprecatedFilters, @Nullable DeprecatedViolations deprecatedViolations, org.sonar.api.issue.IssueFilter[] exclusionFilters,
- IssueFilter[] filters) {
- this.deprecatedFilters = deprecatedFilters;
- this.deprecatedViolations = deprecatedViolations;
+ public IssueFilters(org.sonar.api.issue.IssueFilter[] exclusionFilters, IssueFilter[] filters) {
this.exclusionFilters = exclusionFilters;
this.filters = filters;
}
- public IssueFilters(@Nullable ViolationFilters deprecatedFilters, @Nullable DeprecatedViolations deprecatedViolations, IssueFilter[] filters) {
- this(deprecatedFilters, deprecatedViolations, new org.sonar.api.issue.IssueFilter[0], filters);
- }
-
- public IssueFilters(@Nullable ViolationFilters deprecatedFilters, @Nullable DeprecatedViolations deprecatedViolations, org.sonar.api.issue.IssueFilter[] exclusionFilters) {
- this(deprecatedFilters, deprecatedViolations, exclusionFilters, new IssueFilter[0]);
- }
-
- public IssueFilters(@Nullable ViolationFilters deprecatedFilters, @Nullable DeprecatedViolations deprecatedViolations) {
- this(deprecatedFilters, deprecatedViolations, new org.sonar.api.issue.IssueFilter[0]);
- }
-
- /**
- * Used by scan2
- */
- public IssueFilters(org.sonar.api.issue.IssueFilter[] exclusionFilters, IssueFilter[] filters) {
- this(null, null, exclusionFilters, filters);
- }
-
public IssueFilters(org.sonar.api.issue.IssueFilter[] exclusionFilters) {
- this(null, null, exclusionFilters, new IssueFilter[0]);
+ this(exclusionFilters, new IssueFilter[0]);
}
public IssueFilters(IssueFilter[] filters) {
- this(null, null, new org.sonar.api.issue.IssueFilter[0], filters);
+ this(new org.sonar.api.issue.IssueFilter[0], filters);
}
public IssueFilters() {
- this(null, null, new org.sonar.api.issue.IssueFilter[0], new IssueFilter[0]);
+ this(new org.sonar.api.issue.IssueFilter[0], new IssueFilter[0]);
}
- public boolean accept(DefaultIssue issue, @Nullable Violation violation) {
+ public boolean accept(DefaultIssue issue) {
if (new DefaultIssueFilterChain(filters).accept(issue)) {
// Apply deprecated rules only if filter chain accepts the current issue
for (org.sonar.api.issue.IssueFilter filter : exclusionFilters) {
@@ -81,10 +53,6 @@ public class IssueFilters implements BatchComponent {
return false;
}
}
- if (deprecatedFilters != null && !deprecatedFilters.isEmpty() && deprecatedViolations != null) {
- Violation v = violation != null ? violation : deprecatedViolations.toViolation(issue);
- return !deprecatedFilters.isIgnored(v);
- }
return true;
} else {
return false;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
index 5997f636ba2..93dc8a3c4b8 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
@@ -62,13 +62,9 @@ public class ModuleIssues {
this(activeRules, rules, cache, null, filters);
}
- public boolean initAndAddIssue(DefaultIssue issue) {
- return initAndAddIssue(issue, null);
- }
-
public boolean initAndAddViolation(Violation violation) {
DefaultIssue issue = newIssue(violation);
- return initAndAddIssue(issue, violation);
+ return initAndAddIssue(issue);
}
private DefaultIssue newIssue(Violation violation) {
@@ -84,7 +80,7 @@ public class ModuleIssues {
.build();
}
- private boolean initAndAddIssue(DefaultIssue issue, @Nullable Violation violation) {
+ public boolean initAndAddIssue(DefaultIssue issue) {
RuleKey ruleKey = issue.ruleKey();
Rule rule = rules.find(ruleKey);
validateRule(issue, rule);
@@ -94,7 +90,7 @@ public class ModuleIssues {
return false;
}
updateIssue(issue, rule, activeRule);
- if (filters.accept(issue, violation)) {
+ if (filters.accept(issue)) {
cache.put(issue);
return true;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
index c022067683e..e219cae92dd 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
@@ -33,7 +33,6 @@ import org.sonar.batch.DefaultSensorContext;
import org.sonar.batch.DefaultTimeMachine;
import org.sonar.batch.ProjectTree;
import org.sonar.batch.ResourceFilters;
-import org.sonar.batch.ViolationFilters;
import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
import org.sonar.batch.bootstrap.ExtensionInstaller;
import org.sonar.batch.bootstrap.ExtensionMatcher;
@@ -61,8 +60,8 @@ import org.sonar.batch.phases.PhasesTimeProfiler;
import org.sonar.batch.qualitygate.GenerateQualityGateEvents;
import org.sonar.batch.qualitygate.QualityGateProvider;
import org.sonar.batch.qualitygate.QualityGateVerifier;
-import org.sonar.batch.report.IssuesPublisher;
import org.sonar.batch.report.ComponentsPublisher;
+import org.sonar.batch.report.IssuesPublisher;
import org.sonar.batch.rule.ActiveRulesProvider;
import org.sonar.batch.rule.ModuleQProfiles;
import org.sonar.batch.rule.QProfileDecorator;
@@ -150,7 +149,6 @@ public class ModuleScanContainer extends ComponentContainer {
SensorContextAdapter.class,
BatchExtensionDictionnary.class,
DefaultTimeMachine.class,
- ViolationFilters.class,
IssueFilters.class,
MeasurementFilters.class,
ResourceFilters.class,
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
index 5ae7992ac4d..7fc792ac3ea 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
@@ -35,6 +35,7 @@ import org.sonar.batch.DefaultFileLinesContextFactory;
import org.sonar.batch.DefaultResourceCreationLock;
import org.sonar.batch.ProjectConfigurator;
import org.sonar.batch.ProjectTree;
+import org.sonar.batch.bootstrap.BootstrapProperties;
import org.sonar.batch.bootstrap.ExtensionInstaller;
import org.sonar.batch.bootstrap.ExtensionMatcher;
import org.sonar.batch.bootstrap.ExtensionUtils;
@@ -47,7 +48,6 @@ import org.sonar.batch.duplication.DuplicationCache;
import org.sonar.batch.index.Caches;
import org.sonar.batch.index.ComponentDataCache;
import org.sonar.batch.index.DefaultIndex;
-import org.sonar.batch.index.ResourcePersister;
import org.sonar.batch.index.DependencyPersister;
import org.sonar.batch.index.DuplicationPersister;
import org.sonar.batch.index.EventPersister;
@@ -56,9 +56,9 @@ import org.sonar.batch.index.LinkPersister;
import org.sonar.batch.index.MeasurePersister;
import org.sonar.batch.index.ResourceCache;
import org.sonar.batch.index.ResourceKeyMigration;
+import org.sonar.batch.index.ResourcePersister;
import org.sonar.batch.index.SourcePersister;
import org.sonar.batch.issue.DefaultProjectIssues;
-import org.sonar.batch.issue.DeprecatedViolations;
import org.sonar.batch.issue.IssueCache;
import org.sonar.batch.languages.DefaultLanguagesReferential;
import org.sonar.batch.phases.GraphPersister;
@@ -86,14 +86,20 @@ import org.sonar.core.test.TestablePerspectiveLoader;
import org.sonar.core.user.DefaultUserFinder;
public class ProjectScanContainer extends ComponentContainer {
+ private boolean sensorMode;
+
public ProjectScanContainer(ComponentContainer taskContainer) {
super(taskContainer);
+ sensorMode = CoreProperties.ANALYSIS_MODE_SENSOR.equals(taskContainer.getComponentByType(BootstrapProperties.class).property(CoreProperties.ANALYSIS_MODE));
}
@Override
protected void doBeforeStart() {
projectBootstrap();
addBatchComponents();
+ if (!sensorMode) {
+ addDataBaseComponents();
+ }
fixMavenExecutor();
addBatchExtensions();
Settings settings = getComponentByType(Settings.class);
@@ -129,13 +135,6 @@ public class ProjectScanContainer extends ComponentContainer {
add(
new ProjectReferentialsProvider(),
DefaultResourceCreationLock.class,
- DependencyPersister.class,
- EventPersister.class,
- LinkPersister.class,
- MeasurePersister.class,
- DuplicationPersister.class,
- ResourcePersister.class,
- SourcePersister.class,
CodeColorizers.class,
DefaultNotificationManager.class,
MetricProvider.class,
@@ -159,7 +158,6 @@ public class ProjectScanContainer extends ComponentContainer {
IssueUpdater.class,
FunctionExecutor.class,
IssueWorkflow.class,
- DeprecatedViolations.class,
IssueCache.class,
IssueNotifications.class,
DefaultProjectIssues.class,
@@ -199,6 +197,17 @@ public class ProjectScanContainer extends ComponentContainer {
ProjectSettings.class);
}
+ private void addDataBaseComponents() {
+ add(
+ DependencyPersister.class,
+ EventPersister.class,
+ LinkPersister.class,
+ MeasurePersister.class,
+ DuplicationPersister.class,
+ ResourcePersister.class,
+ SourcePersister.class);
+ }
+
private void fixMavenExecutor() {
if (getComponentByType(MavenPluginExecutor.class) == null) {
add(FakeMavenPluginExecutor.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java
index 58eaf6d5fa2..cb70fa25b6a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java
@@ -142,7 +142,7 @@ public class DefaultSensorContext extends BaseSensorContext {
updateIssue((DefaultIssue) issue, activeRule);
- if (!issueFilters.accept(SensorContextAdapter.toDefaultIssue(def.getKey(), resourceKey, issue), null)) {
+ if (!issueFilters.accept(SensorContextAdapter.toDefaultIssue(def.getKey(), resourceKey, issue))) {
LOG.debug("Issue {} was excluded by some filters.", issue);
return;
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/ViolationFiltersTest.java b/sonar-batch/src/test/java/org/sonar/batch/ViolationFiltersTest.java
deleted file mode 100644
index c1449cfb941..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/ViolationFiltersTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch;
-
-import org.junit.Test;
-import org.sonar.api.rules.Violation;
-import org.sonar.api.rules.ViolationFilter;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-public class ViolationFiltersTest {
-
- @Test
- public void doNotFailIfNoFilters() {
- ViolationFilters filters = new ViolationFilters();
- assertThat(filters.isIgnored(new Violation(null)), is(false));
- }
-
- @Test
- public void ignoreViolation() {
- ViolationFilters filters = new ViolationFilters(new ViolationFilter[]{
- new FakeFilter(false),
- new FakeFilter(true),
- new FakeFilter(false),
- });
- assertThat(filters.isIgnored(new Violation(null)), is(true));
- }
-
- @Test
- public void doNotIgnoreValidViolations() {
- ViolationFilters filters = new ViolationFilters(new ViolationFilter[]{
- new FakeFilter(false),
- new FakeFilter(false),
- new FakeFilter(false),
- });
- assertThat(filters.isIgnored(new Violation(null)), is(false));
- }
-
- private static class FakeFilter implements ViolationFilter {
- private boolean ignore;
-
- private FakeFilter(boolean ignore) {
- this.ignore = ignore;
- }
-
- public boolean isIgnored(Violation violation) {
- return ignore;
- }
- }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
index 42ca92d27b2..b37474770b9 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
@@ -38,18 +38,13 @@ import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.rules.Violation;
-import org.sonar.api.violations.ViolationQuery;
import org.sonar.batch.ProjectTree;
-import org.sonar.batch.issue.DeprecatedViolations;
import org.sonar.batch.issue.ModuleIssues;
import org.sonar.batch.scan.measure.MeasureCache;
import java.io.IOException;
-import static com.google.common.collect.Lists.newArrayList;
import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -59,7 +54,6 @@ public class DefaultIndexTest {
public TemporaryFolder temp = new TemporaryFolder();
DefaultIndex index = null;
- DeprecatedViolations deprecatedViolations;
Rule rule;
RuleFinder ruleFinder;
Project project;
@@ -71,14 +65,13 @@ public class DefaultIndexTest {
@Before
public void createIndex() throws IOException {
- deprecatedViolations = mock(DeprecatedViolations.class);
MetricFinder metricFinder = mock(MetricFinder.class);
when(metricFinder.findByKey("ncloc")).thenReturn(CoreMetrics.NCLOC);
ruleFinder = mock(RuleFinder.class);
ProjectTree projectTree = mock(ProjectTree.class);
ResourceCache resourceCache = new ResourceCache();
- index = new DefaultIndex(resourceCache, null, null, null, projectTree, metricFinder, deprecatedViolations,
+ index = new DefaultIndex(resourceCache, null, null, null, projectTree, metricFinder,
mock(ResourceKeyMigration.class),
mock(MeasureCache.class));
@@ -179,85 +172,6 @@ public class DefaultIndexTest {
assertThat(index.getMeasures(dir, MeasuresFilters.metric("ncloc"))).isNull();
}
- /**
- * See http://jira.codehaus.org/browse/SONAR-2107
- */
- @Test
- public void shouldNotFailWhenSavingViolationOnNullRule() {
- File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
- Violation violation = Violation.create((Rule) null, file);
- index.addViolation(violation);
-
- assertThat(index.getViolations(file)).isEmpty();
- }
-
- /**
- * See https://jira.codehaus.org/browse/SONAR-3583
- */
- @Test
- public void should_ignore_violation_on_unknown_rules() {
- Rule ruleWithoutID = Rule.create("repoKey", "ruleKey", "Rule");
-
- File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
- Violation violation = Violation.create(ruleWithoutID, file);
- index.addViolation(violation);
-
- assertThat(index.getViolations(file)).isEmpty();
- }
-
- @Test
- public void should_get_violation() {
- Rule rule = Rule.create("repoKey", "ruleKey", "Rule");
- File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
- Violation violation = Violation.create(rule, file);
- when(deprecatedViolations.get(anyString())).thenReturn(newArrayList(violation));
-
- index.index(file);
- index.addViolation(violation);
-
- assertThat(index.getViolations(file)).hasSize(1);
- }
-
- @Test
- public void should_not_save_violation_if_resource_not_indexed() {
- Rule rule = Rule.create("repoKey", "ruleKey", "Rule");
- File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
- Violation violation = Violation.create(rule, file);
- when(deprecatedViolations.get(anyString())).thenReturn(newArrayList(violation));
-
- index.addViolation(violation);
-
- assertThat(index.getViolations(file)).hasSize(0);
- }
-
- @Test
- public void should_get_filtered_violation_with_off_switch_mode() {
- Rule rule = Rule.create("repoKey", "ruleKey", "Rule");
- File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
- Violation violation = Violation.create(rule, file).setSwitchedOff(true);
-
- when(deprecatedViolations.get(anyString())).thenReturn(newArrayList(violation));
-
- index.index(file);
- index.addViolation(violation);
-
- assertThat(index.getViolations(ViolationQuery.create().forResource(file).setSwitchMode(ViolationQuery.SwitchMode.OFF))).hasSize(1);
- }
-
- @Test
- public void should_get_filtered_violation_with_on_switch_mode() {
- Rule rule = Rule.create("repoKey", "ruleKey", "Rule");
- File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
- Violation violation = Violation.create(rule, file).setSwitchedOff(false);
-
- when(deprecatedViolations.get(anyString())).thenReturn(newArrayList(violation));
-
- index.index(file);
- index.addViolation(violation);
-
- assertThat(index.getViolations(ViolationQuery.create().forResource(file).setSwitchMode(ViolationQuery.SwitchMode.ON))).hasSize(1);
- }
-
@Test
public void shouldComputePathOfIndexedModules() {
assertThat(index.getResource(project).getPath()).isNull();
@@ -266,9 +180,4 @@ public class DefaultIndexTest {
assertThat(index.getResource(moduleB1).getPath()).isEqualTo("moduleB1");
}
- @Test(expected = IllegalArgumentException.class)
- public void testGetViolationsWithQueryWithNoResource() {
- index.getViolations(ViolationQuery.create());
- }
-
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
index 33da7d65bed..90eb8fa23ef 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
@@ -37,7 +37,6 @@ import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.security.ResourcePermissions;
import org.sonar.batch.ProjectTree;
-import org.sonar.batch.issue.DeprecatedViolations;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.component.ScanGraph;
@@ -223,7 +222,6 @@ public class ResourcePersisterTest extends AbstractDbUnitTestCase {
when(projectTree.getProjectDefinition(moduleB1)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB/moduleB1")));
DefaultIndex index = new DefaultIndex(resourceCache, null, null, null, projectTree, mock(MetricFinder.class),
- mock(DeprecatedViolations.class),
mock(ResourceKeyMigration.class),
mock(MeasureCache.class));
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedViolationsTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedViolationsTest.java
deleted file mode 100644
index b5c7862c740..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedViolationsTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.issue;
-
-import org.junit.Test;
-import org.sonar.api.issue.internal.DefaultIssue;
-import org.sonar.api.resources.Project;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.rules.RulePriority;
-import org.sonar.api.rules.Violation;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
-
-import java.util.Arrays;
-import java.util.List;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class DeprecatedViolationsTest {
-
- IssueCache issueCache = mock(IssueCache.class);
- RuleFinder ruleFinder = mock(RuleFinder.class);
- ResourceCache resourceCache = mock(ResourceCache.class);
- DeprecatedViolations deprecatedViolations = new DeprecatedViolations(issueCache, ruleFinder, resourceCache);
-
- @Test
- public void test_toViolation() throws Exception {
- RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles");
- when(ruleFinder.findByKey(ruleKey)).thenReturn(new Rule("squid", "AvoidCycles"));
- when(resourceCache.get("org.apache:struts")).thenReturn(new BatchResource(1, new Project("org.apache:struts"), null));
-
- DefaultIssue issue = newIssue(ruleKey);
-
- Violation violation = deprecatedViolations.toViolation(issue);
- assertThat(violation.getLineId()).isEqualTo(42);
- assertThat(violation.getSeverity()).isEqualTo(RulePriority.BLOCKER);
- assertThat(violation.isManual()).isTrue();
- assertThat(violation.getRule().getRepositoryKey()).isEqualTo("squid");
- assertThat(violation.getRule().getKey()).isEqualTo("AvoidCycles");
- assertThat(violation.getResource()).isNotNull();
- assertThat(violation.isSwitchedOff()).isFalse();
- }
-
- private DefaultIssue newIssue(RuleKey ruleKey) {
- DefaultIssue issue = new DefaultIssue();
- issue.setKey("ABCDE");
- issue.setRuleKey(ruleKey);
- issue.setComponentKey("org.apache:struts");
- issue.setLine(42);
- issue.setEffortToFix(3.14);
- issue.setReporter("leon");
- issue.setSeverity(Severity.BLOCKER);
- return issue;
- }
-
- @Test
- public void test_get() throws Exception {
- RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles");
- when(ruleFinder.findByKey(ruleKey)).thenReturn(new Rule("squid", "AvoidCycles"));
- when(resourceCache.get("org.apache:struts")).thenReturn(new BatchResource(1, new Project("org.apache:struts"), null));
- when(issueCache.byComponent("org.apache:struts")).thenReturn(Arrays.asList(newIssue(ruleKey)));
-
- List<Violation> violations = deprecatedViolations.get("org.apache:struts");
-
- assertThat(violations).hasSize(1);
- }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/IssueFiltersTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/IssueFiltersTest.java
index 2b87b8b6c4a..d487aeadd6b 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/IssueFiltersTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/IssueFiltersTest.java
@@ -21,10 +21,7 @@ package org.sonar.batch.issue;
import org.junit.Test;
import org.sonar.api.issue.Issue;
-import org.sonar.api.issue.batch.IssueFilter;
import org.sonar.api.issue.internal.DefaultIssue;
-import org.sonar.api.rules.Violation;
-import org.sonar.batch.ViolationFilters;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Matchers.any;
@@ -33,9 +30,6 @@ import static org.mockito.Mockito.when;
public class IssueFiltersTest {
- DeprecatedViolations deprecatedViolations = mock(DeprecatedViolations.class);
- ViolationFilters deprecatedFilters = mock(ViolationFilters.class);
-
@Test
public void accept_when_filter_chain_is_empty() throws Exception {
org.sonar.api.issue.IssueFilter ok = mock(org.sonar.api.issue.IssueFilter.class);
@@ -44,30 +38,19 @@ public class IssueFiltersTest {
org.sonar.api.issue.IssueFilter ko = mock(org.sonar.api.issue.IssueFilter.class);
when(ko.accept(any(Issue.class))).thenReturn(false);
- when(deprecatedFilters.isEmpty()).thenReturn(true);
- IssueFilters filters = new IssueFilters(deprecatedFilters, deprecatedViolations, new org.sonar.api.issue.IssueFilter[]{ok, ko});
- assertThat(filters.accept(new DefaultIssue(), null)).isFalse();
+ IssueFilters filters = new IssueFilters(new org.sonar.api.issue.IssueFilter[] {ok, ko});
+ assertThat(filters.accept(new DefaultIssue())).isFalse();
- filters = new IssueFilters(deprecatedFilters, deprecatedViolations, new org.sonar.api.issue.IssueFilter[]{ok});
- assertThat(filters.accept(new DefaultIssue(), null)).isTrue();
+ filters = new IssueFilters(new org.sonar.api.issue.IssueFilter[] {ok});
+ assertThat(filters.accept(new DefaultIssue())).isTrue();
- filters = new IssueFilters(deprecatedFilters, deprecatedViolations, new org.sonar.api.issue.IssueFilter[]{ko});
- assertThat(filters.accept(new DefaultIssue(), null)).isFalse();
+ filters = new IssueFilters(new org.sonar.api.issue.IssueFilter[] {ko});
+ assertThat(filters.accept(new DefaultIssue())).isFalse();
}
@Test
public void should_always_accept_if_no_filters() {
- when(deprecatedFilters.isEmpty()).thenReturn(true);
- IssueFilters filters = new IssueFilters(deprecatedFilters, deprecatedViolations);
- assertThat(filters.accept(new DefaultIssue(), null)).isTrue();
- }
-
- @Test
- public void should_check_deprecated_violation_filters() throws Exception {
- when(deprecatedFilters.isEmpty()).thenReturn(false);
- when(deprecatedFilters.isIgnored(any(Violation.class))).thenReturn(true);
- IssueFilters filters = new IssueFilters(deprecatedFilters, deprecatedViolations, new org.sonar.api.issue.IssueFilter[0]);
- assertThat(filters.accept(new DefaultIssue(), null)).isFalse();
-
+ IssueFilters filters = new IssueFilters();
+ assertThat(filters.accept(new DefaultIssue())).isTrue();
}
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/ModuleIssuesTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/ModuleIssuesTest.java
index ef507f38001..1516c7a8ddb 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/ModuleIssuesTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/ModuleIssuesTest.java
@@ -46,7 +46,6 @@ import java.util.Date;
import static org.fest.assertions.Assertions.assertThat;
import static org.fest.assertions.Fail.fail;
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
@@ -147,7 +146,7 @@ public class ModuleIssuesTest {
.setKey("ABCDE")
.setRuleKey(SQUID_RULE_KEY)
.setSeverity(Severity.CRITICAL);
- when(filters.accept(issue, null)).thenReturn(true);
+ when(filters.accept(issue)).thenReturn(true);
boolean added = moduleIssues.initAndAddIssue(issue);
@@ -168,7 +167,7 @@ public class ModuleIssuesTest {
when(project.getAnalysisDate()).thenReturn(analysisDate);
DefaultIssue issue = new DefaultIssue().setRuleKey(SQUID_RULE_KEY).setSeverity(null);
- when(filters.accept(issue, null)).thenReturn(true);
+ when(filters.accept(issue)).thenReturn(true);
moduleIssues.initAndAddIssue(issue);
ArgumentCaptor<DefaultIssue> argument = ArgumentCaptor.forClass(DefaultIssue.class);
@@ -191,7 +190,7 @@ public class ModuleIssuesTest {
.setRuleKey(SQUID_RULE_KEY)
.setSeverity(Severity.CRITICAL)
.setMessage("");
- when(filters.accept(issue, null)).thenReturn(true);
+ when(filters.accept(issue)).thenReturn(true);
boolean added = moduleIssues.initAndAddIssue(issue);
@@ -214,7 +213,7 @@ public class ModuleIssuesTest {
violation.setSeverity(RulePriority.CRITICAL);
violation.setMessage("the message");
- when(filters.accept(any(DefaultIssue.class), eq(violation))).thenReturn(true);
+ when(filters.accept(any(DefaultIssue.class))).thenReturn(true);
boolean added = moduleIssues.initAndAddViolation(violation);
assertThat(added).isTrue();
@@ -242,7 +241,7 @@ public class ModuleIssuesTest {
.setRuleKey(SQUID_RULE_KEY)
.setSeverity(Severity.CRITICAL);
- when(filters.accept(issue, null)).thenReturn(false);
+ when(filters.accept(issue)).thenReturn(false);
boolean added = moduleIssues.initAndAddIssue(issue);
@@ -268,7 +267,7 @@ public class ModuleIssuesTest {
.setSeverity(Severity.CRITICAL)
.setEffortToFix(2d);
- when(filters.accept(issue, null)).thenReturn(true);
+ when(filters.accept(issue)).thenReturn(true);
moduleIssues.initAndAddIssue(issue);
ArgumentCaptor<DefaultIssue> argument = ArgumentCaptor.forClass(DefaultIssue.class);
@@ -294,7 +293,7 @@ public class ModuleIssuesTest {
.setSeverity(Severity.CRITICAL)
.setEffortToFix(2d);
- when(filters.accept(issue, null)).thenReturn(true);
+ when(filters.accept(issue)).thenReturn(true);
moduleIssues.initAndAddIssue(issue);
ArgumentCaptor<DefaultIssue> argument = ArgumentCaptor.forClass(DefaultIssue.class);
@@ -320,7 +319,7 @@ public class ModuleIssuesTest {
.setSeverity(Severity.CRITICAL)
.setEffortToFix(null);
- when(filters.accept(issue, null)).thenReturn(true);
+ when(filters.accept(issue)).thenReturn(true);
moduleIssues.initAndAddIssue(issue);
ArgumentCaptor<DefaultIssue> argument = ArgumentCaptor.forClass(DefaultIssue.class);
@@ -343,7 +342,7 @@ public class ModuleIssuesTest {
.setSeverity(Severity.CRITICAL)
.setEffortToFix(2d);
- when(filters.accept(issue, null)).thenReturn(true);
+ when(filters.accept(issue)).thenReturn(true);
try {
moduleIssues.initAndAddIssue(issue);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java
index be4b1e0cd70..0e2bd8b61b0 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java
@@ -26,7 +26,6 @@ import org.sonar.api.measures.Metric;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Violation;
-import org.sonar.api.violations.ViolationQuery;
import java.util.Collection;
import java.util.Date;
@@ -102,27 +101,6 @@ public interface DecoratorContext {
// RULES
/**
- * Returns the violations that match the {@link ViolationQuery} parameters.
- *
- * @since 2.8
- * @param violationQuery
- * the request parameters specified as a {@link ViolationQuery}
- * @return the list of violations that match those parameters
- * @deprecated in 3.6, replaced by {@link org.sonar.api.issue.Issuable}
- */
- @Deprecated
- List<Violation> getViolations(ViolationQuery violationQuery);
-
- /**
- * Returns all the active (= non switched-off) violations found on the current resource.
- *
- * @return the list of violations
- * @deprecated in 3.6, replaced by {@link org.sonar.api.issue.Issuable}
- */
- @Deprecated
- List<Violation> getViolations();
-
- /**
* Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.
*
* @since 2.5
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
index db50719f48f..f21b83bab5f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
@@ -27,7 +27,6 @@ import org.sonar.api.resources.Project;
import org.sonar.api.resources.ProjectLink;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Violation;
-import org.sonar.api.violations.ViolationQuery;
import org.sonar.graph.DirectedGraphAccessor;
import javax.annotation.CheckForNull;
@@ -124,32 +123,6 @@ public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Depe
public abstract <M> M getMeasures(Resource resource, MeasuresFilter<M> filter);
/**
- * Returns the violations that match the {@link ViolationQuery} parameters.
- *
- * @since 2.8
- * @param violationQuery
- * the request parameters specified as a {@link ViolationQuery}
- * @return the list of violations that match those parameters
- * @deprecated in 3.6
- */
- @Deprecated
- public abstract List<Violation> getViolations(ViolationQuery violationQuery);
-
- /**
- * Returns all the active (= non switched-off) violations found on the given resource. Equivalent to
- * {@link #getViolations(ViolationQuery)} called with <code>ViolationQuery.create().forResource(resource).ignoreSwitchedOff(true)</code>
- * as a parameter.
- *
- * @since 2.7
- * @return the list of violations
- * @deprecated in 3.6
- */
- @Deprecated
- public final List<Violation> getViolations(Resource resource) {
- return getViolations(ViolationQuery.create().forResource(resource));
- }
-
- /**
* @since 2.5
* @deprecated in 3.6
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java
index 9f35998b40e..3d963373c22 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java
@@ -49,7 +49,7 @@ public class Violation {
/**
* Creates of a violation from a rule. Will need to define the resource later on
*
- * @deprecated since 2.3. Use the factory method create()
+ * @deprecated since 2.3. Use the factory method {@link #create(ActiveRule, Resource)}
*/
@Deprecated
public Violation(Rule rule) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ViolationFilter.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ViolationFilter.java
deleted file mode 100644
index 5e40e540934..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ViolationFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.rules;
-
-import org.sonar.api.BatchExtension;
-import org.sonar.api.batch.DecoratorBarriers;
-import org.sonar.api.batch.DependedUpon;
-
-/**
- * Filter violations to save. For example, ignore a violation if it occurs on a line of code commented with //NOSONAR
- *
- * @since 1.12
- * @deprecated in 3.6. Replaced by {@link org.sonar.api.issue.IssueFilter}.
- */
-@DependedUpon(value = DecoratorBarriers.START_VIOLATIONS_GENERATION)
-@Deprecated
-public interface ViolationFilter extends BatchExtension {
-
- /**
- * Return true if the violation must be ignored, else it's saved into database.
- */
- boolean isIgnored(Violation violation);
-
-}