aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorFreddy Mallet <freddy.mallet@gmail.com>2011-04-29 11:14:42 +0200
committerFreddy Mallet <freddy.mallet@gmail.com>2011-04-29 11:14:42 +0200
commit71e1d5887f78d55989ec3383d9138a870c24c9ca (patch)
treeba3348ae5272bebaeeea2f2b139697ec2a1f8e86 /plugins
parent086a9db53ed24304cb2652032ebc7305693f3625 (diff)
downloadsonarqube-71e1d5887f78d55989ec3383d9138a870c24c9ca.tar.gz
sonarqube-71e1d5887f78d55989ec3383d9138a870c24c9ca.zip
Slightly improve fix bug of violation tracking when past violation has no checksum.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java2
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest.java22
2 files changed, 15 insertions, 9 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java
index 4ad673c0bc5..ece114c8144 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java
@@ -161,7 +161,7 @@ public class ViolationPersisterDecorator implements Decorator {
}
private boolean isSameLine(Violation newViolation, RuleFailureModel pastViolation) {
- return pastViolation.getLine() == newViolation.getLineId();
+ return pastViolation.getLine() == newViolation.getLineId(); //When lines are null, we also return true
}
private boolean isSameMessage(Violation newViolation, RuleFailureModel pastViolation) {
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest.java
index 51c83a460eb..dda507ee931 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest.java
@@ -19,18 +19,22 @@
*/
package org.sonar.plugins.core.timemachine;
-import com.google.common.collect.Lists;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+import java.util.Map;
+
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.database.model.RuleFailureModel;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.Violation;
-import java.util.List;
-import java.util.Map;
-
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertThat;
+import com.google.common.collect.Lists;
public class ViolationPersisterDecoratorTest {
@@ -90,7 +94,7 @@ public class ViolationPersisterDecoratorTest {
@Test
public void pastMeasureHasNoChecksum() {
- Violation newViolation = newViolation("message", 1, 50, "checksum1");
+ Violation newViolation = newViolation("message", 1, 50, null);
RuleFailureModel pastViolation = newPastViolation("message", 1, 51, null);
Map<Violation, RuleFailureModel> mapping = decorator.mapViolations(Lists.newArrayList(newViolation), Lists.newArrayList(pastViolation));
@@ -149,7 +153,9 @@ public class ViolationPersisterDecoratorTest {
for (int i = decorator.checksums.size() - 1; i < lineId; i++) {
decorator.checksums.add("");
}
- decorator.checksums.set(lineId - 1, ViolationPersisterDecorator.getChecksum(lineChecksum));
+ if (lineChecksum != null) {
+ decorator.checksums.set(lineId - 1, ViolationPersisterDecorator.getChecksum(lineChecksum));
+ }
return violation;
}