summaryrefslogtreecommitdiffstats
path: root/plugins/sonar-cpd-plugin/src
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-09-12 02:26:06 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-09-12 02:26:38 +0400
commitf51d791bf3c45222086f031f75cdaeae0358883a (patch)
tree1bcd9e2fce9ac17ea824e66290f2e5af1cb7f927 /plugins/sonar-cpd-plugin/src
parent705bb4b9ed41d36a10864d2e0365b73c669a4028 (diff)
downloadsonarqube-f51d791bf3c45222086f031f75cdaeae0358883a.tar.gz
sonarqube-f51d791bf3c45222086f031f75cdaeae0358883a.zip
Fix violations
Diffstat (limited to 'plugins/sonar-cpd-plugin/src')
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java24
1 files changed, 12 insertions, 12 deletions
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java
index 1fc00423f99..55072da43b4 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java
@@ -21,6 +21,7 @@ package org.sonar.plugins.cpd;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -67,7 +68,7 @@ public class DuplicationsData {
}
private String getDuplicationXMLData() {
- Collections.sort(duplicationXMLEntries);
+ Collections.sort(duplicationXMLEntries, COMPARATOR);
StringBuilder duplicationXML = new StringBuilder("<duplications>");
for (XmlEntry xmlEntry : duplicationXMLEntries) {
duplicationXML.append(xmlEntry.toString());
@@ -76,10 +77,16 @@ public class DuplicationsData {
return duplicationXML.toString();
}
- /**
- * Note: this class has a natural ordering that is inconsistent with equals.
- */
- private static final class XmlEntry implements Comparable<XmlEntry> {
+ private static final Comparator<XmlEntry> COMPARATOR = new Comparator<XmlEntry>() {
+ public int compare(XmlEntry o1, XmlEntry o2) {
+ if (o1.startLine == o2.startLine) {
+ return o1.lines - o2.lines;
+ }
+ return o1.startLine - o2.startLine;
+ }
+ };
+
+ private static final class XmlEntry {
private String target;
private int targetStartLine;
private int startLine;
@@ -100,13 +107,6 @@ public class DuplicationsData {
.append("\" target-resource=\"").append(target).append("\"/>")
.toString();
}
-
- public int compareTo(XmlEntry o) {
- if (startLine == o.startLine) {
- return lines - o.lines;
- }
- return startLine - o.startLine;
- }
}
}