mirror of
https://github.com/SonarSource/sonarqube.git
synced 2024-08-28 05:54:38 +02:00
Fix Quality flaws
This commit is contained in:
parent
18af892e0d
commit
3ab6644336
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user