]> source.dussan.org Git - sonarqube.git/commitdiff
Prevent from adding violations to resources with scope<file
authorsimonbrandhof <simon.brandhof@gmail.com>
Mon, 7 Feb 2011 14:48:48 +0000 (15:48 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Mon, 7 Feb 2011 14:48:48 +0000 (15:48 +0100)
sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java

index 296571bc28276e6d63feb1ff24e3cd32592ce2ae..09529e5c1b3d4debf702b261fb06045c970523fb 100644 (file)
@@ -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);