aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-duplications/src/main/java
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2019-12-09 09:34:43 -0600
committerSonarTech <sonartech@sonarsource.com>2019-12-10 20:46:09 +0100
commitd1fd889554bccbb50122550899dbb66b90b04f78 (patch)
tree9cad838366292ee79b77ac3513403f7489b06355 /sonar-duplications/src/main/java
parentf86a1094588e4e47b3abf612891af0431653cd0e (diff)
downloadsonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.tar.gz
sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.zip
Fix code quality issues and reduce dependency on Guava
Diffstat (limited to 'sonar-duplications/src/main/java')
-rw-r--r--sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java2
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/detector/ContainsInComparator.java20
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/statement/matcher/UptoTokenMatcher.java5
3 files changed, 9 insertions, 18 deletions
diff --git a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java b/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java
index bc7a20bdd16..e2adf71f69e 100644
--- a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java
+++ b/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java
@@ -67,7 +67,7 @@ public class TokenEntry implements Comparable<TokenEntry> {
i = TOKENS.size() + 1;
TOKENS.put(image, i);
}
- this.identifier = i.intValue();
+ this.identifier = i;
this.tokenSrcID = tokenSrcID;
this.beginLine = beginLine;
this.index = tokenCount++;
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/ContainsInComparator.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/ContainsInComparator.java
index efea70410c8..31b1481270c 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/ContainsInComparator.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/ContainsInComparator.java
@@ -34,25 +34,17 @@ public final class ContainsInComparator implements Comparator<ClonePart> {
/**
* Defines order by resourceId.
*/
- public static final Comparator<ClonePart> RESOURCE_ID_COMPARATOR = new Comparator<ClonePart>() {
- @Override
- public int compare(ClonePart o1, ClonePart o2) {
- return FastStringComparator.INSTANCE.compare(o1.getResourceId(), o2.getResourceId());
- }
- };
+ public static final Comparator<ClonePart> RESOURCE_ID_COMPARATOR = (o1, o2) -> FastStringComparator.INSTANCE.compare(o1.getResourceId(), o2.getResourceId());
/**
* Defines order by resourceId and by unitStart.
*/
- public static final Comparator<ClonePart> CLONEPART_COMPARATOR = new Comparator<ClonePart>() {
- @Override
- public int compare(ClonePart o1, ClonePart o2) {
- int c = RESOURCE_ID_COMPARATOR.compare(o1, o2);
- if (c == 0) {
- return o1.getUnitStart() - o2.getUnitStart();
- }
- return c;
+ public static final Comparator<ClonePart> CLONEPART_COMPARATOR = (o1, o2) -> {
+ int c = RESOURCE_ID_COMPARATOR.compare(o1, o2);
+ if (c == 0) {
+ return o1.getUnitStart() - o2.getUnitStart();
}
+ return c;
};
private final int l1;
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/statement/matcher/UptoTokenMatcher.java b/sonar-duplications/src/main/java/org/sonar/duplications/statement/matcher/UptoTokenMatcher.java
index e8ccfb4018e..52d0fe18cd9 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/statement/matcher/UptoTokenMatcher.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/statement/matcher/UptoTokenMatcher.java
@@ -19,6 +19,7 @@
*/
package org.sonar.duplications.statement.matcher;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -41,9 +42,7 @@ public class UptoTokenMatcher extends TokenMatcher {
// otherwise we will always try to consume everything, but will never succeed
throw new IllegalArgumentException();
}
- for (String uptoMatchToken : uptoMatchTokens) {
- this.uptoMatchTokens.add(uptoMatchToken);
- }
+ this.uptoMatchTokens.addAll(Arrays.asList(uptoMatchTokens));
}
@Override