From: Julien Lancelot Date: Wed, 17 Apr 2013 09:06:46 +0000 (+0200) Subject: Fix issue when violations are ignored X-Git-Tag: 3.6~674 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=12b3f014ce875093ed513900e7f7bc4c9997c5cc;p=sonarqube.git Fix issue when violations are ignored --- 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 ea0746d6b47..8f37854061f 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 @@ -367,14 +367,15 @@ public class DefaultIndex extends SonarIndex { } violation.setResource(bucket.getResource()); - addViolation(violation, bucket, force); - deprecatedViolations.add(violation); + if (addViolation(violation, bucket, force)){ + deprecatedViolations.add(violation); + } } - private void addViolation(Violation violation, Bucket bucket, boolean force) { + private boolean addViolation(Violation violation, Bucket bucket, boolean force) { boolean isIgnored = !force && violationFilters != null && violationFilters.isIgnored(violation); if (isIgnored) { - return; + return false; } // TODO this code is not the responsibility of this index. It should be moved somewhere else. @@ -386,13 +387,15 @@ public class DefaultIndex extends SonarIndex { violation.setSeverity(violation.getRule().getSeverity()); } else { LoggerFactory.getLogger(getClass()).debug("Rule is not activated, ignoring violation {}", violation); - return; + return false; } } bucket.addViolation(violation); + return true; } + // // //