aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-04-23 16:16:46 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-04-23 18:55:28 +0200
commitc4c1dca2f2b6d264b4d57b58f5e6802faa599a20 (patch)
tree896bb16a8b639b729a6a70cbd55b04102dd20549
parentcb4fd33308f357326b44a357f6949360018cf480 (diff)
downloadsonarqube-c4c1dca2f2b6d264b4d57b58f5e6802faa599a20.tar.gz
sonarqube-c4c1dca2f2b6d264b4d57b58f5e6802faa599a20.zip
SONAR-3755 default issue resolution is OPEN
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTracking.java7
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java10
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/IssueTrackingDecoratorTest.java2
3 files changed, 11 insertions, 8 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTracking.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTracking.java
index dcfe7ba75e8..458dd20a0c8 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTracking.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTracking.java
@@ -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);
}
}
};
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
index afe5e149c4c..e4ae221f2eb 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
@@ -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);
}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/IssueTrackingDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/IssueTrackingDecoratorTest.java
index cdbb2f3b807..9e9f775000a 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/IssueTrackingDecoratorTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/IssueTrackingDecoratorTest.java
@@ -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);
}