aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Hartmann <hartmann.eric@gmail.com>2012-03-08 13:52:04 +0100
committerEric Hartmann <hartmann.eric@gmail.com>2012-03-08 13:52:04 +0100
commit830226e10d2690361fb14971261f140146077a4b (patch)
treecba7b34cdb7abb4469f4bd77811f5b7bdffdb7d4
parent53967cc3a94a50db2671d7522b3e5e2b1e63764b (diff)
parentd660da5fd487949dae1954f3ef76a1d310e0e8a8 (diff)
downloadsonarqube-830226e10d2690361fb14971261f140146077a4b.tar.gz
sonarqube-830226e10d2690361fb14971261f140146077a4b.zip
Merge branch 'release-2.14' of github.com:SonarSource/sonar into release-2.14
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecorator.java6
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecoratorTest.java7
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java6
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java14
4 files changed, 22 insertions, 11 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecorator.java
index 7f350b02330..9fc97e67ba8 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecorator.java
@@ -32,6 +32,7 @@ import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.resources.ResourceUtils;
import org.sonar.api.rules.Violation;
+import org.sonar.api.violations.ViolationQuery;
import org.sonar.batch.index.ResourcePersister;
import org.sonar.core.NotDryRun;
import org.sonar.core.review.ReviewDao;
@@ -66,10 +67,11 @@ public class ReviewWorkflowDecorator implements Decorator {
Collection<ReviewDto> openReviews = reviewDao.selectOpenByResourceId(snapshot.getResourceId());
Set<ReviewDto> updated = Sets.newHashSet();
if (!openReviews.isEmpty()) {
- closeResolvedStandardViolations(openReviews, context.getViolations(), context.getProject(), resource, updated);
+ List<Violation> violations = context.getViolations(ViolationQuery.create().forResource(resource).setSwitchMode(ViolationQuery.SwitchMode.BOTH));
+ closeResolvedStandardViolations(openReviews, violations, context.getProject(), resource, updated);
closeResolvedManualViolations(openReviews, context.getProject(), resource, updated);
reopenUnresolvedViolations(openReviews, context.getProject(), resource, updated);
- updateReviewInformation(openReviews, context.getViolations(), updated);
+ updateReviewInformation(openReviews, violations, updated);
}
if (ResourceUtils.isRootProject(resource)) {
closeReviewsOnDeletedResources((Project) resource, snapshot.getResourceId(), snapshot.getId(), updated);
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecoratorTest.java
index 681e532a37c..4fb70af490a 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecoratorTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecoratorTest.java
@@ -30,6 +30,7 @@ import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.Violation;
+import org.sonar.api.violations.ViolationQuery;
import org.sonar.batch.index.ResourcePersister;
import org.sonar.core.review.ReviewDao;
import org.sonar.core.review.ReviewDto;
@@ -75,7 +76,7 @@ public class ReviewWorkflowDecoratorTest extends AbstractDbUnitTestCase {
public void shouldCloseReviewsOnResolvedViolations() {
setupData("shouldCloseReviewsOnResolvedViolations");
DecoratorContext context = mock(DecoratorContext.class);
- when(context.getViolations()).thenReturn(Collections.<Violation>emptyList());
+ when(context.getViolations(any(ViolationQuery.class))).thenReturn(Collections.<Violation>emptyList());
Resource resource = new JavaFile("org.foo.Bar");
decorator.decorate(resource, context);
@@ -88,7 +89,7 @@ public class ReviewWorkflowDecoratorTest extends AbstractDbUnitTestCase {
public void shouldCloseResolvedManualViolations() {
setupData("shouldCloseResolvedManualViolations");
DecoratorContext context = mock(DecoratorContext.class);
- when(context.getViolations()).thenReturn(Collections.<Violation>emptyList());
+ when(context.getViolations(any(ViolationQuery.class))).thenReturn(Collections.<Violation>emptyList());
Resource resource = new JavaFile("org.foo.Bar");
decorator.decorate(resource, context);
@@ -103,7 +104,7 @@ public class ReviewWorkflowDecoratorTest extends AbstractDbUnitTestCase {
DecoratorContext context = mock(DecoratorContext.class);
Violation violation = new Violation(new Rule());
violation.setPermanentId(1000);
- when(context.getViolations()).thenReturn(Lists.newArrayList(violation));
+ when(context.getViolations(any(ViolationQuery.class))).thenReturn(Lists.newArrayList(violation));
Resource resource = new JavaFile("org.foo.Bar");
decorator.decorate(resource, context);
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java
index 259993eda33..fc800738a86 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java
@@ -24,6 +24,7 @@ import com.google.common.collect.Sets;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
+import org.sonar.api.measures.PersistenceMode;
import org.sonar.api.resources.Resource;
import java.util.Collections;
@@ -58,7 +59,10 @@ public class DuplicationsData {
context.saveMeasure(resource, CoreMetrics.DUPLICATED_FILES, 1d);
context.saveMeasure(resource, CoreMetrics.DUPLICATED_LINES, (double) duplicatedLines.size());
context.saveMeasure(resource, CoreMetrics.DUPLICATED_BLOCKS, duplicatedBlocks);
- context.saveMeasure(resource, new Measure(CoreMetrics.DUPLICATIONS_DATA, getDuplicationXMLData()));
+
+ Measure data = new Measure(CoreMetrics.DUPLICATIONS_DATA, getDuplicationXMLData())
+ .setPersistenceMode(PersistenceMode.DATABASE);
+ context.saveMeasure(resource, data);
}
private String getDuplicationXMLData() {
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
index 961b085bf4f..460fdd10fa0 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
@@ -27,6 +27,7 @@ import org.sonar.api.batch.SensorContext;
import org.sonar.api.database.model.ResourceModel;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
+import org.sonar.api.measures.PersistenceMode;
import org.sonar.api.resources.*;
import org.sonar.api.utils.SonarException;
import org.sonar.duplications.block.Block;
@@ -79,10 +80,10 @@ public class SonarEngine extends CpdEngine {
static String getFullKey(Project project, Resource resource) {
return new StringBuilder(ResourceModel.KEY_SIZE)
- .append(project.getKey())
- .append(':')
- .append(resource.getKey())
- .toString();
+ .append(project.getKey())
+ .append(':')
+ .append(resource.getKey())
+ .toString();
}
@Override
@@ -195,7 +196,10 @@ public class SonarEngine extends CpdEngine {
context.saveMeasure(resource, CoreMetrics.DUPLICATED_FILES, 1.0);
context.saveMeasure(resource, CoreMetrics.DUPLICATED_LINES, (double) duplicatedLines.size());
context.saveMeasure(resource, CoreMetrics.DUPLICATED_BLOCKS, duplicatedBlocks);
- context.saveMeasure(resource, new Measure(CoreMetrics.DUPLICATIONS_DATA, toXml(duplications)));
+
+ Measure data = new Measure(CoreMetrics.DUPLICATIONS_DATA, toXml(duplications))
+ .setPersistenceMode(PersistenceMode.DATABASE);
+ context.saveMeasure(resource, data);
}
private static String toXml(Iterable<CloneGroup> duplications) {