package org.sonar.alm.client.github;
import com.google.gson.Gson;
-
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
-
import org.sonar.alm.client.github.GithubApplicationHttpClient.GetResponse;
import org.sonar.alm.client.github.GithubBinding.GsonGithubRepository;
import org.sonar.alm.client.github.GithubBinding.GsonInstallations;
import static java.net.HttpURLConnection.HTTP_FORBIDDEN;
import static java.net.HttpURLConnection.HTTP_OK;
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
-import static java.util.stream.Collectors.toList;
public class GithubApplicationClientImpl implements GithubApplicationClient {
private static final Logger LOG = Loggers.get(GithubApplicationClientImpl.class);
List<String> missingPermissions = permissions.entrySet().stream()
.filter(permission -> !Objects.equals(permission.getValue(), perms.get(permission.getKey())))
.map(Map.Entry::getKey)
- .collect(toList());
+ .toList();
if (!missingPermissions.isEmpty()) {
String message = missingPermissions.stream()
organizations.setOrganizations(gsonInstallations.get().installations.stream()
.map(gsonInstallation -> new Organization(gsonInstallation.account.id, gsonInstallation.account.login, null, null, null, null, null,
gsonInstallation.targetType))
- .collect(toList()));
+ .toList());
}
return organizations;
if (gsonRepositories.get().items != null) {
repositories.setRepositories(gsonRepositories.get().items.stream()
.map(GsonGithubRepository::toRepository)
- .collect(toList()));
+ .toList());
}
return repositories;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-import java.util.stream.Collectors;
import static org.sonar.auth.saml.SamlSettings.GROUP_NAME_ATTRIBUTE;
import static org.sonar.auth.saml.SamlSettings.USER_EMAIL_ATTRIBUTE;
samlAuthenticationStatus.getErrors().add(e.getMessage());
}
- samlAuthenticationStatus.getErrors().addAll(auth.getErrors().stream().filter(Objects::nonNull).collect(Collectors.toList()));
+ samlAuthenticationStatus.getErrors().addAll(auth.getErrors().stream().filter(Objects::nonNull).toList());
if (auth.getLastErrorReason() != null) {
samlAuthenticationStatus.getErrors().add(auth.getLastErrorReason());
}
.stream()
.filter(entry -> !entry.getValue().isEmpty() && (auth.getAttribute(entry.getValue()) == null || auth.getAttribute(entry.getValue()).isEmpty()))
.map(entry -> String.format("Mapping not found for the property %s, the field %s is not available in the SAML response.", entry.getKey(), entry.getValue()))
- .collect(Collectors.toList());
+ .toList();
}
}
import java.util.List;
import java.util.Map;
import java.util.function.Function;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
List<ComponentDto> moduleDtos = dbClient.componentDao()
.selectProjectAndModulesFromProjectKey(dbSession, rootKey, true, branchKey, prKey).stream()
.filter(c -> Qualifiers.MODULE.equals(c.qualifier()))
- .collect(Collectors.toList());
+ .toList();
if (moduleDtos.isEmpty()) {
return Collections.emptyMap();
}
public VisitorsCrawler(Collection<ComponentVisitor> visitors, boolean computeDuration) {
- List<VisitorWrapper> visitorWrappers = visitors.stream().map(ToVisitorWrapper.INSTANCE).collect(Collectors.toList());
- this.preOrderVisitorWrappers = visitorWrappers.stream().filter(MathPreOrderVisitor.INSTANCE).collect(Collectors.toList());
- this.postOrderVisitorWrappers = visitorWrappers.stream().filter(MatchPostOrderVisitor.INSTANCE).collect(Collectors.toList());
+ List<VisitorWrapper> visitorWrappers = visitors.stream().map(ToVisitorWrapper.INSTANCE).toList();
+ this.preOrderVisitorWrappers = visitorWrappers.stream().filter(MathPreOrderVisitor.INSTANCE).toList();
+ this.postOrderVisitorWrappers = visitorWrappers.stream().filter(MatchPostOrderVisitor.INSTANCE).toList();
this.computeDuration = computeDuration;
this.visitorCumulativeDurations = computeDuration ? visitors.stream().collect(Collectors.toMap(v -> v, v -> new VisitorDuration())) : Collections.emptyMap();
}
private void visitImpl(Component component) {
MatchVisitorMaxDepth visitorMaxDepth = MatchVisitorMaxDepth.forComponent(component);
- List<VisitorWrapper> preOrderVisitorWrappersToExecute = preOrderVisitorWrappers.stream().filter(visitorMaxDepth).collect(Collectors.toList());
- List<VisitorWrapper> postOrderVisitorWrappersToExecute = postOrderVisitorWrappers.stream().filter(visitorMaxDepth).collect(Collectors.toList());
+ List<VisitorWrapper> preOrderVisitorWrappersToExecute = preOrderVisitorWrappers.stream().filter(visitorMaxDepth).toList();
+ List<VisitorWrapper> postOrderVisitorWrappersToExecute = postOrderVisitorWrappers.stream().filter(visitorMaxDepth).toList();
if (preOrderVisitorWrappersToExecute.isEmpty() && postOrderVisitorWrappersToExecute.isEmpty()) {
return;
}
import java.util.Map;
import java.util.function.Function;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Configuration;
List<CloneGroup> duplications = SuffixTreeCloneDetectionAlgorithm.detect(duplicationIndex, originBlocks);
Iterable<CloneGroup> filtered = duplications.stream()
.filter(getNumberOfUnitsNotLessThan(component.getFileAttributes().getLanguageKey()))
- .collect(Collectors.toList());
+ .toList();
addDuplications(component, filtered);
}
.filter(new DoesNotMatchSameComponentKey(originPart.getResourceId()))
.filter(new DuplicateLimiter(file, originPart))
.map(ClonePartToCrossProjectDuplicate.INSTANCE)
- .collect(Collectors.toList());
+ .toList();
}
private NumberOfUnitsNotLessThan getNumberOfUnitsNotLessThan(String language) {
}
public List<Match> filter(Collection<Match> matches) {
- return matches.stream().filter(this::notAlreadyMatched).collect(Collectors.toList());
+ return matches.stream().filter(this::notAlreadyMatched).toList();
}
private boolean notAlreadyMatched(Match input) {
.values()
.stream()
.filter(file -> Objects.nonNull(file.getFileAttributes().getOldRelativePath()))
- .collect(toList());
+ .toList();
}
private static Optional<DbComponent> retrieveDbFile(Map<String, DbComponent> dbFilesByPathReference, Component file) {
*/
public List<DefaultIssue> loadChanges(DbSession dbSession, Collection<DefaultIssue> issues) {
Map<String, List<IssueChangeDto>> changeDtoByIssueKey = dbClient.issueChangeDao()
- .selectByIssueKeys(dbSession, issues.stream().map(DefaultIssue::key).collect(toList()))
+ .selectByIssueKeys(dbSession, issues.stream().map(DefaultIssue::key).toList())
.stream()
.collect(groupingBy(IssueChangeDto::getIssueKey));
private void setFilteredChanges(Map<String, List<IssueChangeDto>> changeDtoByIssueKey, DefaultIssue i) {
List<IssueChangeDto> sortedIssueChanges = changeDtoByIssueKey.computeIfAbsent(i.key(), k -> emptyList()).stream()
.sorted(Comparator.comparing(IssueChangeDto::getIssueChangeCreationDate).reversed())
- .collect(toList());
+ .toList();
int statusCount = 0;
int branchCount = 0;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.sonar.ce.task.projectanalysis.component.Component;
import org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit;
var issues = Stream.of(newOpenIssues, existingOpenIssues, closedIssues, copiedIssues)
.flatMap(Collection::stream)
- .collect(Collectors.toList());
+ .toList();
processIssues(component, issues);
issueVisitors.beforeCaching(component);
appendIssuesToCache(cacheAppender, issues);
// TODO should replace flag "beingClosed" by express call to transition "automaticClose"
issue.setBeingClosed(true)
// TODO manual issues -> was updater.setResolution(newIssue, Issue.RESOLUTION_REMOVED, changeContext);. Is it a problem ?
- ).collect(Collectors.toList());
+ ).toList();
}
private List<DefaultIssue> copyIssues(Map<DefaultIssue, DefaultIssue> matched) {
import java.util.List;
import java.util.Optional;
import java.util.Set;
-import java.util.stream.Collectors;
import org.sonar.api.issue.Issue;
import org.sonar.ce.task.projectanalysis.component.Component;
import org.sonar.ce.task.projectanalysis.source.NewLinesRepository;
Input<DefaultIssue> unmatchedRawsAfterTargetResolvedTracking;
if (targetInputFactory.hasTargetBranchAnalysis()) {
Input<DefaultIssue> targetInput = targetInputFactory.createForTargetBranch(component);
- List<DefaultIssue> resolvedTargetIssues = targetInput.getIssues().stream().filter(i -> Issue.STATUS_RESOLVED.equals(i.status())).collect(Collectors.toList());
+ List<DefaultIssue> resolvedTargetIssues = targetInput.getIssues().stream().filter(i -> Issue.STATUS_RESOLVED.equals(i.status())).toList();
Input<DefaultIssue> resolvedTargetInput = createInput(targetInput, resolvedTargetIssues);
Tracking<DefaultIssue, DefaultIssue> prResolvedTracking = tracker.trackNonClosed(unmatchedRawsAfterChangedLineFiltering, resolvedTargetInput);
- unmatchedRawsAfterTargetResolvedTracking = createInput(rawInput, prResolvedTracking.getUnmatchedRaws().collect(Collectors.toList()));
+ unmatchedRawsAfterTargetResolvedTracking = createInput(rawInput, prResolvedTracking.getUnmatchedRaws().toList());
} else {
unmatchedRawsAfterTargetResolvedTracking = unmatchedRawsAfterChangedLineFiltering;
}
final Set<Integer> newLines = newLinesOpt.get();
return issues.stream()
.filter(i -> IssueLocations.allLinesFor(i, component.getUuid()).anyMatch(newLines::contains))
- .collect(Collectors.toList());
+ .toList();
}
}
return dbClient.issueDao().selectOpenByComponentUuids(session, uuids)
.stream()
.map(SiblingsIssuesLoader::toSiblingIssue)
- .collect(Collectors.toList());
+ .toList();
}
}
package org.sonar.ce.task.projectanalysis.measure;
import java.util.Objects;
-import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import javax.annotation.CheckForNull;
import org.sonar.ce.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper;
public void setMeasureComputers(Iterable<MeasureComputerWrapper> measureComputers) {
requireNonNull(measureComputers, "Measure computers cannot be null");
checkState(this.measureComputers == null, "Measure computers have already been initialized");
- this.measureComputers = StreamSupport.stream(measureComputers.spliterator(), false).filter(Objects::nonNull).collect(Collectors.toList());
+ this.measureComputers = StreamSupport.stream(measureComputers.spliterator(), false).filter(Objects::nonNull).toList();
}
}
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.List;
-import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import javax.annotation.concurrent.Immutable;
import org.sonar.ce.task.projectanalysis.measure.Measure;
this.level = requireNonNull(level);
this.conditions = StreamSupport.stream(conditions.spliterator(), false)
.sorted(new ConditionComparator<>(c -> c.getCondition().getMetric().getKey()))
- .collect(Collectors.toList());
+ .toList();
this.ignoredConditions = ignoredConditions;
}
public List<Metric> getMetricsByType(Metric.MetricType type) {
verifyMetricsInitialized();
- return metricsByKey.values().stream().filter(m -> m.getType() == type).collect(Collectors.toList());
+ return metricsByKey.values().stream().filter(m -> m.getType() == type).toList();
}
private void verifyMetricsInitialized() {
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import java.util.stream.Collectors;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.utils.KeyValueFormat;
import org.sonar.api.utils.log.Logger;
.stream()
.filter(entry -> entry.getValue() == 1)
.map(Map.Entry::getKey)
- .collect(Collectors.toList());
+ .toList();
}
public static final class Counter {
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
-import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
return;
}
- Collection<String> hashes = cpdTextBlocks.stream().map(CpdTextBlockToHash.INSTANCE).collect(Collectors.toList());
+ Collection<String> hashes = cpdTextBlocks.stream().map(CpdTextBlockToHash.INSTANCE).toList();
List<DuplicationUnitDto> dtos = selectDuplicates(file, hashes);
if (dtos.isEmpty()) {
return;
}
- Collection<Block> duplicatedBlocks = dtos.stream().map(DtoToBlock.INSTANCE).collect(Collectors.toList());
- Collection<Block> originBlocks = cpdTextBlocks.stream().map(new CpdTextBlockToBlock(file.getKey())).collect(Collectors.toList());
+ Collection<Block> duplicatedBlocks = dtos.stream().map(DtoToBlock.INSTANCE).toList();
+ Collection<Block> originBlocks = cpdTextBlocks.stream().map(new CpdTextBlockToBlock(file.getKey())).toList();
LOGGER.trace("Found {} duplicated cpd blocks on file {}", duplicatedBlocks.size(), file.getKey());
integrateCrossProjectDuplications.computeCpd(file, originBlocks, duplicatedBlocks);
package org.sonar.ce.task.projectanalysis.step;
import java.util.function.Function;
-import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
import org.sonar.ce.task.projectanalysis.batch.BatchReportReader;
new Duplication(
convert(duplication.getOriginPosition(), id),
duplication.getDuplicateList().stream()
- .map(new BatchDuplicateToCeDuplicate(file)).collect(Collectors.toList())));
+ .map(new BatchDuplicateToCeDuplicate(file)).toList()));
}
private DetailedTextBlock convert(ScannerReport.TextRange textRange, int id) {
@Override
public void execute(Context context) {
- List<MeasureComputerWrapper> wrappers = Arrays.stream(measureComputers).map(ToMeasureWrapper.INSTANCE).collect(Collectors.toList());
+ List<MeasureComputerWrapper> wrappers = Arrays.stream(measureComputers).map(ToMeasureWrapper.INSTANCE).toList();
validateMetrics(wrappers);
measureComputersHolder.setMeasureComputers(sortComputers(wrappers));
}
return measureComputer.getDefinition().getInputMetrics().stream()
.map(toComputerByOutputMetricKey)
.filter(Objects::nonNull)
- .collect(Collectors.toList());
+ .toList();
}
private static Collection<MeasureComputerWrapper> getDependents(MeasureComputerWrapper measureComputer, ToComputerByKey toComputerByInputMetricKey) {
return measureComputer.getDefinition().getInputMetrics().stream()
.map(toComputerByInputMetricKey)
- .collect(Collectors.toList());
+ .toList();
}
private static class ToComputerByKey implements Function<String, MeasureComputerWrapper> {
*/
package org.sonar.ce.task.projectanalysis.step;
-import java.util.stream.Collectors;
import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
import org.sonar.ce.task.projectanalysis.qualitygate.Condition;
import org.sonar.ce.task.projectanalysis.qualitygate.MutableQualityGateHolder;
}
private static QualityGate filterQGForPR(QualityGate qg) {
- return new QualityGate(qg.getUuid(), qg.getName(), qg.getConditions().stream().filter(Condition::useVariation).collect(Collectors.toList()));
+ return new QualityGate(qg.getUuid(), qg.getName(), qg.getConditions().stream().filter(Condition::useVariation).toList());
}
private QualityGate getProjectQualityGate() {
import java.util.Objects;
import java.util.function.Function;
-import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
.setDescription(event.getDescription())
.setData(event.getData());
// FIXME bulk insert
- for (EventDto batchEventDto : StreamSupport.stream(eventRepository.getEvents(component).spliterator(), false).map(eventToEventDto).collect(Collectors.toList())) {
+ for (EventDto batchEventDto : StreamSupport.stream(eventRepository.getEvents(component).spliterator(), false).map(eventToEventDto).toList()) {
dbClient.eventDao().insert(session, batchEventDto);
}
}
private Map<String, UserDto> loadUserDtoByUuid(NewIssuesStatistics statistics) {
List<Map.Entry<String, NewIssuesStatistics.Stats>> entriesWithIssuesOnLeak = statistics.getAssigneesStatistics().entrySet()
- .stream().filter(e -> e.getValue().hasIssuesOnCurrentAnalysis()).collect(toList());
- List<String> assigneeUuids = entriesWithIssuesOnLeak.stream().map(Map.Entry::getKey).collect(toList());
+ .stream().filter(e -> e.getValue().hasIssuesOnCurrentAnalysis()).toList();
+ List<String> assigneeUuids = entriesWithIssuesOnLeak.stream().map(Map.Entry::getKey).toList();
try (DbSession dbSession = dbClient.openSession(false)) {
return dbClient.userDao().selectByUuids(dbSession, assigneeUuids).stream().collect(toMap(UserDto::getUuid, u -> u));
}
import java.util.List;
import java.util.Objects;
import java.util.Optional;
-import java.util.stream.Collectors;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.log.Loggers;
import org.sonar.ce.task.projectexport.component.ComponentRepository;
.setStart(e.getStart())
.setEnd(e.getEnd())
.setType(ProjectDump.MessageFormattingType.valueOf(e.getType().name())).build())
- .collect(Collectors.toList());
+ .toList();
}
private static class RuleRegistrar {
import com.sonarsource.governance.projectdump.protobuf.ProjectDump;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
import org.sonar.api.utils.log.Loggers;
import org.sonar.ce.task.projectexport.component.ComponentRepository;
import org.sonar.ce.task.step.ComputationStep;
.stream()
.filter(dto -> dto.getComponentUuid() != null)
.filter(dto -> !IGNORED_KEYS.contains(dto.getKey()))
- .collect(Collectors.toList());
+ .toList();
for (PropertyDto property : properties) {
builder.clear()
.setKey(property.getKey())
public void get_all_metrics() {
List<MetricDto> enabledMetrics = IntStream.range(0, 1 + new Random().nextInt(12))
.mapToObj(i -> dbTester.measures().insertMetric(t -> t.setKey("key_enabled_" + i).setEnabled(true)))
- .collect(Collectors.toList());
+ .toList();
IntStream.range(0, 1 + new Random().nextInt(12))
.forEach(i -> dbTester.measures().insertMetric(t -> t.setKey("key_disabled_" + i).setEnabled(false)));
public void getMetricsByType_givenRatingType_returnRatingMetrics() {
List<MetricDto> enabledMetrics = IntStream.range(0, 1 + new Random().nextInt(12))
.mapToObj(i -> dbTester.measures().insertMetric(t -> t.setKey("key_enabled_" + i).setEnabled(true).setValueType("RATING")))
- .collect(Collectors.toList());
+ .toList();
underTest.start();
assertThat(underTest.getMetricsByType(Metric.MetricType.RATING))
List<DefaultIssue> issues = IntStream.range(0, 2001 + new Random().nextInt(10))
.mapToObj(i -> newIssue(ruleDefinitionDto, project, file).setKee("uuid_" + i).setType(randomTypeExceptHotspot).toDefaultIssue()
.setNew(false).setChanged(true).setSendNotifications(true).setAssigneeUuid(user.getUuid()))
- .collect(toList());
+ .toList();
DiskCache.CacheAppender cacheAppender = protoIssueCache.newAppender();
issues.forEach(cacheAppender::append);
cacheAppender.close();
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
-import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.sonar.ce.task.projectanalysis.component.Component;
}
public static Iterable<MeasureRepoEntry> toEntries(Map<String, Measure> data) {
- return data.entrySet().stream().map(toMeasureRepoEntry()).collect(Collectors.toList());
+ return data.entrySet().stream().map(toMeasureRepoEntry()).toList();
}
public static MeasureRepoEntry entryOf(String metricKey, Measure measure) {
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.stream.Collectors;
-
import org.junit.rules.ExternalResource;
import static com.google.common.base.Preconditions.checkState;
@Override
public List<Metric> getMetricsByType(Metric.MetricType type) {
- return metricsByKey.values().stream().filter(m -> m.getType() == type).collect(Collectors.toList());
+ return metricsByKey.values().stream().filter(m -> m.getType() == type).toList();
}
}
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
import org.sonar.api.Startable;
import org.sonar.ce.configuration.CeConfiguration;
import org.sonar.ce.taskprocessor.CeWorker;
return workers.stream()
.map(CeWorker::getUUID)
.sorted()
- .collect(Collectors.toList());
+ .toList();
}
@Override
.filter(ceWorkerController::isEnabled)
.map(CeWorker::getUUID)
.sorted()
- .collect(Collectors.toList());
+ .toList();
}
@Override
private static List<PrOrBranchTask> filterOldestPerProject(List<PrOrBranchTask> queuedPrOrBranches) {
Set<String> mainComponentUuidsSeen = new HashSet<>();
- return queuedPrOrBranches.stream().filter(t -> mainComponentUuidsSeen.add(t.getMainComponentUuid())).collect(toList());
+ return queuedPrOrBranches.stream().filter(t -> mainComponentUuidsSeen.add(t.getMainComponentUuid())).toList();
}
/**
String mainComponentUuid = task.getMainComponentUuid();
List<PrOrBranchTask> sameComponentTasks = inProgress.stream()
.filter(t -> t.getMainComponentUuid().equals(mainComponentUuid))
- .collect(toList());
+ .toList();
//we can peek branch analysis task only if all the other in progress tasks for this component uuid are pull requests
return sameComponentTasks.stream().map(PrOrBranchTask::getBranchType).allMatch(s -> Objects.equals(s, PULL_REQUEST));
}
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
List<String> branchUuids = session.getMapper(BranchMapper.class).selectByProjectUuid(uuid).stream()
.map(BranchDto::getUuid)
.filter(branchUuid -> !uuid.equals(branchUuid))
- .collect(Collectors.toList());
+ .toList();
branchUuids.forEach(id -> deleteRootComponent(id, purgeMapper, purgeCommands));
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
-import java.util.stream.Collectors;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleQuery;
import org.sonar.core.util.UuidFactory;
List<String> templateRuleUuids = ruleDtos.stream()
.map(RuleDto::getTemplateUuid)
.filter(Objects::nonNull)
- .collect(Collectors.toList());
+ .toList();
Map<String, RuleDto> templateDtos = findTemplateDtos(mapper, templateRuleUuids);
ruleDtos.stream().map(r -> toRuleForIndexingDto(r, templateDtos)).forEach(consumer);
return logins.stream()
.map(new LoginToUser(unordered))
.filter(Objects::nonNull)
- .collect(Collectors.toList());
+ .toList();
}
public List<UserDto> selectUsers(DbSession dbSession, UserQuery query) {
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
-import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;
FileSourceDto fileSource = db.fileSources().insertFileSource(file);
return new ComponentAndSource(file, fileSource);
})
- .collect(Collectors.toList());
+ .toList();
RecordingResultHandler resultHandler = new RecordingResultHandler();
underTest.scrollAllFilesForFileMove(dbSession, project.uuid(), resultHandler);
.mapToObj(j -> db.components().insertSnapshot(project));
})
.flatMap(t -> t)
- .collect(toList());
+ .toList();
assertThat(underTest.selectAnalysesByQuery(db.getSession(), new SnapshotQuery()))
.extracting(SnapshotDto::getUuid)
ComponentDto project2 = db.components().insertPrivateProject();
List<SnapshotDto> snapshots1 = IntStream.range(0, 1 + random.nextInt(20))
.mapToObj(j -> db.components().insertSnapshot(project1))
- .collect(toList());
+ .toList();
List<SnapshotDto> snapshots2 = IntStream.range(0, 1 + random.nextInt(20))
.mapToObj(j -> db.components().insertSnapshot(project2))
- .collect(toList());
+ .toList();
assertThat(underTest.selectAnalysesByQuery(db.getSession(), new SnapshotQuery().setComponentUuid(project1.uuid())))
.extracting(SnapshotDto::getUuid)
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
List<EventDto> events = IntStream.range(0, 1 + new Random().nextInt(10))
.mapToObj(i -> dbTester.events().insertEvent(newEvent(analysis).setCategory("cat_" + i)))
- .collect(toList());
+ .toList();
List<EventDto> dtos = underTest.selectByComponentUuid(dbTester.getSession(), project.uuid());
assertThat(dtos)
import java.util.Collections;
import java.util.List;
import java.util.Random;
-import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.junit.Rule;
import org.junit.Test;
public void find_all_enabled() {
List<MetricDto> enabledMetrics = IntStream.range(0, 1 + new Random().nextInt(10))
.mapToObj(i -> MetricTesting.newMetricDto().setEnabled(true))
- .collect(Collectors.toList());
+ .toList();
List<MetricDto> disabledMetrics = IntStream.range(0, 1 + new Random().nextInt(10))
.mapToObj(i -> MetricTesting.newMetricDto().setEnabled(false))
- .collect(Collectors.toList());
+ .toList();
List<MetricDto> all = new ArrayList<>(enabledMetrics);
all.addAll(disabledMetrics);
public void find_all() {
List<MetricDto> enabledMetrics = IntStream.range(0, 1 + new Random().nextInt(10))
.mapToObj(i -> MetricTesting.newMetricDto().setEnabled(true))
- .collect(Collectors.toList());
+ .toList();
List<MetricDto> disabledMetrics = IntStream.range(0, 1 + new Random().nextInt(10))
.mapToObj(i -> MetricTesting.newMetricDto().setEnabled(false))
- .collect(Collectors.toList());
+ .toList();
List<MetricDto> all = new ArrayList<>(enabledMetrics);
all.addAll(disabledMetrics);
@Test
public void keepAuthorizedProjectUuids_should_be_able_to_handle_lots_of_projects() {
- List<ComponentDto> projects = IntStream.range(0, 2000).mapToObj(i -> db.components().insertPublicProject()).collect(Collectors.toList());
+ List<ComponentDto> projects = IntStream.range(0, 2000).mapToObj(i -> db.components().insertPublicProject()).toList();
Collection<String> uuids = projects.stream().map(ComponentDto::uuid).collect(Collectors.toSet());
assertThat(underTest.keepAuthorizedProjectUuids(dbSession, uuids, null, UserRole.USER))
@Test
public void keepAuthorizedUsersForRoleAndProject_should_be_able_to_handle_lots_of_users() {
- List<UserDto> users = IntStream.range(0, 2000).mapToObj(i -> db.users().insertUser()).collect(Collectors.toList());
+ List<UserDto> users = IntStream.range(0, 2000).mapToObj(i -> db.users().insertUser()).toList();
assertThat(underTest.keepAuthorizedUsersForRoleAndProject(dbSession,
users.stream().map(UserDto::getUuid).collect(Collectors.toSet()), "user", PROJECT_UUID)).isEmpty();
dbTester.fileSources().insertFileSource(file);
return file;
})
- .collect(Collectors.toList());
+ .toList();
Map<String, FileHashesDto> fileSourcesByUuid = new HashMap<>();
underTest.scrollFileHashesByProjectUuid(dbSession, project.branchUuid(), result -> fileSourcesByUuid.put(result.getResultObject().getFileUuid(), result.getResultObject()));
dbTester.fileSources().insertFileSource(file);
return file;
})
- .collect(Collectors.toList());
+ .toList();
LineHashesWithKeyDtoHandler handler = new LineHashesWithKeyDtoHandler();
underTest.scrollLineHashes(dbSession, files.stream().map(ComponentDto::uuid).collect(Collectors.toSet()), handler);
package org.sonar.db.webhook;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.core.util.Uuids;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
return dbTester.select(dbSession, "select uuid as \"uuid\" from webhook_deliveries")
.stream()
.map(columns -> (String) columns.get("uuid"))
- .collect(Collectors.toList());
+ .toList();
}
}
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
// Example of row:
// issues | kee | Latin1_General_CS_AS or Latin1_General_100_CI_AS_KS_WS
List<ColumnDef> columns = metadata.getColumnDefs(connection);
- for (ColumnDef column : columns.stream().filter(ColumnDef::isInSonarQubeTable).collect(Collectors.toList())) {
+ for (ColumnDef column : columns.stream().filter(ColumnDef::isInSonarQubeTable).toList()) {
String collation = column.getCollation();
if (!isCollationCorrect(collation)) {
repairColumnCollation(connection, column, toCaseSensitive(collation));
import com.google.common.collect.Lists;
import java.util.List;
import java.util.Objects;
-import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkState;
import static java.lang.String.format;
public AddPrimaryKeyBuilder(String tableName, String column, String... moreColumns) {
this.tableName = validateTableName(tableName);
- this.primaryKey = Lists.asList(column, moreColumns).stream().filter(Objects::nonNull).collect(Collectors.toList());
+ this.primaryKey = Lists.asList(column, moreColumns).stream().filter(Objects::nonNull).toList();
}
public String build() {
sql.add(sb.toString());
}
- List<Column> notNullColumns = columns.stream().filter(c -> !c.definition().isNullable()).collect(Collectors.toList());
+ List<Column> notNullColumns = columns.stream().filter(c -> !c.definition().isNullable()).toList();
for (Column c : notNullColumns) {
sql.addAll(new AlterColumnsBuilder(dialect, tableName).updateColumn(c.definition()).build());
}
import java.util.ArrayList;
import java.util.List;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import org.sonar.db.dialect.Dialect;
import org.sonar.db.dialect.H2;
default:
throw new IllegalArgumentException("Unsupported dialect id " + dialect.getId());
}
- }).collect(Collectors.toList());
+ }).toList();
}
private static class Renaming implements ColumnDef {
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.xml.XMLConstants;
private static List<String> findConsistencyErrors(Collection<ViewDef> portfolios, Map<String, PortfolioDb> portfolioDbMap) {
return portfolios.stream()
.flatMap(portfolio -> findConsistencyErrors(portfolio, portfolioDbMap).stream())
- .collect(Collectors.toList());
+ .toList();
}
private static List<String> findConsistencyErrors(ViewDef portfolio, Map<String, PortfolioDb> portfolioDbMap) {
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.process.MessageException;
public T addFromMandatoryProperty(Props props, String propertyName) {
String value = props.nonNullValue(propertyName);
if (!value.isEmpty()) {
- List<String> jvmOptions = Arrays.stream(value.split(" (?=-)")).map(String::trim).collect(Collectors.toList());
+ List<String> jvmOptions = Arrays.stream(value.split(" (?=-)")).map(String::trim).toList();
checkOptionFormat(propertyName, jvmOptions);
checkMandatoryOptionOverwrite(propertyName, jvmOptions);
options.addAll(jvmOptions);
private static void checkOptionFormat(String propertyName, List<String> jvmOptionsFromProperty) {
List<String> invalidOptions = jvmOptionsFromProperty.stream()
.filter(JvmOptions::isInvalidOption)
- .collect(Collectors.toList());
+ .toList();
if (!invalidOptions.isEmpty()) {
throw new MessageException(format(
"a JVM option can't be empty and must start with '-'. The following JVM options defined by property '%s' are invalid: %s",
List<Match> matches = jvmOptionsFromProperty.stream()
.map(jvmOption -> new Match(jvmOption, mandatoryOptionFor(jvmOption)))
.filter(match -> match.getMandatoryOption() != null)
- .collect(Collectors.toList());
+ .toList();
if (!matches.isEmpty()) {
throw new MessageException(format(
"a JVM option can't overwrite mandatory JVM options. The following JVM options defined by property '%s' are invalid: %s",
import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.joining;
-import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static org.sonar.process.ProcessProperties.Property.AUTH_JWT_SECRET;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_ENABLED;
.map(AddressAndPort::getHost)
.filter(t -> !network.toInetAddress(t).isPresent())
.sorted()
- .collect(toList());
+ .toList();
if (!invalidHosts.isEmpty()) {
throw new MessageException(format("Address in property %s is not a valid address: %s",
property.getKey(), String.join(", ", invalidHosts)));
List<String> violations = FORBIDDEN_SEARCH_NODE_SETTINGS.stream()
.filter(setting -> props.value(setting.getKey()) != null)
.map(Property::getKey)
- .collect(toList());
+ .toList();
if (!violations.isEmpty()) {
throw new MessageException(format("Properties [%s] are not allowed when running SonarQube in cluster mode.", String.join(", ", violations)));
import com.hazelcast.config.NetworkConfig;
import com.hazelcast.core.Hazelcast;
import java.util.List;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.sonar.process.ProcessId;
import org.sonar.process.cluster.hz.HazelcastMember.Attribute;
.filter(host -> !host.isBlank())
.map(String::trim)
.map(HazelcastMemberBuilder::applyDefaultPortToHost)
- .collect(Collectors.toList());
+ .toList();
joinConfig.getTcpIpConfig().setEnabled(true);
joinConfig.getTcpIpConfig().setMembers(requireNonNull(addressesWithDefaultPorts, "Members are missing"));
}
.filter(loggerName -> !ROOT_LOGGER_NAME.equals(loggerName))
.distinct()
.sorted()
- .collect(Collectors.toList());
+ .toList();
if (!loggerNames.isEmpty()) {
putProperty("loggers", loggerNames.stream().collect(Collectors.joining(",")));
}
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.sonar.process.ProcessId;
private void levelByProperty(String loggerName, String property, String... otherProperties) {
ensureUniqueConfiguration(loggerName);
- configuredByProperties.put(loggerName, Stream.concat(Stream.of(property), Arrays.stream(otherProperties)).collect(Collectors.toList()));
+ configuredByProperties.put(loggerName, Stream.concat(Stream.of(property), Arrays.stream(otherProperties)).toList());
}
/**
return Arrays.stream(config.getStringArray(CLUSTER_SEARCH_HOSTS.getKey()))
.map(HostAndPort::fromString)
.map(EsClientProvider::toHttpHost)
- .collect(Collectors.toList());
+ .toList();
}
private static HttpHost toHttpHost(HostAndPort host) {
package org.sonar.server.es;
import java.util.Collection;
-import java.util.stream.Collectors;
import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
default void commitAndIndexBranches(DbSession dbSession, Collection<BranchDto> branches, ProjectIndexer.Cause cause) {
Collection<String> branchUuids = branches.stream()
.map(BranchDto::getUuid)
- .collect(Collectors.toList());
+ .toList();
commitAndIndexByProjectUuids(dbSession, branchUuids, cause);
}
}
import java.util.Optional;
import java.util.Set;
import java.util.function.BiPredicate;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
List<QueryBuilder> selectQueryBuilders = queryFilters.entrySet().stream()
.filter(e -> predicate.test(e.getKey(), e.getValue()))
.map(Map.Entry::getValue)
- .collect(Collectors.toList());
+ .toList();
if (selectQueryBuilders.isEmpty()) {
return empty();
}
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;
import org.sonar.api.config.Configuration;
import org.sonar.api.rules.RuleType;
private List<IssueDto> filterTaintIssues(List<IssueDto> issues, boolean returnTaint) {
return issues.stream()
.filter(getTaintIssueFilter(returnTaint))
- .collect(Collectors.toList());
+ .toList();
}
@NotNull
return repositories;
}
- repositories.addAll(Arrays.stream(config.getStringArray(EXTRA_TAINT_REPOSITORIES)).collect(Collectors.toList()));
+ repositories.addAll(Arrays.stream(config.getStringArray(EXTRA_TAINT_REPOSITORIES)).toList());
return repositories;
}
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import org.sonar.api.issue.Issue;
return Arrays.stream(outTransitions)
.filter(transition -> !transition.automatic())
.filter(transition -> transition.supports(issue))
- .collect(Collectors.toList());
+ .toList();
}
@CheckForNull
List<Transition> transitions = Arrays.stream(outTransitions)
.filter(Transition::automatic)
.filter(t -> t.supports(issue))
- .collect(Collectors.toList());
+ .toList();
if(transitions.size() > 1){
throw new IllegalArgumentException("Several automatic transitions are available for issue: " + issue);
}
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.sonar.api.measures.Metric;
import org.sonar.db.DbClient;
public Collection<Metric> findAll(List<String> metricKeys) {
try (DbSession session = dbClient.openSession(false)) {
List<MetricDto> dtos = dbClient.metricDao().selectByKeys(session, metricKeys);
- return dtos.stream().filter(IsEnabled.INSTANCE).map(ToMetric.INSTANCE).collect(Collectors.toList());
+ return dtos.stream().filter(IsEnabled.INSTANCE).map(ToMetric.INSTANCE).toList();
}
}
public Collection<Metric> findAll() {
try (DbSession session = dbClient.openSession(false)) {
List<MetricDto> dtos = dbClient.metricDao().selectEnabled(session);
- return dtos.stream().map(ToMetric.INSTANCE).collect(Collectors.toList());
+ return dtos.stream().map(ToMetric.INSTANCE).toList();
}
}
import java.util.Arrays;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.api.Startable;
import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.server.ServerSide;
public ProcessInfoProvider(SystemInfoSection[] sections) {
this.sections = Arrays.stream(sections)
.filter(section -> !(section instanceof Global))
- .collect(Collectors.toList());
+ .toList();
}
@Override
import java.util.Comparator;
import java.util.Map;
import java.util.SortedSet;
-import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import javax.annotation.concurrent.Immutable;
import org.sonar.api.utils.text.JsonWriter;
jsonProfile.get("name").getAsString(),
jsonProfile.get("language").getAsString(),
UtcDateUtils.parseDateTime(jsonProfile.get("rulesUpdatedAt").getAsString()));
- }).collect(Collectors.toList()));
+ }).toList());
}
public static String toJson(QPMeasureData data) {
import java.util.Date;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.sonar.api.rule.RuleKey;
private Collection<org.sonar.api.rules.Rule> convertToRuleApi(DbSession dbSession, List<RuleDto> ruleDtos) {
List<org.sonar.api.rules.Rule> rules = new ArrayList<>();
- List<RuleKey> ruleKeys = ruleDtos.stream().map(RuleDto::getKey).collect(Collectors.toList());
+ List<RuleKey> ruleKeys = ruleDtos.stream().map(RuleDto::getKey).toList();
List<RuleParamDto> ruleParamDtos = ruleDao.selectRuleParamsByRuleKeys(dbSession, ruleKeys);
ImmutableListMultimap<String, RuleParamDto> ruleParamByRuleUuid = FluentIterable.from(ruleParamDtos).index(RuleParamDtoToRuleUuid.INSTANCE);
for (RuleDto rule : ruleDtos) {
"6.3.2", "6.4.1", "6.4.2", "7.1.3", "7.1.4", "7.2.1", "7.2.2", "7.3.1", "7.3.2", "7.3.3", "7.3.4", "7.4.2", "7.4.3", "8.1.1", "8.1.2", "8.1.3", "8.1.4", "8.3.5", "8.3.6",
"8.3.7", "8.3.8", "9.2.1", "9.2.2", "9.2.3", "9.2.4", "10.2.1", "10.2.2", "11.1.6", "11.1.7", "11.1.8", "12.1.2", "12.1.3", "12.2.1", "12.3.6", "13.1.4", "13.1.5", "13.2.4",
"13.2.5", "13.2.6", "13.3.2", "13.4.1", "13.4.2", "14.1.1", "14.1.2", "14.1.3", "14.1.4", "14.2.4", "14.2.5", "14.2.6", "14.5.4"), OWASP_ASVS_40_LEVEL_1.stream())
- .collect(Collectors.toList()));
+ .toList());
public static final List<String> OWASP_ASVS_40_LEVEL_3 = Collections.unmodifiableList(Stream
.concat(Stream.of("1.11.3", "2.2.4", "2.2.5", "2.2.6", "2.2.7", "2.8.7", "3.6.1", "3.6.2", "6.2.7", "6.2.8", "6.3.3", "8.1.5",
"8.1.6", "9.2.5", "10.1.1", "10.2.3", "10.2.4", "10.2.5", "10.2.6", "14.1.5"), OWASP_ASVS_40_LEVEL_2.stream())
- .collect(Collectors.toList()));
+ .toList());
public static final Map<Integer, List<String>> OWASP_ASVS_40_REQUIREMENTS_BY_LEVEL = Map.of(
1, OWASP_ASVS_40_LEVEL_1,
.put(SQCategory.TRACEABILITY, Set.of("778"))
.put(SQCategory.PERMISSION, Set.of("266", "269", "284", "668", "732"))
.build();
- private static final Ordering<SQCategory> SQ_CATEGORY_ORDERING = Ordering.explicit(stream(SQCategory.values()).collect(Collectors.toList()));
- public static final Ordering<String> SQ_CATEGORY_KEYS_ORDERING = Ordering.explicit(stream(SQCategory.values()).map(SQCategory::getKey).collect(Collectors.toList()));
+ private static final Ordering<SQCategory> SQ_CATEGORY_ORDERING = Ordering.explicit(stream(SQCategory.values()).toList());
+ public static final Ordering<String> SQ_CATEGORY_KEYS_ORDERING = Ordering.explicit(stream(SQCategory.values()).map(SQCategory::getKey).toList());
private final Set<String> standards;
private final Set<String> cwe;
import java.net.SocketException;
import java.util.Collections;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.server.ServerSide;
return Collections.list(NetworkInterface.getNetworkInterfaces())
.stream()
.flatMap(ni -> Collections.list(ni.getInetAddresses()).stream())
- .collect(Collectors.toList());
+ .toList();
}
}
import org.sonar.server.es.newindex.TestNewIndex;
import org.sonar.server.es.newindex.TypeMapping;
-import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_ENABLED;
consumer.accept(mainTypeMapping.getMainTypeMapping());
return mainTypeMapping;
})
- .collect(toList());
+ .toList();
List<TestNewIndex> relationIndices = fieldTypes1.stream()
.map(consumer -> {
TestNewIndex relationTypeMapping = new TestNewIndex(mainType, settingsConfiguration);
consumer.accept(relationTypeMapping.createRelationMapping("donut"));
return relationTypeMapping;
})
- .collect(toList());
+ .toList();
Set<String> mainHashes = mainIndices.stream()
.map(IndexDefinitionHashTest::hashOf)
consumer.accept(mainTypeMapping.getMainTypeMapping());
return mainTypeMapping;
})
- .collect(toList());
+ .toList();
List<TestNewIndex> relationIndices = Arrays.stream(fieldTypes)
.map(consumer -> {
TestNewIndex relationTypeMapping = new TestNewIndex(mainType, settingsConfiguration);
consumer.accept(relationTypeMapping.createRelationMapping("donut"));
return relationTypeMapping;
})
- .collect(toList());
+ .toList();
Set<String> mainHashes = mainIndices.stream()
.map(IndexDefinitionHashTest::hashOf)
import java.util.List;
import java.util.Optional;
import java.util.Random;
-import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import javax.annotation.CheckForNull;
@Test
public void add_counts_issue_per_component_on_current_analysis_globally_and_per_assignee() {
- List<String> componentUuids = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).collect(Collectors.toList());
+ List<String> componentUuids = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).toList();
String assignee = randomAlphanumeric(10);
componentUuids.stream()
.map(componentUuid -> new DefaultIssue().setType(randomRuleTypeExceptHotspot).setComponentUuid(componentUuid).setAssigneeUuid(assignee).setNew(true))
@Test
public void add_counts_issue_per_component_off_current_analysis_globally_and_per_assignee() {
- List<String> componentUuids = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).collect(Collectors.toList());
+ List<String> componentUuids = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).toList();
String assignee = randomAlphanumeric(10);
componentUuids.stream()
.map(componentUuid -> new DefaultIssue().setType(randomRuleTypeExceptHotspot).setComponentUuid(componentUuid).setAssigneeUuid(assignee).setNew(false))
@Test
public void add_counts_issue_per_ruleKey_on_current_analysis_globally_and_per_assignee() {
String repository = randomAlphanumeric(3);
- List<String> ruleKeys = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).collect(Collectors.toList());
+ List<String> ruleKeys = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).toList();
String assignee = randomAlphanumeric(10);
ruleKeys.stream()
.map(ruleKey -> new DefaultIssue().setType(randomRuleTypeExceptHotspot).setRuleKey(RuleKey.of(repository, ruleKey)).setAssigneeUuid(assignee).setNew(true))
@Test
public void add_counts_issue_per_ruleKey_off_current_analysis_globally_and_per_assignee() {
String repository = randomAlphanumeric(3);
- List<String> ruleKeys = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).collect(Collectors.toList());
+ List<String> ruleKeys = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).toList();
String assignee = randomAlphanumeric(10);
ruleKeys.stream()
.map(ruleKey -> new DefaultIssue().setType(randomRuleTypeExceptHotspot).setRuleKey(RuleKey.of(repository, ruleKey)).setAssigneeUuid(assignee).setNew(false))
@Test
public void add_counts_issue_per_assignee_on_current_analysis_globally_and_per_assignee() {
- List<String> assignees = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).collect(Collectors.toList());
+ List<String> assignees = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).toList();
assignees.stream()
.map(assignee -> new DefaultIssue().setType(randomRuleTypeExceptHotspot).setAssigneeUuid(assignee).setNew(true))
.forEach(underTest::add);
@Test
public void add_counts_issue_per_assignee_off_current_analysis_globally_and_per_assignee() {
- List<String> assignees = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).collect(Collectors.toList());
+ List<String> assignees = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).toList();
assignees.stream()
.map(assignee -> new DefaultIssue().setType(randomRuleTypeExceptHotspot).setAssigneeUuid(assignee).setNew(false))
.forEach(underTest::add);
@Test
public void add_counts_issue_per_tags_on_current_analysis_globally_and_per_assignee() {
- List<String> tags = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).collect(Collectors.toList());
+ List<String> tags = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).toList();
String assignee = randomAlphanumeric(10);
underTest.add(new DefaultIssue().setType(randomRuleTypeExceptHotspot).setTags(tags).setAssigneeUuid(assignee).setNew(true));
@Test
public void add_counts_issue_per_tags_off_current_analysis_globally_and_per_assignee() {
- List<String> tags = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).collect(Collectors.toList());
+ List<String> tags = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> randomAlphabetic(3)).toList();
String assignee = randomAlphanumeric(10);
underTest.add(new DefaultIssue().setType(randomRuleTypeExceptHotspot).setTags(tags).setAssigneeUuid(assignee).setNew(false));
@Test
public void add_sums_effort_on_current_analysis_globally_and_per_assignee() {
Random random = new Random();
- List<Integer> efforts = IntStream.range(0, 1 + random.nextInt(10)).mapToObj(i -> 10_000 * i).collect(Collectors.toList());
+ List<Integer> efforts = IntStream.range(0, 1 + random.nextInt(10)).mapToObj(i -> 10_000 * i).toList();
int expected = efforts.stream().mapToInt(s -> s).sum();
String assignee = randomAlphanumeric(10);
efforts.stream()
@Test
public void add_sums_effort_off_current_analysis_globally_and_per_assignee() {
Random random = new Random();
- List<Integer> efforts = IntStream.range(0, 1 + random.nextInt(10)).mapToObj(i -> 10_000 * i).collect(Collectors.toList());
+ List<Integer> efforts = IntStream.range(0, 1 + random.nextInt(10)).mapToObj(i -> 10_000 * i).toList();
int expected = efforts.stream().mapToInt(s -> s).sum();
String assignee = randomAlphanumeric(10);
efforts.stream()
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang.reflect.ConstructorUtils;
import org.apache.http.HttpHost;
return getDocuments(indexType)
.stream()
.map(input -> (T) input.getSourceAsMap().get(fieldNameToReturn))
- .collect(Collectors.toList());
+ .toList();
}
public List<String> getIds(IndexType indexType) {
- return getDocuments(indexType).stream().map(SearchHit::getId).collect(Collectors.toList());
+ return getDocuments(indexType).stream().map(SearchHit::getId).toList();
}
public void lockWrites(IndexType index) {
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
-import java.util.stream.Collectors;
import javax.inject.Inject;
import org.apache.commons.io.FileUtils;
import org.sonar.api.SonarRuntime;
import static java.lang.String.format;
import static org.apache.commons.io.FileUtils.moveFile;
-import static org.sonar.core.util.FileUtils.deleteQuietly;
-import static org.sonar.server.log.ServerProcessLogging.STARTUP_LOGGER_NAME;
import static org.sonar.core.plugin.PluginType.BUNDLED;
import static org.sonar.core.plugin.PluginType.EXTERNAL;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
+import static org.sonar.server.log.ServerProcessLogging.STARTUP_LOGGER_NAME;
public class PluginJarLoader {
private static final Logger LOG = Loggers.get(PluginJarLoader.class);
List<T> list = listJarFiles(pluginsDir).stream()
.map(toPluginInfo)
.filter(this::checkPluginInfo)
- .collect(Collectors.toList());
+ .toList();
failIfContainsIncompatiblePlugins(list);
return list;
}
.filter(p -> FORBIDDEN_INCOMPATIBLE_PLUGINS.contains(p.getKey()))
.map(p -> "'" + p.getKey() + "'")
.sorted()
- .collect(Collectors.toList());
+ .toList();
if (!incompatiblePlugins.isEmpty()) {
logGenericPluginLoadErrorLog();
}
private Collection<ExplodedPlugin> extractPlugins(Collection<ServerPluginInfo> plugins) {
- return plugins.stream().map(pluginJarExploder::explode).collect(Collectors.toList());
+ return plugins.stream().map(pluginJarExploder::explode).toList();
}
private static List<ServerPlugin> createServerPlugins(Collection<ExplodedPlugin> explodedPlugins, Map<String, Plugin> instancesByKey, Map<String, PluginType> typesByKey) {
.stream()
.filter(p -> p.getType() == type)
.map(ServerPlugin::getPluginInfo)
- .collect(Collectors.toList());
+ .toList();
}
@Override
public Collection<Plugin> getPluginInstances() {
return pluginByKey.values().stream()
.map(ServerPlugin::getInstance)
- .collect(Collectors.toList());
+ .toList();
}
@Override
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.server.authentication.IdentityProvider;
return providersByKey.values().stream()
.filter(IS_ENABLED_FILTER)
.sorted(Comparator.comparing(TO_NAME))
- .collect(Collectors.toList());
+ .toList();
}
}
import org.sonar.api.web.UserRole;
import org.sonar.db.permission.GlobalPermission;
-import static java.util.stream.Collectors.toList;
-
@Immutable
public class PermissionServiceImpl implements PermissionService {
private static final List<String> ALL_PROJECT_PERMISSIONS = List.of(
globalPermissions = List.copyOf(ALL_GLOBAL_PERMISSIONS.stream()
.filter(s -> !s.equals(GlobalPermission.APPLICATION_CREATOR) || resourceTypes.isQualifierPresent(Qualifiers.APP))
.filter(s -> !s.equals(GlobalPermission.PORTFOLIO_CREATOR) || resourceTypes.isQualifierPresent(Qualifiers.VIEW))
- .collect(toList()));
+ .toList());
projectPermissions = List.copyOf(ALL_PROJECT_PERMISSIONS.stream()
.filter(s -> !s.equals(GlobalPermission.APPLICATION_CREATOR.getKey()) || resourceTypes.isQualifierPresent(Qualifiers.APP))
.filter(s -> !s.equals(GlobalPermission.PORTFOLIO_CREATOR.getKey()) || resourceTypes.isQualifierPresent(Qualifiers.VIEW))
- .collect(toList()));
+ .toList());
}
/**
return projects.stream()
.filter(project -> authorizedProjectsUuids.contains(project.getUuid()))
- .collect(toList());
+ .toList();
}
private Set<String> keepProjectsUuidsByPermission(String permission, Collection<String> projectsUuids) {
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.junit.Before;
import org.junit.Rule;
}
private void checkGroupMembership(UserDto user, GroupDto... expectedGroups) {
- assertThat(db.users().selectGroupUuidsOfUser(user)).containsOnly(stream(expectedGroups).map(GroupDto::getUuid).collect(Collectors.toList()).toArray(new String[]{}));
+ assertThat(db.users().selectGroupUuidsOfUser(user)).containsOnly(stream(expectedGroups).map(GroupDto::getUuid).toList().toArray(new String[]{}));
}
private GroupDto insertDefaultGroup() {
List<String> uuids = ceQueueDtos.stream()
.filter(p -> p.getTaskType().equals(BRANCH_ISSUE_SYNC))
.map(CeQueueDto::getUuid)
- .collect(Collectors.toList());
+ .toList();
LOG.info(String.format("%s pending indexation task found to be deleted...", uuids.size()));
for (String uuid : uuids) {
import java.util.Arrays;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.api.server.ServerSide;
import org.sonar.process.systeminfo.Global;
import org.sonar.process.systeminfo.SystemInfoSection;
public GlobalInfoLoader(SystemInfoSection[] sections) {
this.globalSections = Arrays.stream(sections)
.filter(section -> section instanceof Global)
- .collect(Collectors.toList());
+ .toList();
}
public List<ProtobufSystemInfo.Section> load() {
return globalSections.stream()
.map(SystemInfoSection::toProtobuf)
- .collect(Collectors.toList());
+ .toList();
}
}
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.rule.Severity;
private static List<Language> getActiveLanguages(Language[] allLanguages) {
return Arrays.stream(allLanguages)
.filter(Predicate.not(language -> LANGUAGES_TO_SKIP.contains(language.getKey())))
- .collect(Collectors.toList());
+ .toList();
}
private static void defineBranchCoverageRule(RulesDefinition.NewRepository repo) {
}
public Builder setQualifiers(Stream<ComponentHitsPerQualifier> qualifiers) {
- this.qualifiers = qualifiers.collect(Collectors.toList());
+ this.qualifiers = qualifiers.toList();
return this;
}
return Arrays.stream(client.getIndex(new GetIndexRequest("_all")).getIndices())
.filter(definedNames::contains)
.filter(index -> !DESCRIPTOR.getName().equals(index))
- .collect(Collectors.toList());
+ .toList();
}
}
.filter(categoryBucket -> StringUtils.startsWith(categoryBucket.getKeyAsString(), categoryFilter.getName() + "."))
.filter(categoryBucket -> level == null || OWASP_ASVS_40_REQUIREMENTS_BY_LEVEL.get(level).contains(categoryBucket.getKeyAsString()))
.map(categoryBucket -> processSecurityReportCategorySearchResults(categoryBucket, categoryBucket.getKeyAsString(), null, null))
- .collect(toList());
+ .toList();
return processSecurityReportCategorySearchResults(categoryFilter, categoryFilter.getName(), children, version);
}
List<SecurityStandardCategoryStatistics> children = list.stream()
.filter(categoryBucket -> OWASP_ASVS_40_REQUIREMENTS_BY_LEVEL.get(Integer.parseInt(level)).contains(categoryBucket.getKeyAsString()))
.map(categoryBucket -> processSecurityReportCategorySearchResults(categoryBucket, categoryBucket.getKeyAsString(), null, null))
- .collect(toList());
+ .toList();
return processSecurityReportCategorySearchResults(categoryFilter, categoryFilter.getName(), children, version);
}
.map(indexTypeByFormat::get)
.filter(Objects::nonNull)
.map(indexType -> new BulkIndexer(esClient, indexType, Size.REGULAR, new OneToOneResilientIndexingListener(dbClient, dbSession, items)))
- .collect(Collectors.toList());
+ .toList();
if (bulkIndexers.isEmpty()) {
return result;
import java.util.Arrays;
import java.util.List;
-import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.junit.Rule;
import org.junit.Test;
public void paginate_results() {
List<ComponentDto> projects = IntStream.range(0, 9)
.mapToObj(i -> db.components().insertPrivateProject(p -> p.setName("project " + i)))
- .collect(Collectors.toList());
+ .toList();
index(projects.toArray(new ComponentDto[0]));
SearchIdResult<String> result = underTest.search(ComponentQuery.builder().build(), new SearchOptions().setPage(2, 3));
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
-import java.util.stream.Collectors;
import org.assertj.core.api.ListAssert;
import org.junit.Rule;
import org.sonar.api.utils.System2;
List<ComponentDto> files = Arrays.stream(resultsInOrder)
.map(r -> ComponentTesting.newFileDto(project).setName(r))
.peek(f -> f.setUuid(f.uuid() + "_" + f.name().replaceAll("[^a-zA-Z0-9]", "")))
- .collect(Collectors.toList());
+ .toList();
// index them, but not in the expected order
files.stream()
List<SecurityStandardCategoryStatistics> owaspAsvsReportGroupedByLevel = new ArrayList<>();
owaspAsvsReportGroupedByLevel.addAll(underTest.getOwaspAsvsReportGroupedByLevel(project.uuid(), false, OwaspAsvsVersion.V4_0, 1).stream()
.sorted(comparing(s -> parseInt(s.getCategory())))
- .collect(toList()));
+ .toList());
owaspAsvsReportGroupedByLevel.addAll(underTest.getOwaspAsvsReportGroupedByLevel(project.uuid(), false, OwaspAsvsVersion.V4_0, 2).stream()
.sorted(comparing(s -> parseInt(s.getCategory())))
- .collect(toList()));
+ .toList());
owaspAsvsReportGroupedByLevel.addAll(underTest.getOwaspAsvsReportGroupedByLevel(project.uuid(), false, OwaspAsvsVersion.V4_0, 3).stream()
.sorted(comparing(s -> parseInt(s.getCategory())))
- .collect(toList()));
+ .toList());
assertThat(owaspAsvsReportGroupedByLevel)
.extracting(SecurityStandardCategoryStatistics::getCategory, SecurityStandardCategoryStatistics::getVulnerabilities,
import org.sonar.server.es.EsTester;
import static java.util.Arrays.stream;
-import static java.util.stream.Collectors.toList;
public class PermissionIndexerTester {
}
public PermissionIndexerTester allowOnlyAnyone(ComponentDto... projects) {
- return allow(stream(projects).map(project -> new IndexPermissions(project.uuid(), project.qualifier()).allowAnyone()).collect(toList()));
+ return allow(stream(projects).map(project -> new IndexPermissions(project.uuid(), project.qualifier()).allowAnyone()).toList());
}
public PermissionIndexerTester allowOnlyUser(ComponentDto project, UserDto user) {
}
public PermissionIndexerTester allow(IndexPermissions... indexPermissions) {
- return allow(stream(indexPermissions).collect(toList()));
+ return allow(stream(indexPermissions).toList());
}
public PermissionIndexerTester allow(List<IndexPermissions> indexPermissions) {
Collection<String> componentUuids = recentSuccessfulTasks.stream()
.map(CeActivityDto::getMainComponentUuid)
- .collect(Collectors.toList());
+ .toList();
List<ComponentDto> componentDtos = dbClient.componentDao().selectByUuids(dbSession, componentUuids);
Map<String, String> componentUuidAndKeys = componentDtos.stream()
.collect(Collectors.toMap(ComponentDto::uuid, ComponentDto::getKey));
List<CeActivityDto> recentTasks = dbClient.ceActivityDao().selectNewerThan(dbSession, lastUpdatedTimestamp);
return recentTasks.stream()
.filter(c -> c.getStatus() == CeActivityDto.Status.SUCCESS)
- .collect(Collectors.toList());
+ .toList();
}
private void reportObservedDurationForTasks(List<CeActivityDto> tasks, Map<String, String> componentUuidAndKeys) {
try (DbSession dbSession = dbClient.openSession(false)) {
List<OrgActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByProfile(dbSession, profileDto);
- List<String> activeRuleUuids = activeRuleDtos.stream().map(ActiveRuleDto::getUuid).collect(Collectors.toList());
+ List<String> activeRuleUuids = activeRuleDtos.stream().map(ActiveRuleDto::getUuid).toList();
Map<String, List<ActiveRuleParamDto>> paramsByActiveRuleUuid = dbClient.activeRuleDao().selectParamsByActiveRuleUuids(dbSession, activeRuleUuids)
.stream().collect(Collectors.groupingBy(ActiveRuleParamDto::getActiveRuleUuid));
Map<String, String> activeRuleUuidByRuleUuid = activeRuleDtos.stream().collect(Collectors.toMap(ActiveRuleDto::getRuleUuid, ActiveRuleDto::getUuid));
- List<String> ruleUuids = activeRuleDtos.stream().map(ActiveRuleDto::getRuleUuid).collect(Collectors.toList());
+ List<String> ruleUuids = activeRuleDtos.stream().map(ActiveRuleDto::getRuleUuid).toList();
List<RuleDto> ruleDtos = dbClient.ruleDao().selectByUuids(dbSession, ruleUuids);
for (RuleDto ruleDto : ruleDtos) {
try (DbSession dbSession = dbClient.openSession(false)) {
List<OrgActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByProfile(dbSession, profileDto);
- List<String> ruleUuids = activeRuleDtos.stream().map(ActiveRuleDto::getRuleUuid).collect(Collectors.toList());
+ List<String> ruleUuids = activeRuleDtos.stream().map(ActiveRuleDto::getRuleUuid).toList();
List<RuleDto> ruleDtos = dbClient.ruleDao().selectByUuids(dbSession, ruleUuids);
for (RuleDto ruleDto : ruleDtos) {
.stream()
.map(profile -> getQualityProfileAssociatedProjects(dbSession, profile))
.flatMap(Collection::stream)
- .collect(Collectors.toList());
+ .toList();
}
private List<ProjectDto> getQualityProfileAssociatedProjects(DbSession dbSession, QProfileDto profile) {
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
-
import org.sonar.alm.client.azure.AzureDevOpsHttpClient;
import org.sonar.alm.client.azure.GsonAzureProject;
import org.sonar.alm.client.azure.GsonAzureProjectList;
List<AzureProject> values = projectList.getValues().stream()
.map(ListAzureProjectsAction::toAzureProject)
.sorted(comparing(AzureProject::getName, String::compareToIgnoreCase))
- .collect(Collectors.toList());
+ .toList();
ListAzureProjectsWsResponse.Builder builder = ListAzureProjectsWsResponse.newBuilder()
.addAllProjects(values);
return builder.build();
.filter(r -> isSearchOnlyByProjectName(searchQuery) || doesSearchCriteriaMatchProjectOrRepo(r, searchQuery))
.map(repo -> toAzureRepo(repo, sqProjectsKeyByAzureKey))
.sorted(comparing(AzureRepo::getName, String::compareToIgnoreCase))
- .collect(toList());
+ .toList();
LOG.debug(repositories.toString());
List<BBCRepo> bbcRepos = repositoryList.getValues().stream()
.map(repository -> toBBCRepo(repository, workspace, sqProjectKeyByRepoSlug))
- .collect(toList());
+ .toList();
SearchBitbucketcloudReposWsResponse.Builder builder = SearchBitbucketcloudReposWsResponse.newBuilder()
.setIsLastPage(repositoryList.getNext() == null)
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
import org.sonar.alm.client.bitbucketserver.BitbucketServerRestClient;
import org.sonar.alm.client.bitbucketserver.Project;
import org.sonar.alm.client.bitbucketserver.ProjectList;
String url = requireNonNull(almSettingDto.getUrl(), "URL cannot be null");
ProjectList projectList = bitbucketServerRestClient.getProjects(url, pat);
- List<AlmProject> values = projectList.getValues().stream().map(ListBitbucketServerProjectsAction::toAlmProject).collect(Collectors.toList());
+ List<AlmProject> values = projectList.getValues().stream().map(ListBitbucketServerProjectsAction::toAlmProject).toList();
ListBitbucketserverProjectsWsResponse.Builder builder = ListBitbucketserverProjectsWsResponse.newBuilder()
.addAllProjects(values);
return builder.build();
Map<String, String> sqProjectsKeyByBBSKey = getSqProjectsKeyByBBSKey(dbSession, almSettingDto, gsonBBSRepoList);
List<BBSRepo> bbsRepos = gsonBBSRepoList.getValues().stream().map(gsonBBSRepo -> toBBSRepo(gsonBBSRepo, sqProjectsKeyByBBSKey))
- .collect(toList());
+ .toList();
SearchBitbucketserverReposWsResponse.Builder builder = SearchBitbucketserverReposWsResponse.newBuilder()
.setIsLastPage(gsonBBSRepoList.isLastPage())
List<GitlabRepository> gitlabRepositories = gitlabProjectList.getProjects().stream()
.map(project -> toGitlabRepository(project, sqProjectsKeyByGitlabProjectId))
- .collect(toList());
+ .toList();
Paging.Builder pagingBuilder = Paging.newBuilder()
.setPageIndex(gitlabProjectList.getPageNumber())
import java.util.Comparator;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
return almSettingBuilder.build();
})
- .collect(Collectors.toList());
+ .toList();
return ListWsResponse.newBuilder()
.addAllAlmSettings(wsAlmSettings).build();
}
List<AlmSettingGithub> githubSettings = settingsByAlm.getOrDefault(ALM.GITHUB, emptyList())
.stream()
.sorted(Comparator.comparing(AlmSettingDto::getCreatedAt))
- .map(ListDefinitionsAction::toGitHub).collect(Collectors.toList());
+ .map(ListDefinitionsAction::toGitHub).toList();
List<AlmSettingAzure> azureSettings = settingsByAlm.getOrDefault(ALM.AZURE_DEVOPS, emptyList())
.stream()
.sorted(Comparator.comparing(AlmSettingDto::getCreatedAt))
- .map(ListDefinitionsAction::toAzure).collect(Collectors.toList());
+ .map(ListDefinitionsAction::toAzure).toList();
List<AlmSettingBitbucket> bitbucketSettings = settingsByAlm.getOrDefault(ALM.BITBUCKET, emptyList())
.stream()
.sorted(Comparator.comparing(AlmSettingDto::getCreatedAt))
- .map(ListDefinitionsAction::toBitbucket).collect(Collectors.toList());
+ .map(ListDefinitionsAction::toBitbucket).toList();
List<AlmSettingBitbucketCloud> bitbucketCloudSettings = settingsByAlm.getOrDefault(ALM.BITBUCKET_CLOUD, emptyList())
.stream()
.sorted(Comparator.comparing(AlmSettingDto::getCreatedAt))
- .map(ListDefinitionsAction::toBitbucketCloud).collect(Collectors.toList());
+ .map(ListDefinitionsAction::toBitbucketCloud).toList();
List<AlmSettingGitlab> gitlabSettings = settingsByAlm.getOrDefault(ALM.GITLAB, emptyList())
.stream()
.sorted(Comparator.comparing(AlmSettingDto::getCreatedAt))
- .map(ListDefinitionsAction::toGitlab).collect(Collectors.toList());
+ .map(ListDefinitionsAction::toGitlab).toList();
return ListDefinitionsWsResponse.newBuilder()
.addAllGithub(githubSettings)
.addAllAzure(azureSettings)
List<String> usersUuids = issueDtos.stream()
.filter(issue -> issue.getAssigneeUuid() != null)
.map(IssueDto::getAssigneeUuid)
- .collect(toList());
+ .toList();
Map<String, String> userLoginsByUserUuids = dbClient.userDao().selectByUuids(dbSession, usersUuids)
.stream().collect(toMap(UserDto::getUuid, UserDto::getLogin));
package org.sonar.server.ce.ws;
import java.util.List;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
.setMessage(dto.getMessage())
.setDismissable(dto.getType().isDismissible())
.build())
- .collect(Collectors.toList());
+ .toList();
builder.addAllWarnings(result);
return builder.build();
}
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.utils.DateUtils;
.stream()
.collect(uniqueIndex(ComponentDto::uuid));
Multimap<String, CeTaskCharacteristicDto> characteristicsByTaskUuid = dbClient.ceTaskCharacteristicsDao()
- .selectByTaskUuids(dbSession, ceQueueDtos.stream().map(CeQueueDto::getUuid).collect(Collectors.toList()))
+ .selectByTaskUuids(dbSession, ceQueueDtos.stream().map(CeQueueDto::getUuid).toList())
.stream().collect(MoreCollectors.index(CeTaskCharacteristicDto::getTaskUuid));
Set<String> submitterUuids = ceQueueDtos.stream().map(CeQueueDto::getSubmitterUuid).filter(Objects::nonNull).collect(toSet());
Map<String, UserDto> usersByUuid = dbClient.userDao().selectByUuids(dbSession, submitterUuids).stream().collect(uniqueIndex(UserDto::getUuid));
.stream()
.collect(uniqueIndex(ComponentDto::uuid));
Multimap<String, CeTaskCharacteristicDto> characteristicsByTaskUuid = dbClient.ceTaskCharacteristicsDao()
- .selectByTaskUuids(dbSession, ceActivityDtos.stream().map(CeActivityDto::getUuid).collect(Collectors.toList()))
+ .selectByTaskUuids(dbSession, ceActivityDtos.stream().map(CeActivityDto::getUuid).toList())
.stream().collect(MoreCollectors.index(CeTaskCharacteristicDto::getTaskUuid));
Set<String> submitterUuids = ceActivityDtos.stream().map(CeActivityDto::getSubmitterUuid).filter(Objects::nonNull).collect(toSet());
Map<String, UserDto> usersByUuid = dbClient.userDao().selectByUuids(dbSession, submitterUuids).stream().collect(uniqueIndex(UserDto::getUuid));
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.resources.Qualifiers;
import static org.sonar.api.resources.Qualifiers.VIEW;
import static org.sonar.core.util.stream.MoreCollectors.toHashSet;
import static org.sonar.server.es.SearchOptions.MAX_PAGE_SIZE;
-import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter;
import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
+import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SEARCH;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_QUALIFIERS;
.selectByUuids(dbSession, projectUuidsToSearch)
.stream()
.filter(c -> !c.qualifier().equals(Qualifiers.MODULE))
- .collect(Collectors.toList());
+ .toList();
return projects.stream().collect(toMap(ComponentDto::uuid, ComponentDto::getKey));
}
return stream(SuggestionCategory.values())
.map(SuggestionCategory::getQualifier)
.filter(availableQualifiers::contains)
- .collect(Collectors.toList());
+ .toList();
}
String qualifier = SuggestionCategory.getByName(more).getQualifier();
.setKey(p.getKey())
.setName(p.longName())
.build())
- .collect(Collectors.toList());
+ .toList();
}
}
.setDescription("Comma-separated list of SonarSource security categories. Use '" + SecurityStandards.SQCategory.OTHERS.getKey() +
"' to select issues not associated with any category")
.setSince("8.6")
- .setPossibleValues(Arrays.stream(SecurityStandards.SQCategory.values()).map(SecurityStandards.SQCategory::getKey).collect(Collectors.toList()));
+ .setPossibleValues(Arrays.stream(SecurityStandards.SQCategory.values()).map(SecurityStandards.SQCategory::getKey).toList());
action.createParam(PARAM_CWE)
.setDescription("Comma-separated list of CWE numbers")
.setExampleValue("89,434,352")
return issueKeys.stream()
.map(hotspotsByKey::get)
.filter(Objects::nonNull)
- .collect(Collectors.toList());
+ .toList();
}
private SearchResponse doIndexSearch(WsRequest wsRequest, DbSession dbSession, @Nullable ComponentDto project) {
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.issue.IssueDto;
import org.sonar.db.protobuf.DbCommons;
convertFlowType(flow.getType()).ifPresent(targetFlow::setType);
}
return targetFlow.build();
- }).collect(Collectors.toList());
+ }).toList();
}
private static Optional<Common.FlowType> convertFlowType(DbIssues.FlowType flowType) {
});
return issueIndex.searchAuthors(
issueQueryBuilder
- .types(ALL_RULE_TYPES_EXCEPT_SECURITY_HOTSPOTS.stream().map(Enum::name).collect(Collectors.toList()))
+ .types(ALL_RULE_TYPES_EXCEPT_SECURITY_HOTSPOTS.stream().map(Enum::name).toList())
.build(),
request.param(TEXT_QUERY),
request.mandatoryParamAsInt(PAGE_SIZE));
List<IssueDto> allIssues = dbClient.issueDao().selectByKeys(dbSession, issueKeys)
.stream()
.filter(issueDto -> SECURITY_HOTSPOT.getDbConstant() != issueDto.getType())
- .collect(Collectors.toList());
+ .toList();
List<ComponentDto> allProjects = getComponents(dbSession, allIssues.stream().map(IssueDto::getProjectUuid).collect(MoreCollectors.toSet()));
this.projectsByUuid = getAuthorizedProjects(allProjects).stream().collect(uniqueIndex(ComponentDto::uuid, identity()));
.setDescription("Comma-separated list of SonarSource security categories. Use '" + SQCategory.OTHERS.getKey() + "' to select issues not associated" +
" with any category")
.setSince("7.8")
- .setPossibleValues(Arrays.stream(SQCategory.values()).map(SQCategory::getKey).collect(Collectors.toList()));
+ .setPossibleValues(Arrays.stream(SQCategory.values()).map(SQCategory::getKey).toList());
action.createParam(PARAM_AUTHOR)
.setDescription("SCM accounts. To set several values, the parameter must be called once for each value.")
.setExampleValue("author=torvalds@linux-foundation.org&author=linux@fondation.org");
if (typeFacet != null) {
typeFacet.remove(RuleType.SECURITY_HOTSPOT.name());
}
- addMandatoryValuesToFacet(facets, PARAM_TYPES, ALL_RULE_TYPES_EXCEPT_SECURITY_HOTSPOTS.stream().map(Enum::name).collect(Collectors.toList()));
+ addMandatoryValuesToFacet(facets, PARAM_TYPES, ALL_RULE_TYPES_EXCEPT_SECURITY_HOTSPOTS.stream().map(Enum::name).toList());
}
private static void addMandatoryValuesToFacet(Facets facets, String facetName, @Nullable Iterable<String> mandatoryValues) {
}
List<UserDto> userDtos = dbClient.userDao().selectByLogins(dbSession, userLogins);
- List<String> assigneeUuid = userDtos.stream().map(UserDto::getUuid).collect(toList());
+ List<String> assigneeUuid = userDtos.stream().map(UserDto::getUuid).toList();
if ((assigneeLogins != null) && firstNonNull(assigneeUuid, emptyList()).isEmpty()) {
assigneeUuid = List.of("non-existent-uuid");
import static java.util.Collections.emptyList;
import static java.util.Objects.requireNonNull;
import static java.util.Optional.ofNullable;
-import static java.util.stream.Collectors.toList;
import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE;
import static org.sonar.api.rule.RuleKey.EXTERNAL_RULE_REPO_PREFIX;
import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
private List<Issues.Issue> createIssues(Collection<SearchAdditionalField> fields, SearchResponseData data) {
return data.getIssues().stream()
.map(dto -> createIssue(fields, data, dto))
- .collect(toList());
+ .toList();
}
private Issue createIssue(Collection<SearchAdditionalField> fields, SearchResponseData data, IssueDto dto) {
if (issueKeysToLoad.isEmpty()) {
return issueKeys.stream()
.map(new KeyToIssueFunction(preloadedIssues)).filter(Objects::nonNull)
- .collect(Collectors.toList());
+ .toList();
}
List<IssueDto> loadedIssues = dbClient.issueDao().selectByKeys(dbSession, issueKeysToLoad);
return issueKeys.stream()
.map(new KeyToIssueFunction(unorderedIssues)).filter(Objects::nonNull)
- .collect(Collectors.toList());
+ .toList();
}
private void loadUsers(SearchResponseData preloadedResponseData, Collector collector, DbSession dbSession, SearchResponseData result) {
import org.sonar.db.issue.IssueDto;
import org.sonar.db.issue.IssueQueryParams;
-import static java.util.stream.Collectors.toList;
import static org.sonar.db.issue.IssueDao.DEFAULT_PAGE_SIZE;
public class PullActionIssuesRetriever {
return issues
.stream()
.filter(i -> hasCorrectTypeAndStatus(i, issueQueryParams))
- .collect(toList());
+ .toList();
}
private static boolean hasCorrectTypeAndStatus(IssueDto issueDto, IssueQueryParams queryParams) {
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Collectors;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.ComponentDto;
}
return dbClient.componentDao().selectByUuids(dbSession, componentUuids).stream()
.sorted(Comparator.comparing(ComponentDto::getUuidPath).reversed())
- .collect(Collectors.toList());
+ .toList();
}
@Override
import java.util.List;
import java.util.Objects;
import java.util.Optional;
-import java.util.stream.Collectors;
import org.sonar.api.config.Configuration;
import org.sonar.api.measures.Metric;
import org.sonar.db.DbClient;
.flatMap(c -> matrix.getMeasure(c, currentFormula.getMetric().getKey()).stream())
.map(LiveMeasureDto::getValue)
.filter(Objects::nonNull)
- .collect(Collectors.toList());
+ .toList();
}
/**
}
}
- List<MetricDto> toRemove = measuresByComponentUuidAndMetric.columnKeySet().stream().filter(m -> !requestedMetricKeys.contains(m.getKey())).collect(Collectors.toList());
+ List<MetricDto> toRemove = measuresByComponentUuidAndMetric.columnKeySet().stream().filter(m -> !requestedMetricKeys.contains(m.getKey())).toList();
measuresByComponentUuidAndMetric.columnKeySet().removeAll(toRemove);
}
import com.google.common.collect.TreeMultimap;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
if (users.isEmpty()) {
return emptyList();
}
- List<String> userUuids = users.stream().map(UserDto::getUuid).collect(Collectors.toList());
+ List<String> userUuids = users.stream().map(UserDto::getUuid).toList();
PermissionQuery.Builder queryBuilder = PermissionQuery.builder()
.withAtLeastOnePermission();
if (project != null) {
import com.google.common.collect.TreeBasedTable;
import java.util.List;
import java.util.Locale;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.resources.Qualifiers;
private SearchTemplatesData load(DbSession dbSession, SearchTemplatesRequest request) {
SearchTemplatesData.Builder data = builder();
List<PermissionTemplateDto> templates = searchTemplates(dbSession, request);
- List<String> templateUuids = templates.stream().map(PermissionTemplateDto::getUuid).collect(Collectors.toList());
+ List<String> templateUuids = templates.stream().map(PermissionTemplateDto::getUuid).toList();
ResolvedDefaultTemplates resolvedDefaultTemplates = defaultTemplatesResolver.resolve(dbSession);
data.templates(templates)
import com.google.common.collect.Ordering;
import com.google.common.collect.TreeMultimap;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.api.security.DefaultGroups;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
}
private List<PermissionTemplateGroupDto> findGroupPermissions(DbSession dbSession, List<GroupDto> groups, PermissionTemplateDto template) {
- List<String> names = groups.stream().map(GroupDto::getName).collect(Collectors.toList());
+ List<String> names = groups.stream().map(GroupDto::getName).toList();
return dbClient.permissionTemplateDao().selectGroupPermissionsByTemplateIdAndGroupNames(dbSession, template.getUuid(), names);
}
}
import com.google.common.collect.Ordering;
import com.google.common.collect.TreeMultimap;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
Paging paging = Paging.forPageIndex(wsRequest.mandatoryParamAsInt(PAGE)).withPageSize(wsRequest.mandatoryParamAsInt(PAGE_SIZE)).andTotal(total);
List<UserDto> users = findUsers(dbSession, query, template);
List<PermissionTemplateUserDto> permissionTemplateUsers = dbClient.permissionTemplateDao().selectUserPermissionsByTemplateIdAndUserLogins(dbSession, template.getUuid(),
- users.stream().map(UserDto::getLogin).collect(Collectors.toList()));
+ users.stream().map(UserDto::getLogin).toList());
Permissions.UsersWsResponse templateUsersResponse = buildResponse(users, permissionTemplateUsers, paging);
writeProtobuf(templateUsersResponse, wsRequest, wsResponse);
}
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
ofNullable(plugin.getIssueTrackerUrl()).ifPresent(builder::setIssueTrackerUrl);
ofNullable(plugin.getHomepageUrl()).ifPresent(builder::setHomepageUrl);
return builder.build();
- }).collect(Collectors.toList());
+ }).toList();
}
private static Update buildUpdate(PluginUpdate pluginUpdate) {
}
private static Collection<PluginUpdate> retrieveAvailablePlugins(UpdateCenter updateCenter) {
- return updateCenter.findAvailablePlugins().stream().sorted(NAME_KEY_PLUGIN_UPDATE_ORDERING).collect(Collectors.toList());
+ return updateCenter.findAvailablePlugins().stream().sorted(NAME_KEY_PLUGIN_UPDATE_ORDERING).toList();
}
}
Plugin plugin = compatiblePluginsByKey.get(pluginInfo.getKey());
return buildPluginDetails(null, pluginInfo, null, plugin);
})
- .collect(Collectors.toList());
+ .toList();
}
}
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.core.platform.PluginInfo;
import org.sonar.db.plugin.PluginDto;
ofNullable(artifact.getDescription()).ifPresent(builder::setDescription);
return builder.build();
})
- .collect(Collectors.toList());
+ .toList();
}
static UpdateStatus convertUpdateCenterStatus(PluginUpdate.Status status) {
import java.util.List;
import java.util.Objects;
import java.util.Optional;
-import java.util.stream.Collectors;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
ofNullable(plugin.getIssueTrackerUrl()).ifPresent(builder::setIssueTrackerUrl);
ofNullable(plugin.getHomepageUrl()).ifPresent(builder::setHomepageUrl);
return builder.build();
- }).collect(Collectors.toList());
+ }).toList();
}
private static Collection<AvailableUpdate> buildUpdates(PluginUpdateAggregate pluginUpdateAggregate) {
.setStatus(convertUpdateCenterStatus(pluginUpdate.getStatus()))
.addAllRequires(buildRequires(pluginUpdate))
.build())
- .collect(Collectors.toList());
+ .toList();
}
private Collection<PluginUpdateAggregate> retrieveUpdatablePlugins(UpdateCenter updateCenter) {
import static java.util.Comparator.nullsFirst;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;
-import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
@ServerSide
List<Project> resultProjects = allProjects.stream()
.sorted(comparing(ProjectDto::getName, nullsFirst(String.CASE_INSENSITIVE_ORDER)))
.map(p -> new Project(p.getKey(), p.getName()))
- .collect(toList());
+ .toList();
return new SearchResult(resultProjects);
}
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
import org.sonar.api.server.ws.Change;
var detectedCIs = dbClient.analysisPropertiesDao().selectByKeyAndAnalysisUuids(data.getDbSession(),
CorePropertyDefinitions.SONAR_ANALYSIS_DETECTEDCI,
- snapshotDtos.stream().map(SnapshotDto::getUuid).collect(Collectors.toList()));
+ snapshotDtos.stream().map(SnapshotDto::getUuid).toList());
data.setAnalyses(snapshotDtos);
data.setDetectedCIs(detectedCIs);
}
wsQualityGate.addAllFailing(eventComponentChangeDtos.stream()
.map(SearchResponseBuilder::toFailing)
- .collect(toList()));
+ .toList());
wsEvent.setQualityGate(wsQualityGate.build());
}
componentChangeByKey.asMap().values().stream()
.map(SearchResponseBuilder::addChange)
.map(Project::toProject)
- .collect(toList())
+ .toList()
);
wsEvent.setDefinitionChange(wsDefinitionChange.build());
} catch (IllegalStateException e) {
return SearchWsResponse.newBuilder()
.addAllLinks(links.stream()
.map(SearchAction::buildLink)
- .collect(Collectors.toList()))
+ .toList())
.build();
}
ValueType.RATING,
ValueType.WORK_DUR);
- private static final List<String> RATING_VALID_INT_VALUES = stream(Rating.values()).map(r -> Integer.toString(r.getIndex())).collect(Collectors.toList());
+ private static final List<String> RATING_VALID_INT_VALUES = stream(Rating.values()).map(r -> Integer.toString(r.getIndex())).toList();
private final DbClient dbClient;
import org.sonarqube.ws.Qualitygates;
import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.stream.Collectors.toList;
import static org.sonar.api.server.ws.WebService.Param.SELECTED;
import static org.sonar.api.utils.Paging.forPageIndex;
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
}
private static List<ProjectQgateAssociationDto> getPaginatedProjects(List<ProjectQgateAssociationDto> projects, Paging paging) {
- return projects.stream().skip(paging.offset()).limit(paging.pageSize()).collect(toList());
+ return projects.stream().skip(paging.offset()).limit(paging.pageSize()).toList();
}
private List<ProjectQgateAssociationDto> keepAuthorizedProjects(DbSession dbSession, List<ProjectQgateAssociationDto> projects) {
private static void checkIfRulesFromExternalEngines(Collection<RuleDto> ruleDefinitions) {
List<RuleDto> externalRules = ruleDefinitions.stream()
.filter(RuleDto::isExternal)
- .collect(Collectors.toList());
+ .toList();
if (!externalRules.isEmpty()) {
throw new IllegalArgumentException("The quality profile cannot be restored as it contains rules from external rule engines: "
List<NewCustomRule> customRulesToCreate = rules.stream()
.filter(r -> ruleDefinitionsByKey.get(r.getRuleKey()) == null && r.isCustomRule())
.map(QProfileBackuperImpl::importedRuleToNewCustomRule)
- .collect(Collectors.toList());
+ .toList();
if (!customRulesToCreate.isEmpty()) {
return db.ruleDao().selectByKeys(dbSession, ruleCreator.create(dbSession, customRulesToCreate))
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.utils.System2;
import org.sonar.core.util.stream.MoreCollectors;
return rulesCollection1.stream()
.filter(rule -> !rulesCollection2Uuids.contains(rule.getRuleUuid()))
- .collect(Collectors.toList());
+ .toList();
}
private List<ActiveRuleChange> removeParent(DbSession dbSession, QProfileDto profile) {
List<ActiveRuleParamDto> rules = ruleRepository.getRuleParams(activeRule.getRuleKey()).stream()
.map(param -> createParamDto(param, Optional.ofNullable(valuesByParamKey.get(param.getName())).orElse(param.getDefaultValue())))
.filter(Objects::nonNull)
- .collect(Collectors.toList());
+ .toList();
rules.forEach(paramDto -> dbClient.activeRuleDao().insertParam(session, activeRuleDto, paramDto));
return rules;
loadDescendants();
return getProfiles().stream()
.flatMap(p -> profilesByParentUuid.get(p.getKee()).stream())
- .collect(Collectors.toList());
+ .toList();
}
private void loadDescendants() {
this.currentRulesProfile = ruleProfile;
this.currentProfiles = profilesByUuid.values().stream()
.filter(p -> p.getRulesProfileUuid().equals(ruleProfile.getUuid()))
- .collect(Collectors.toList());
+ .toList();
this.currentActiveRule = this.activeRulesByKey.get(ActiveRuleKey.of(ruleProfile, ruleKey));
this.currentParentActiveRule = this.currentProfiles.stream()
.map(QProfileDto::getParentKee)
import org.sonar.server.util.TypeValidations;
import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.stream.Collectors.toList;
import static org.sonar.server.exceptions.BadRequestException.checkRequest;
/**
public List<ActiveRuleChange> activate(DbSession dbSession, Collection<RuleActivation> activations, RuleActivationContext context) {
return activations.stream().map(a -> activate(dbSession, a, context))
.flatMap(List::stream)
- .collect(toList());
+ .toList();
}
public List<ActiveRuleChange> activate(DbSession dbSession, RuleActivation activation, RuleActivationContext context) {
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import org.sonar.api.resources.Languages;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
private static Iterable<QualityProfile> buildAncestors(List<QProfileDto> ancestors, Statistics statistics) {
return ancestors.stream()
.map(ancestor -> buildProfile(ancestor, statistics))
- .collect(Collectors.toList());
+ .toList();
}
private static Iterable<QualityProfile> buildChildren(List<QProfileDto> children, Statistics statistics) {
return children.stream()
.map(child -> buildProfile(child, statistics))
- .collect(Collectors.toList());
+ .toList();
}
private static QualityProfile buildProfile(QProfileDto qualityProfile, Statistics statistics) {
.filter(byDefault(request, defaultProfiles))
.filter(byProject(dbSession, project, defaultProfiles))
.sorted(Q_PROFILE_COMPARATOR)
- .collect(Collectors.toList());
+ .toList();
}
private Predicate<QProfileDto> hasLanguagePlugin() {
RuleKey customRuleKey = RuleKey.of(templateRule.getRepositoryKey(), newCustomRule.ruleKey());
return createCustomRule(customRuleKey, newCustomRule, templateRule, dbSession);
})
- .collect(Collectors.toList());
+ .toList();
ruleIndexer.commitAndIndex(dbSession, customRuleUuids);
return newRules.stream()
RuleDto templateRule = templateRules.get(newCustomRule.templateKey());
return RuleKey.of(templateRule.getRepositoryKey(), newCustomRule.ruleKey());
})
- .collect(Collectors.toList());
+ .toList();
}
private void validateCustomRule(NewCustomRule newRule, DbSession dbSession, RuleKey templateKey) {
activeRuleUuidsByKey.put(activeRuleDto.getUuid(), activeRuleDto.getKey());
}
- List<String> activeRuleUuids = activeRules.stream().map(ActiveRuleDto::getUuid).collect(Collectors.toList());
+ List<String> activeRuleUuids = activeRules.stream().map(ActiveRuleDto::getUuid).toList();
List<ActiveRuleParamDto> activeRuleParams = dbClient.activeRuleDao().selectParamsByActiveRuleUuids(dbSession, activeRuleUuids);
ListMultimap<ActiveRuleKey, ActiveRuleParamDto> activeRuleParamsByActiveRuleKey = ArrayListMultimap.create(activeRules.size(), 10);
for (ActiveRuleParamDto activeRuleParamDto : activeRuleParams) {
return activeRules.stream()
.map(activeRule -> buildActiveRuleResponse(activeRule, activeRuleParamsByActiveRuleKey.get(activeRule.getKey())))
- .collect(Collectors.toList());
+ .toList();
}
private static Rules.Active buildActiveRuleResponse(OrgActiveRuleDto activeRule, List<ActiveRuleParamDto> parameters) {
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
.setPossibleValues(
Arrays.stream(RuleStatus.values())
.filter(status -> !RuleStatus.REMOVED.equals(status))
- .collect(Collectors.toList()))
+ .toList())
.setDefaultValue(RuleStatus.READY)
.setDescription("Rule status");
List<String> deprecatedKeys = deprecatedRuleKeyDtos.stream()
.map(r -> RuleKey.of(r.getOldRepositoryKey(), r.getOldRuleKey()).toString())
- .collect(Collectors.toList());
+ .toList();
if (!deprecatedKeys.isEmpty()) {
ruleResponse.setDeprecatedKeys(Rules.DeprecatedKeys.newBuilder().addAllDeprecatedKey(deprecatedKeys).build());
}
import java.util.Map;
import java.util.Objects;
import java.util.Set;
-import java.util.stream.Collectors;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
import org.sonar.api.rules.RuleType;
.setDescription("Comma-separated list of SonarSource security categories. Use '" + SQCategory.OTHERS.getKey() + "' to select rules not associated" +
" with any category")
.setSince("7.8")
- .setPossibleValues(Arrays.stream(SQCategory.values()).map(SQCategory::getKey).collect(Collectors.toList()))
+ .setPossibleValues(Arrays.stream(SQCategory.values()).map(SQCategory::getKey).toList())
.setExampleValue("sql-injection,command-injection,others");
action
List<Map<String, String>> maps = request.getFieldValues().stream()
.map(oneFieldValues -> readOneFieldValues(oneFieldValues, request.getKey()))
- .collect(Collectors.toList());
+ .toList();
for (Map<String, String> map : maps) {
checkRequest(map.values().stream().anyMatch(StringUtils::isNotBlank), MSG_NO_EMPTY_VALUE);
}
- List<Map.Entry<String, String>> entries = maps.stream().flatMap(map -> map.entrySet().stream()).collect(Collectors.toList());
+ List<Map.Entry<String, String>> entries = maps.stream().flatMap(map -> map.entrySet().stream()).toList();
entries.forEach(entry -> valuesByFieldKeys.put(entry.getKey(), entry.getValue()));
entries.forEach(entry -> checkRequest(fieldKeys.contains(entry.getKey()), "Unknown field key '%s' for setting '%s'", entry.getKey(), request.getKey()));
checkFieldType(request, definition, valuesByFieldKeys);
private void validateMetric(SettingData data) {
try (DbSession dbSession = dbClient.openSession(false)) {
- List<MetricDto> metrics = dbClient.metricDao().selectByKeys(dbSession, data.values).stream().filter(MetricDto::isEnabled).collect(Collectors.toList());
+ List<MetricDto> metrics = dbClient.metricDao().selectByKeys(dbSession, data.values).stream().filter(MetricDto::isEnabled).toList();
checkRequest(data.values.size() == metrics.size(), "Error when validating metric setting with key '%s' and values [%s]. A value is not a valid metric key.",
data.key, data.values.stream().collect(Collectors.joining(", ")));
}
private void validateLogin(SettingData data) {
try (DbSession dbSession = dbClient.openSession(false)) {
- List<UserDto> users = dbClient.userDao().selectByLogins(dbSession, data.values).stream().filter(UserDto::isActive).collect(Collectors.toList());
+ List<UserDto> users = dbClient.userDao().selectByLogins(dbSession, data.values).stream().filter(UserDto::isActive).toList();
checkRequest(data.values.size() == users.size(), "Error when validating login setting with key '%s' and values [%s]. A value is not a valid login.",
data.key, data.values.stream().collect(Collectors.joining(", ")));
}
component.ifPresent(componentDto -> settings.addAll(loadComponentSettings(dbSession, keys, componentDto).values()));
return settings.stream()
.filter(s -> settingsWsSupport.isVisible(s.getKey(), component))
- .collect(Collectors.toList());
+ .toList();
}
@CheckForNull
.filter(definition -> keys.contains(definition.key()))
.filter(defaultProperty -> !isEmpty(defaultProperty.defaultValue()))
.map(Setting::createFromDefinition)
- .collect(Collectors.toList());
+ .toList();
}
private Map<String, String> getKeysToDisplayMap(Set<String> keys) {
List<PropertyDto> propertySets = dbClient.propertiesDao().selectGlobalPropertiesByKeys(dbSession, getPropertySetKeys(properties));
return properties.stream()
.map(property -> Setting.createFromDto(property, getPropertySets(property.getKey(), propertySets, null), propertyDefinitions.get(property.getKey())))
- .collect(Collectors.toList());
+ .toList();
}
/**
return propertySets.stream()
.filter(propertyDto -> Objects.equals(propertyDto.getComponentUuid(), componentUuid))
.filter(propertyDto -> propertyDto.getKey().startsWith(propertyKey + "."))
- .collect(Collectors.toList());
+ .toList();
}
private class ValuesResponseBuilder {
}
private Settings.Values.Builder createValuesBuilder(String value) {
- List<String> values = COMMA_SPLITTER.splitToList(value).stream().map(v -> v.replace(COMMA_ENCODED_VALUE, ",")).collect(Collectors.toList());
+ List<String> values = COMMA_SPLITTER.splitToList(value).stream().map(v -> v.replace(COMMA_ENCODED_VALUE, ",")).toList();
return Settings.Values.newBuilder().addAllValues(values);
}
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.utils.MessageException;
import org.sonar.api.web.WebAnalytics;
this.analytics = null;
} else {
if (analytics.length > 1) {
- List<String> classes = Arrays.stream(analytics).map(a -> a.getClass().getName()).collect(Collectors.toList());
+ List<String> classes = Arrays.stream(analytics).map(a -> a.getClass().getName()).toList();
throw MessageException.of("Limited to only one web analytics plugin. Found multiple implementations: " + classes);
}
this.analytics = analytics.length == 1 ? analytics[0] : null;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.config.Configuration;
.map(LiveMeasureDto::getDataAsString)
.map(data -> QPMeasureData.fromJson(data).getProfiles())
.orElse(emptySortedSet());
- Map<String, QProfileDto> dtoByQPKey = dbClient.qualityProfileDao().selectByUuids(dbSession, qualityProfiles.stream().map(QualityProfile::getQpKey).collect(Collectors.toList()))
+ Map<String, QProfileDto> dtoByQPKey = dbClient.qualityProfileDao().selectByUuids(dbSession, qualityProfiles.stream().map(QualityProfile::getQpKey).toList())
.stream()
.collect(uniqueIndex(QProfileDto::getKee));
json.name("qualityProfiles").beginArray();
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static java.util.Optional.ofNullable;
-import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang.StringUtils.EMPTY;
import static org.sonar.api.web.UserRole.USER;
import static org.sonar.server.user.ws.DismissNoticeAction.EDUCATION_PRINCIPLES;
return permissionService.getGlobalPermissions().stream()
.filter(userSession::hasPermission)
.map(GlobalPermission::getKey)
- .collect(toList());
+ .toList();
}
private boolean isNoticeDismissed(UserDto user, String noticeName) {
private List<Type> types;
public HomepageTypesImpl() {
- types = Stream.of(HomepageTypes.Type.values()).collect(Collectors.toList());
+ types = Stream.of(HomepageTypes.Type.values()).toList();
}
@Override
return identityProviderRepository.getAllEnabledAndSorted()
.stream()
.map(IdentityProvider::getKey)
- .collect(Collectors.toList());
+ .toList();
}
private static boolean isLdapIdentityProvider(String identityProviderKey) {
import java.net.SocketException;
import java.util.Collections;
import java.util.List;
-import java.util.stream.Collectors;
public class NetworkInterfaceProvider {
return Collections.list(NetworkInterface.getNetworkInterfaces())
.stream()
.flatMap(ni -> Collections.list(ni.getInetAddresses()).stream())
- .collect(Collectors.toList());
+ .toList();
}
}
Optional<ProjectDto> projectDto = db.getDbClient().projectDao().selectProjectByKey(db.getSession(), result.getKey());
Collection<BranchDto> branchDtos = db.getDbClient().branchDao().selectByProject(db.getSession(), projectDto.get());
- List<BranchDto> collect = branchDtos.stream().filter(BranchDto::isMain).collect(Collectors.toList());
+ List<BranchDto> collect = branchDtos.stream().filter(BranchDto::isMain).toList();
String mainBranchName = collect.iterator().next().getKey();
assertThat(mainBranchName).isEqualTo(DEFAULT_MAIN_BRANCH_NAME);
}
Optional<ProjectDto> projectDto = db.getDbClient().projectDao().selectProjectByKey(db.getSession(), result.getKey());
Collection<BranchDto> branchDtos = db.getDbClient().branchDao().selectByProject(db.getSession(), projectDto.get());
- List<BranchDto> collect = branchDtos.stream().filter(BranchDto::isMain).collect(Collectors.toList());
+ List<BranchDto> collect = branchDtos.stream().filter(BranchDto::isMain).toList();
String mainBranchName = collect.iterator().next().getKey();
assertThat(mainBranchName).isEqualTo("default");
}
when(nodeInformation.isStandalone()).thenReturn(false);
List<String[]> causesGroups = IntStream.range(0, 1 + random.nextInt(20))
.mapToObj(s -> IntStream.range(0, random.nextInt(3)).mapToObj(i -> randomAlphanumeric(3)).toArray(String[]::new))
- .collect(Collectors.toList());
+ .toList();
ClusterHealthCheck[] clusterHealthChecks = causesGroups.stream()
.map(HardcodedHealthClusterCheck::new)
.map(ClusterHealthCheck.class::cast)
.build()));
List<Common.Changelog> changelog = IntStream.range(0, 1 + new Random().nextInt(12))
.mapToObj(i -> Common.Changelog.newBuilder().setUser("u" + i).build())
- .collect(Collectors.toList());
+ .toList();
List<Common.Comment> comments = IntStream.range(0, 1 + new Random().nextInt(12))
.mapToObj(i -> Common.Comment.newBuilder().setKey("u" + i).build())
- .collect(Collectors.toList());
+ .toList();
FormattingContext formattingContext = mockChangelogAndCommentsFormattingContext();
when(issueChangeSupport.formatChangelog(any(), any())).thenReturn(changelog.stream());
when(issueChangeSupport.formatComments(any(), any(), any())).thenReturn(comments.stream());
.setUserName("Joe")
.setAvatar("my-avatar")
.build())
- .collect(Collectors.toList());
+ .toList();
List<Common.Comment> comments = IntStream.range(0, 3)
.mapToObj(i -> Common.Comment.newBuilder()
.setKey("comment-" + i)
.setMarkdown("markdown " + i)
.setCreatedAt("2020-01-02T14:47:47+0100")
.build())
- .collect(Collectors.toList());
+ .toList();
mockChangelogAndCommentsFormattingContext();
when(issueChangeSupport.formatChangelog(any(), any())).thenReturn(changelog.stream());
package org.sonar.server.ws;
import java.util.List;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.db.protobuf.DbIssues;
import org.sonarqube.ws.Common;
.setStart(f.getStart())
.setEnd(f.getEnd())
.setType(Common.MessageFormattingType.valueOf(f.getType().name())).build())
- .collect(Collectors.toList());
+ .toList();
}
}