aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-duplications/src
diff options
context:
space:
mode:
authorZeeshan Asghar <zeeshan.asghar@devfactory.com>2016-01-21 15:56:32 +0500
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-01-29 17:01:31 +0100
commitbf071cefa1d04303ae246de745a8856c64b9617f (patch)
tree8d31b74cadac3271f8519d3d76566f04b2139e45 /sonar-duplications/src
parent1fc88e490a8db848301e784d53d5170018b6d1e5 (diff)
downloadsonarqube-bf071cefa1d04303ae246de745a8856c64b9617f.tar.gz
sonarqube-bf071cefa1d04303ae246de745a8856c64b9617f.zip
squid:S1213 members of an interface decleration or class should appear in a pre-defined order
Diffstat (limited to 'sonar-duplications/src')
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Search.java22
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/SuffixTree.java12
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/SuffixTreeCloneDetectionAlgorithm.java22
3 files changed, 28 insertions, 28 deletions
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Search.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Search.java
index ba0db8e86d4..bdc87065250 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Search.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Search.java
@@ -35,16 +35,23 @@ public final class Search {
private final List<Integer> list = new ArrayList<>();
private final List<Node> innerNodes = new ArrayList<>();
-
- public static void perform(TextSet text, Collector reporter) {
- new Search(SuffixTree.create(text), text, reporter).compute();
- }
+
+ private static final Comparator<Node> DEPTH_COMPARATOR = new Comparator<Node>() {
+ @Override
+ public int compare(Node o1, Node o2) {
+ return o2.depth - o1.depth;
+ }
+ };
private Search(SuffixTree tree, TextSet text, Collector reporter) {
this.tree = tree;
this.text = text;
this.reporter = reporter;
}
+
+ public static void perform(TextSet text, Collector reporter) {
+ new Search(SuffixTree.create(text), text, reporter).compute();
+ }
private void compute() {
// O(N)
@@ -57,13 +64,6 @@ public final class Search {
visitInnerNodes();
}
- private static final Comparator<Node> DEPTH_COMPARATOR = new Comparator<Node>() {
- @Override
- public int compare(Node o1, Node o2) {
- return o2.depth - o1.depth;
- }
- };
-
/**
* Depth-first search (DFS).
*/
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/SuffixTree.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/SuffixTree.java
index d4c5678c44f..fc0975dd87d 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/SuffixTree.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/SuffixTree.java
@@ -46,7 +46,12 @@ public final class SuffixTree {
final Text text;
private final Node root;
-
+
+ private SuffixTree(Text text) {
+ this.text = text;
+ root = new Node(this, null);
+ }
+
public static SuffixTree create(Text text) {
SuffixTree tree = new SuffixTree(text);
Suffix active = new Suffix(tree.root, 0, -1);
@@ -56,11 +61,6 @@ public final class SuffixTree {
return tree;
}
- private SuffixTree(Text text) {
- this.text = text;
- root = new Node(this, null);
- }
-
private void addPrefix(Suffix active, int endIndex) {
Node lastParentNode = null;
Node parentNode;
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/SuffixTreeCloneDetectionAlgorithm.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/SuffixTreeCloneDetectionAlgorithm.java
index 1e83cca5c05..1d84f92df8c 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/SuffixTreeCloneDetectionAlgorithm.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/SuffixTreeCloneDetectionAlgorithm.java
@@ -34,7 +34,17 @@ import org.sonar.duplications.index.CloneGroup;
import org.sonar.duplications.index.CloneIndex;
public final class SuffixTreeCloneDetectionAlgorithm {
-
+
+ private SuffixTreeCloneDetectionAlgorithm() {
+ }
+
+ private static final Comparator<Block> BLOCK_COMPARATOR = new Comparator<Block>() {
+ @Override
+ public int compare(Block o1, Block o2) {
+ return o1.getIndexInFile() - o2.getIndexInFile();
+ }
+ };
+
public static List<CloneGroup> detect(CloneIndex cloneIndex, Collection<Block> fileBlocks) {
if (fileBlocks.isEmpty()) {
return Collections.emptyList();
@@ -48,9 +58,6 @@ public final class SuffixTreeCloneDetectionAlgorithm {
return reporter.getResult();
}
- private SuffixTreeCloneDetectionAlgorithm() {
- }
-
private static TextSet createTextSet(CloneIndex index, Collection<Block> fileBlocks) {
Set<ByteArray> hashes = new HashSet<>();
for (Block fileBlock : fileBlocks) {
@@ -112,11 +119,4 @@ public final class SuffixTreeCloneDetectionAlgorithm {
return collection;
}
- private static final Comparator<Block> BLOCK_COMPARATOR = new Comparator<Block>() {
- @Override
- public int compare(Block o1, Block o2) {
- return o1.getIndexInFile() - o2.getIndexInFile();
- }
- };
-
}