aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-02-07 15:48:48 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-02-07 15:48:48 +0100
commitc07d90eea0a359fc37a7f49ab6ad6ea0a13d18b8 (patch)
tree347e9e642dc161e8c0e2efb3004b28557c0f0440
parentebee9e8be46ed85227fb4ded4afb34f12d6d465f (diff)
downloadsonarqube-c07d90eea0a359fc37a7f49ab6ad6ea0a13d18b8.tar.gz
sonarqube-c07d90eea0a359fc37a7f49ab6ad6ea0a13d18b8.zip
Prevent from adding violations to resources with scope<file
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java3
1 files changed, 3 insertions, 0 deletions
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 296571bc282..09529e5c1b3 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
@@ -294,7 +294,10 @@ public final class DefaultIndex extends SonarIndex {
Resource resource = violation.getResource();
if (resource == null) {
violation.setResource(currentProject);
+ } else if (!Scopes.isHigherThanOrEquals(resource, Scopes.FILE)){
+ throw new IllegalArgumentException("Violations are only supported on files, directories and project");
}
+
Bucket bucket = checkIndexed(resource);
if (bucket != null && !bucket.isExcluded()) {
boolean isIgnored = !force && violationFilters != null && violationFilters.isIgnored(violation);