aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-01-21 14:32:24 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-01-21 14:32:24 +0100
commit08cb4444e0341652a4bf34133485ac405fb1ec50 (patch)
treebfefc7453a2ad73be491cdeaa10c3b1bd45bd060 /plugins
parent1ab2475003835b71ff44b3652691c538059db699 (diff)
downloadsonarqube-08cb4444e0341652a4bf34133485ac405fb1ec50.tar.gz
sonarqube-08cb4444e0341652a4bf34133485ac405fb1ec50.zip
SONAR-2127 API: do not automatically create hierarchy of resource tree
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java6
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java4
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java5
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewViolationsDecoratorTest.java3
4 files changed, 13 insertions, 5 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java
index 1f7d5e5982f..da1415f6fde 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java
@@ -20,6 +20,7 @@
package org.sonar.plugins.core.timemachine;
import com.google.common.collect.*;
+import org.apache.commons.lang.StringUtils;
import org.sonar.api.batch.Decorator;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.batch.DependedUpon;
@@ -28,6 +29,7 @@ import org.sonar.api.measures.*;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.resources.ResourceUtils;
+import org.sonar.api.resources.Scopes;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RulePriority;
import org.sonar.api.rules.Violation;
@@ -72,7 +74,9 @@ public class NewViolationsDecorator implements Decorator {
}
private boolean shouldDecorateResource(Resource resource, DecoratorContext context) {
- return !ResourceUtils.isUnitTestClass(resource) && context.getMeasure(CoreMetrics.NEW_VIOLATIONS) == null;
+ return
+ (StringUtils.equals(Scopes.PROJECT, resource.getScope()) || StringUtils.equals(Scopes.DIRECTORY, resource.getScope()) || StringUtils.equals(Scopes.FILE, resource.getScope()))
+ && !ResourceUtils.isUnitTestClass(resource) && context.getMeasure(CoreMetrics.NEW_VIOLATIONS) == null;
}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java
index 836d23613e8..310b19f04ef 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java
@@ -22,6 +22,7 @@ package org.sonar.plugins.core.timemachine;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.sonar.api.batch.*;
import org.sonar.api.measures.Measure;
@@ -30,6 +31,7 @@ import org.sonar.api.measures.MetricFinder;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.resources.ResourceUtils;
+import org.sonar.api.resources.Scopes;
import org.sonar.batch.components.TimeMachineConfiguration;
import java.util.List;
@@ -114,6 +116,6 @@ public class TendencyDecorator implements Decorator {
}
private boolean shouldDecorateResource(Resource resource) {
- return ResourceUtils.isSet(resource) || ResourceUtils.isSpace(resource);
+ return StringUtils.equals(Scopes.PROJECT, resource.getScope()) || StringUtils.equals(Scopes.DIRECTORY, resource.getScope());
}
}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java
index 4e6ddddf74e..68e686f61c8 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java
@@ -20,13 +20,14 @@
package org.sonar.plugins.core.timemachine;
import com.google.common.collect.Maps;
+import org.apache.commons.lang.StringUtils;
import org.sonar.api.batch.*;
import org.sonar.api.database.model.MeasureModel;
import org.sonar.api.measures.*;
import org.sonar.api.qualitymodel.Characteristic;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.ResourceUtils;
+import org.sonar.api.resources.Scopes;
import org.sonar.api.rules.RulePriority;
import org.sonar.batch.components.PastMeasuresLoader;
import org.sonar.batch.components.PastSnapshot;
@@ -73,7 +74,7 @@ public class VariationDecorator implements Decorator {
static boolean shouldCalculateVariations(Resource resource) {
// measures on files are currently purged, so past measures are not available on files
- return !ResourceUtils.isEntity(resource);
+ return StringUtils.equals(Scopes.PROJECT, resource.getScope()) || StringUtils.equals(Scopes.DIRECTORY, resource.getScope());
}
private void calculateVariation(Resource resource, DecoratorContext context, PastSnapshot pastSnapshot) {
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewViolationsDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewViolationsDecoratorTest.java
index 8170bb55dfe..22574d4a1b7 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewViolationsDecoratorTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewViolationsDecoratorTest.java
@@ -31,6 +31,7 @@ import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
import org.sonar.api.measures.RuleMeasure;
+import org.sonar.api.resources.File;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Rule;
@@ -79,7 +80,7 @@ public class NewViolationsDecoratorTest {
when(timeMachineConfiguration.getProjectPastSnapshots()).thenReturn(Arrays.asList(pastSnapshot, pastSnapshot2));
context = mock(DecoratorContext.class);
- resource = mock(Resource.class);
+ resource = new File("com/foo/bar");
when(context.getResource()).thenReturn(resource);
decorator = new NewViolationsDecorator(timeMachineConfiguration);