aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-duplications/src
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-duplications/src')
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/block/BlockChunker.java6
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/PmdBlockChunker.java6
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokensLine.java11
3 files changed, 8 insertions, 15 deletions
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/block/BlockChunker.java b/sonar-duplications/src/main/java/org/sonar/duplications/block/BlockChunker.java
index 40779fed35a..1a21a4a57ec 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/block/BlockChunker.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/block/BlockChunker.java
@@ -63,11 +63,9 @@ public class BlockChunker {
while (j < statements.size() && statements.get(j).getValue().equals(first.getValue())) {
j++;
}
+ filtered.add(statements.get(i));
if (i < j - 1) {
- Statement last = statements.get(j - 1);
- filtered.add(new Statement(first.getStartLine(), last.getEndLine(), first.getValue()));
- } else {
- filtered.add(statements.get(i));
+ filtered.add(statements.get(j - 1));
}
i = j;
}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/PmdBlockChunker.java b/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/PmdBlockChunker.java
index 1c8e9624f13..1ce97191f59 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/PmdBlockChunker.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/PmdBlockChunker.java
@@ -57,11 +57,9 @@ public class PmdBlockChunker {
while (j < fragments.size() && fragments.get(j).getValue().equals(first.getValue())) {
j++;
}
+ filtered.add(fragments.get(i));
if (i < j - 1) {
- TokensLine last = fragments.get(j - 1);
- filtered.add(new TokensLine(first.getStartUnit(), last.getEndUnit(), first.getStartLine(), last.getEndLine(), first.getValue()));
- } else {
- filtered.add(fragments.get(i));
+ filtered.add(fragments.get(j - 1));
}
i = j;
}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokensLine.java b/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokensLine.java
index 44fcaafb1c3..c4b5f63d348 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokensLine.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/internal/pmd/TokensLine.java
@@ -30,7 +30,6 @@ class TokensLine implements CodeFragment {
private final String value;
private final int startLine;
- private final int endLine;
private final int hashCode;
private final int startUnit;
@@ -38,14 +37,9 @@ class TokensLine implements CodeFragment {
public TokensLine(int startUnit, int endUnit, int startLine, String value) {
- this(startUnit, endUnit, startLine, startLine, value);
- }
-
- public TokensLine(int startUnit, int endUnit, int startLine, int endLine, String value) {
Preconditions.checkArgument(startLine > 0);
// TODO do we have requirements for length and hashcode ?
this.startLine = startLine;
- this.endLine = endLine;
this.value = value;
this.hashCode = value.hashCode();
@@ -61,8 +55,11 @@ class TokensLine implements CodeFragment {
return startLine;
}
+ /**
+ * Same as {@link #getStartLine()}
+ */
public int getEndLine() {
- return endLine;
+ return startLine;
}
public int getHashCode() {