]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3755 default issue resolution is OPEN
authorSimon Brandhof <simon.brandhof@gmail.com>
Tue, 23 Apr 2013 14:16:46 +0000 (16:16 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Tue, 23 Apr 2013 16:55:28 +0000 (18:55 +0200)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTracking.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/IssueTrackingDecoratorTest.java

index dcfe7ba75e8e6dd7d3db0e884d5fd40f6edd3d9e..458dd20a0c809f0dda574f68e381d2f611a5d2c9 100644 (file)
@@ -23,8 +23,6 @@ package org.sonar.plugins.core.issue;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Objects;
 import com.google.common.collect.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.sonar.api.BatchExtension;
 import org.sonar.api.batch.SonarIndex;
 import org.sonar.api.resources.Project;
@@ -38,20 +36,17 @@ import org.sonar.plugins.core.timemachine.ViolationTrackingBlocksRecognizer;
 import org.sonar.plugins.core.timemachine.tracking.*;
 
 import javax.annotation.Nullable;
-
 import java.util.*;
 
 public class IssueTracking implements BatchExtension {
 
-  private static final Logger LOG = LoggerFactory.getLogger(IssueTracking.class);
-
   private static final Comparator<LinePair> LINE_PAIR_COMPARATOR = new Comparator<LinePair>() {
     public int compare(LinePair o1, LinePair o2) {
       int weightDiff = o2.weight - o1.weight;
       if (weightDiff != 0) {
         return weightDiff;
       } else {
-        return Math.abs(o1.lineA -o1.lineB) - Math.abs(o2.lineA - o2.lineB);
+        return Math.abs(o1.lineA - o1.lineB) - Math.abs(o2.lineA - o2.lineB);
       }
     }
   };
index afe5e149c4c82509b04118cfd06e48660afc6557..e4ae221f2eb38730139d38c1dd5f1e590dd2e9ba 100644 (file)
@@ -60,14 +60,22 @@ public class IssueTrackingDecorator implements Decorator {
 
   public void decorate(Resource resource, DecoratorContext context) {
     if (isComponentSupported(resource)) {
+      // all the issues created by rule engines during this module scan
       Collection<DefaultIssue> newIssues = new ArrayList(scanIssues.issues(resource.getEffectiveKey()));
+
+      // all the issues that are open in db before starting this module scan
       Collection<IssueDto> openIssues = initialOpenIssuesStack.selectAndRemove(resource.getId());
+
       tracking.track(resource, openIssues, newIssues);
+
       updateIssues(newIssues);
 
       Set<String> issueKeys = Sets.newHashSet(Collections2.transform(newIssues, new IssueToKeyFunction()));
       for (IssueDto openIssue : openIssues) {
+        // not in newIssues
         addManualIssuesAndCloseResolvedOnes(openIssue);
+
+
         closeResolvedStandardIssues(openIssue, issueKeys);
         keepFalsePositiveIssues(openIssue);
         reopenUnresolvedIssues(openIssue);
@@ -142,7 +150,7 @@ public class IssueTrackingDecorator implements Decorator {
   private void reopenAndSave(IssueDto openIssue) {
     DefaultIssue issue = openIssue.toDefaultIssue();
     issue.setStatus(Issue.STATUS_REOPENED);
-    issue.setResolution(null);
+    issue.setResolution(Issue.RESOLUTION_OPEN);
     issue.setUpdatedAt(getLoadedDate());
     scanIssues.addOrUpdate(issue);
   }
index cdbb2f3b807eead6cd3d8315cf9cea1e5abdbfc2..9e9f775000af67d2fef49c2651add7b4343becce 100644 (file)
@@ -119,7 +119,7 @@ public class IssueTrackingDecoratorTest extends AbstractDaoTestCase {
     // First call is done when updating issues after calling issue tracking and we don't care
     DefaultIssue defaultIssue = capturedDefaultIssues.get(1);
     assertThat(defaultIssue.status()).isEqualTo(Issue.STATUS_REOPENED);
-    assertThat(defaultIssue.resolution()).isNull();
+    assertThat(defaultIssue.resolution()).isEqualTo(Issue.RESOLUTION_OPEN);
     assertThat(defaultIssue.updatedAt()).isEqualTo(loadedDate);
   }