diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2019-12-09 09:34:43 -0600 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-12-10 20:46:09 +0100 |
commit | d1fd889554bccbb50122550899dbb66b90b04f78 (patch) | |
tree | 9cad838366292ee79b77ac3513403f7489b06355 /server/sonar-ce | |
parent | f86a1094588e4e47b3abf612891af0431653cd0e (diff) | |
download | sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.tar.gz sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.zip |
Fix code quality issues and reduce dependency on Guava
Diffstat (limited to 'server/sonar-ce')
6 files changed, 10 insertions, 16 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java index f17cbf65d9e..d1bc0882f79 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java @@ -19,21 +19,18 @@ */ package org.sonar.ce.taskprocessor; -import com.google.common.base.Function; -import com.google.common.base.Joiner; import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import java.util.Collection; import java.util.Map; import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; import javax.annotation.Nonnull; import org.sonar.ce.task.CeTask; import org.sonar.ce.task.taskprocessor.CeTaskProcessor; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.FluentIterable.from; import static java.lang.String.CASE_INSENSITIVE_ORDER; import static java.lang.String.format; @@ -42,8 +39,6 @@ import static java.lang.String.format; * PicoContainer the current object belongs to. */ public class CeTaskProcessorRepositoryImpl implements CeTaskProcessorRepository { - private static final Joiner COMMA_JOINER = Joiner.on(", "); - private final Map<String, CeTaskProcessor> taskProcessorByCeTaskType; public CeTaskProcessorRepositoryImpl(CeTaskProcessor[] taskProcessors) { @@ -58,7 +53,7 @@ public class CeTaskProcessorRepositoryImpl implements CeTaskProcessorRepository private static Map<String, CeTaskProcessor> indexTaskProcessors(CeTaskProcessor[] taskProcessors) { Multimap<String, CeTaskProcessor> permissiveIndex = buildPermissiveCeTaskProcessorIndex(taskProcessors); checkUniqueHandlerPerCeTaskType(permissiveIndex); - return ImmutableMap.copyOf(Maps.transformValues(permissiveIndex.asMap(), CeTaskProcessorCollectionToFirstElement.INSTANCE)); + return permissiveIndex.asMap().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, y -> CeTaskProcessorCollectionToFirstElement.INSTANCE.apply(y.getValue()))); } private static Multimap<String, CeTaskProcessor> buildPermissiveCeTaskProcessorIndex(CeTaskProcessor[] taskProcessors) { @@ -79,7 +74,7 @@ public class CeTaskProcessorRepositoryImpl implements CeTaskProcessorRepository "There can be only one CeTaskProcessor instance registered as the processor for CeTask type %s. " + "More than one found. Please fix your configuration: %s", entry.getKey(), - COMMA_JOINER.join(from(entry.getValue()).transform(ToClassName.INSTANCE).toSortedList(CASE_INSENSITIVE_ORDER)))); + entry.getValue().stream().map(ToClassName.INSTANCE).sorted(CASE_INSENSITIVE_ORDER).collect(Collectors.joining(", ")))); } } diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java index 38d50609779..e5ac953aeb5 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java @@ -104,8 +104,7 @@ public class CeDistributedInformationImplTest { connectedClients.add(clientUUID1); connectedClients.add(clientUUID2); connectedClients.add(clientUUID3); - Map modifiableWorkerMap = new HashMap(); - modifiableWorkerMap.putAll(workerMap); + Map modifiableWorkerMap = new HashMap(workerMap); when(hzClientWrapper.getUuid()).thenReturn(clientUUID1); when(hzClientWrapper.getMemberUuids()).thenReturn(connectedClients); diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java index ed29b66a014..7a9ff48a625 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java @@ -89,7 +89,7 @@ public class CePluginJarExploderTest { return new File("src/test/plugins/sonar-test2-plugin/target/sonar-test2-plugin-0.1-SNAPSHOT.jar"); } - private class DumbFileSystem implements ServerFileSystem { + private static class DumbFileSystem implements ServerFileSystem { private final TemporaryFolder temp; private File tempDir; diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java index c002d288e26..3af53faea9b 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java @@ -19,9 +19,9 @@ */ package org.sonar.ce.container; -import com.google.common.collect.Maps; import java.io.File; import java.util.Collection; +import java.util.HashMap; import java.util.Map; import org.junit.After; import org.junit.Rule; @@ -144,7 +144,7 @@ public class CePluginRepositoryTest { */ @Override public Map<String, Plugin> load(Map<String, PluginInfo> infoByKeys) { - Map<String, Plugin> result = Maps.newHashMap(); + Map<String, Plugin> result = new HashMap<>(); for (String pluginKey : infoByKeys.keySet()) { result.put(pluginKey, mock(Plugin.class)); } diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index d6bf03851e6..aa6aedf7c59 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -138,7 +138,7 @@ public class ComputeEngineContainerImplTest { .map(ComponentAdapter::getComponentImplementation) .collect(Collectors.toList())).doesNotContain( (Class) CeDistributedInformationImpl.class).contains( - (Class) StandaloneCeDistributedInformation.class); + StandaloneCeDistributedInformation.class); assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull(); } finally { underTest.stop(); diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java index e686c1ea019..9c4c86b2db6 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java @@ -281,7 +281,7 @@ public class CeProcessingSchedulerImplTest { processingExecutorService.runFutures(); } - private class TestCeWorkerFactory implements CeWorkerFactory { + private static class TestCeWorkerFactory implements CeWorkerFactory { private final Iterator<CeWorker> ceWorkers; private TestCeWorkerFactory(CeWorker... ceWorkers) { |