aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-duplications/src/test/java/org/sonar
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/test/java/org/sonar
parentf86a1094588e4e47b3abf612891af0431653cd0e (diff)
downloadsonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.tar.gz
sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.zip
Fix code quality issues and reduce dependency on Guava
Diffstat (limited to 'sonar-duplications/src/test/java/org/sonar')
-rw-r--r--sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java5
-rw-r--r--sonar-duplications/src/test/java/org/sonar/duplications/index/DataUtilsTest.java2
-rw-r--r--sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java3
-rw-r--r--sonar-duplications/src/test/java/org/sonar/duplications/java/JavaDuplicationsFunctionalTest.java6
-rw-r--r--sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementTest.java2
5 files changed, 8 insertions, 10 deletions
diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java
index e21de0e8756..f44d6c4b70c 100644
--- a/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java
+++ b/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java
@@ -19,6 +19,7 @@
*/
package org.sonar.duplications.detector.original;
+import java.util.Arrays;
import org.junit.Test;
import org.sonar.duplications.block.Block;
@@ -40,9 +41,7 @@ public class BlocksGroupTest {
public static BlocksGroup newBlocksGroup(Block... blocks) {
BlocksGroup result = BlocksGroup.empty();
- for (Block block : blocks) {
- result.blocks.add(block);
- }
+ result.blocks.addAll(Arrays.asList(blocks));
return result;
}
diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/index/DataUtilsTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/index/DataUtilsTest.java
index 4825849122f..058161a8ee7 100644
--- a/sonar-duplications/src/test/java/org/sonar/duplications/index/DataUtilsTest.java
+++ b/sonar-duplications/src/test/java/org/sonar/duplications/index/DataUtilsTest.java
@@ -63,7 +63,7 @@ public class DataUtilsTest {
assertThat(DataUtils.binarySearch(sortable), is(2));
}
- class SimpleSortable implements DataUtils.Sortable {
+ static class SimpleSortable implements DataUtils.Sortable {
private final int[] a;
private final int size;
diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java
index 43636a71f66..23e6c0e4603 100644
--- a/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java
+++ b/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java
@@ -20,7 +20,6 @@
package org.sonar.duplications.internal.pmd;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;
@@ -42,7 +41,7 @@ public class TokenizerBridgeTest {
@Before
public void setUp() {
Tokenizer tokenizer = new Tokenizer() {
- public void tokenize(SourceCode tokens, Tokens tokenEntries) throws IOException {
+ public void tokenize(SourceCode tokens, Tokens tokenEntries) {
tokenEntries.add(new TokenEntry("t1", "src", 1));
tokenEntries.add(new TokenEntry("t2", "src", 1));
tokenEntries.add(new TokenEntry("t3", "src", 2));
diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaDuplicationsFunctionalTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaDuplicationsFunctionalTest.java
index 75966a19091..8d8f8ab2010 100644
--- a/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaDuplicationsFunctionalTest.java
+++ b/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaDuplicationsFunctionalTest.java
@@ -19,6 +19,7 @@
*/
package org.sonar.duplications.java;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.junit.Test;
@@ -33,7 +34,6 @@ import org.sonar.duplications.statement.Statement;
import org.sonar.duplications.statement.StatementChunker;
import org.sonar.duplications.token.TokenChunker;
-import static java.util.Arrays.asList;
import static java.util.stream.Collectors.joining;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -149,7 +149,7 @@ public class JavaDuplicationsFunctionalTest {
}
private String source(String... lines) {
- return asList(lines).stream().collect(joining("\n"));
+ return Arrays.stream(lines).collect(joining("\n"));
}
private static List<CloneGroup> detect2(String... fragments) {
@@ -180,7 +180,7 @@ public class JavaDuplicationsFunctionalTest {
private static BlockChunker BLOCK_CHUNKER = new BlockChunker(BLOCK_SIZE);
private List<CloneGroup> detect(String... lines) {
- String sourceCode = asList(lines).stream().collect(joining("\n"));
+ String sourceCode = Arrays.stream(lines).collect(joining("\n"));
MemoryCloneIndex index = new MemoryCloneIndex();
List<Statement> statements = STATEMENT_CHUNKER.chunk(TOKEN_CHUNKER.chunk(sourceCode));
List<Block> blocks = BLOCK_CHUNKER.chunk("resourceId", statements);
diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementTest.java
index 9762da77fba..f11a6f90fff 100644
--- a/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementTest.java
+++ b/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementTest.java
@@ -37,7 +37,7 @@ public class StatementTest {
@Test(expected = IllegalArgumentException.class)
public void shouldNotAcceptEmpty() {
- new Statement(new ArrayList<Token>());
+ new Statement(new ArrayList<>());
}
@Test