diff options
author | ameya <ask1604@gmail.com> | 2017-10-11 13:03:03 -0700 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-10-16 09:34:31 +0200 |
commit | 3ab664433645b5e752c2447ce278617611aa9759 (patch) | |
tree | a7bcf5bcaa91c8ffbd9725dea124e010a964f54c | |
parent | 18af892e0df11889eb699c4e562e6bbd979b559f (diff) | |
download | sonarqube-3ab664433645b5e752c2447ce278617611aa9759.tar.gz sonarqube-3ab664433645b5e752c2447ce278617611aa9759.zip |
Fix Quality flaws
6 files changed, 12 insertions, 11 deletions
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java b/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java index 09482d16d00..975563da4ec 100644 --- a/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java +++ b/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java @@ -123,7 +123,7 @@ public class DatabaseUtils { } private static <OUTPUT, INPUT extends Comparable<INPUT>, RESULT extends Collection<OUTPUT>> RESULT executeLargeInputs(Collection<INPUT> input, - Function<List<INPUT>, RESULT> function, java.util.function.Function<Integer, RESULT> outputInitializer, IntFunction<Integer> partitionSizeManipulations) { + Function<List<INPUT>, RESULT> function, java.util.function.IntFunction<RESULT> outputInitializer, IntFunction<Integer> partitionSizeManipulations) { if (input.isEmpty()) { return outputInitializer.apply(0); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java index aaa8cf5f54d..459c97075ae 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java @@ -42,7 +42,7 @@ public class InputModuleHierarchyProvider extends ProviderAdapter { validator.validate(projectReactor); // 3 Create modules and the hierarchy - DefaultInputModule root = new DefaultInputModule(projectReactor.getRoot(), batchIdGenerator.get()); + DefaultInputModule root = new DefaultInputModule(projectReactor.getRoot(), batchIdGenerator.getAsInt()); Map<DefaultInputModule, DefaultInputModule> parents = createChildren(root, batchIdGenerator, new HashMap<>()); if (parents.isEmpty()) { hierarchy = new DefaultInputModuleHierarchy(root); @@ -56,7 +56,7 @@ public class InputModuleHierarchyProvider extends ProviderAdapter { private static Map<DefaultInputModule, DefaultInputModule> createChildren(DefaultInputModule parent, BatchIdGenerator batchIdGenerator, Map<DefaultInputModule, DefaultInputModule> parents) { for (ProjectDefinition def : parent.definition().getSubProjects()) { - DefaultInputModule child = new DefaultInputModule(def, batchIdGenerator.get()); + DefaultInputModule child = new DefaultInputModule(def, batchIdGenerator.getAsInt()); parents.put(child, parent); createChildren(child, batchIdGenerator, parents); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/BatchIdGenerator.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/BatchIdGenerator.java index 119d8d9bc9f..28a5ace2347 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/BatchIdGenerator.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/BatchIdGenerator.java @@ -20,7 +20,7 @@ package org.sonar.scanner.scan.filesystem; import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Supplier; +import java.util.function.IntSupplier; import javax.annotation.concurrent.ThreadSafe; @@ -32,11 +32,11 @@ import org.sonar.api.batch.fs.InputComponent; * The ID should never be 0, as it is sometimes used to indicate invalid components. */ @ThreadSafe -public class BatchIdGenerator implements Supplier<Integer> { +public class BatchIdGenerator implements IntSupplier { private AtomicInteger nextBatchId = new AtomicInteger(1); @Override - public Integer get() { + public int getAsInt() { return nextBatchId.getAndIncrement(); } } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java index 09f774a0d32..e0dc7eab38b 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java @@ -198,7 +198,7 @@ public class FileIndexer { private void indexFileAndParentDir(InputFile inputFile, String parentRelativePath) { DefaultInputDir inputDir = (DefaultInputDir) componentStore.getDir(module.key(), parentRelativePath); if (inputDir == null) { - inputDir = new DefaultInputDir(module.key(), parentRelativePath, batchIdGenerator.get()); + inputDir = new DefaultInputDir(module.key(), parentRelativePath, batchIdGenerator.getAsInt()); inputDir.setModuleBaseDir(module.getBaseDir()); componentTree.index(inputDir, module); defaultModuleFileSystem.add(inputDir); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputFileBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputFileBuilder.java index aee7714e9fc..2cb2969f1f3 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputFileBuilder.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputFileBuilder.java @@ -57,7 +57,7 @@ public class InputFileBuilder { DefaultIndexedFile indexedFile = new DefaultIndexedFile(absolutePath, moduleKey, PathUtils.sanitize(projectBaseDir.relativize(absolutePath).toString()), PathUtils.sanitize(moduleBaseDir.relativize(absolutePath).toString()), - type, language, idGenerator.get(), sensorStrategy); + type, language, idGenerator.getAsInt(), sensorStrategy); DefaultInputFile inputFile = new DefaultInputFile(indexedFile, f -> metadataGenerator.setMetadata(f, moduleFileSystemInitializer.defaultEncoding())); if (language != null) { inputFile.setPublished(true); diff --git a/tests/src/test/java/org/sonarqube/tests/ce/CeWorkersTest.java b/tests/src/test/java/org/sonarqube/tests/ce/CeWorkersTest.java index 747602c0850..491c671a3ce 100644 --- a/tests/src/test/java/org/sonarqube/tests/ce/CeWorkersTest.java +++ b/tests/src/test/java/org/sonarqube/tests/ce/CeWorkersTest.java @@ -34,6 +34,7 @@ import java.util.List; import java.util.Random; import java.util.Set; import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.IntStream; import javax.annotation.Nullable; @@ -209,16 +210,16 @@ public class CeWorkersTest { .getTasksList(); } - private <T> T waitForWsCallStatus(Function<WsClient, T> call, Function<T, Boolean> test) { + private <T> T waitForWsCallStatus(Function<WsClient, T> call, Predicate<T> test) { WsClient wsClient = ItUtils.newAdminWsClient(orchestrator); int i = 0; T returnValue = call.apply(wsClient); - boolean expectedState = test.apply(returnValue); + boolean expectedState = test.test(returnValue); while (i < MAX_WAIT_LOOP && !expectedState) { waitInterruptedly(); i++; returnValue = call.apply(wsClient); - expectedState = test.apply(returnValue); + expectedState = test.test(returnValue); } assertThat(expectedState) .as("Failed to wait for expected queue status. Last call returned:\n%s", returnValue) |