]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6014 Drop deprecated violations
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 7 Jan 2015 21:01:59 +0000 (22:01 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Wed, 7 Jan 2015 21:07:30 +0000 (22:07 +0100)
19 files changed:
sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java
sonar-batch/src/main/java/org/sonar/batch/ViolationFilters.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedViolations.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java
sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java
sonar-batch/src/test/java/org/sonar/batch/ViolationFiltersTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedViolationsTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/issue/IssueFiltersTest.java
sonar-batch/src/test/java/org/sonar/batch/issue/ModuleIssuesTest.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java
sonar-plugin-api/src/main/java/org/sonar/api/rules/ViolationFilter.java [deleted file]

index fe7cdd7f57cb1911c0ae113016bc7a698d72d169..1fa2a1b6450e881ff3cf6895848609e45f742147 100644 (file)
@@ -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 (file)
index 2e24b34..0000000
+++ /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;
-  }
-}
index 59dab76609b6b04e857fe13833cac1f1d7f88a23..d0d99bc4beba32d3c0892509c27fcfeee425e003 100644 (file)
@@ -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 (file)
index 13e03a3..0000000
+++ /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;
-  }
-}
index a6987f2368ebf05a7a35f210662e5b7d8c35ee2b..469a65cb90980786a8d21ca15036c89be39ece7d 100644 (file)
@@ -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;
index 5997f636ba291648c536dd63cb6b758096a1b2cc..93dc8a3c4b8fd4b88b3385e1c2024eb748119979 100644 (file)
@@ -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;
     }
index c022067683e02c648bc9e90bfaf6214e96ebe704..e219cae92ddf474bc2b32f87737c715b9a6f2ee1 100644 (file)
@@ -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,
index 5ae7992ac4dc8c17e34051c16a34658919f669c3..7fc792ac3eacf4b103ac86f39472a12edc7b5306 100644 (file)
@@ -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);
index 58eaf6d5fa2f04642bca85c7f2e85848db26d4d4..cb70fa25b6ae94b5e56060cb4141d9762928ab74 100644 (file)
@@ -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 (file)
index c1449cf..0000000
+++ /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;
-    }
-  }
-}
index 42ca92d27b20770f065e67451e6ede38e3941af1..b37474770b9a0f330aada9818ff114834de51288 100644 (file)
@@ -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());
-  }
-
 }
index 33da7d65bed3f1ea45bc41bcba2ed7480c559fd3..90eb8fa23ef65745874ee81f4298b73c9d6f20d4 100644 (file)
@@ -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 (file)
index b5c7862..0000000
+++ /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);
-  }
-}
index 2b87b8b6c4ae88937d9c492f8d7dc4b28450da31..d487aeadd6bc58aa0117fcb6a53ada50110cf14d 100644 (file)
@@ -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();
   }
 }
index ef507f38001a98a0b0b1f8c9848b0f57d60a4c45..1516c7a8ddb1bb342938d3f3d0e1181c6167b99a 100644 (file)
@@ -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);
index be4b1e0cd704d52a764c27b0eed17f5d3a08b8f1..0e2bd8b61b0e6fd8b2f3b3731cb5260566c0f882 100644 (file)
@@ -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;
@@ -101,27 +100,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.
    * 
index db50719f48f567b98bfdf79fa7e97877010412e2..f21b83bab5fb1788777037829beb5d9c87e49012 100644 (file)
@@ -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;
@@ -123,32 +122,6 @@ public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Depe
   @CheckForNull
   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
index 9f35998b40ed2cbf76aa65462f52b7f129b0a1fc..3d963373c22eef623753151a8ef056b0c7a42217 100644 (file)
@@ -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 (file)
index 5e40e54..0000000
+++ /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);
-
-}