aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2023-12-04 12:50:58 +0100
committersonartech <sonartech@sonarsource.com>2023-12-04 20:03:22 +0000
commitd62a56ecfd4cf2f183873900fd32cffc4743c7fb (patch)
tree552481ceb8b8cab34f74b59563b58278ffa62f69
parentcdda3dbcdd4e4b5f4a2e7471a37fa66877e26aad (diff)
downloadsonarqube-d62a56ecfd4cf2f183873900fd32cffc4743c7fb.tar.gz
sonarqube-d62a56ecfd4cf2f183873900fd32cffc4743c7fb.zip
SONAR-21174 Fix code smells raised after dropping JDK11 support
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/variant/CodeVariantSensor.java3
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java3
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/MultilineIssuesSensorTest.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/PersistIssuesStepIT.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TransitionIssuesToAnticipatedStatesVisitorTest.java5
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/qualityprofile/QProfileChangeDaoIT.java3
-rw-r--r--server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/TelemetryDataLoaderImplIT.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/extension/PlatformLevelPredicates.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java8
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/status/IssueStatus.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/tracking/FilteringBaseInputWrapper.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/tracking/Tracker.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/ListContainer.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoader.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/PriorityBeanFactory.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/SpringComponentContainer.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/StartableBeanPostProcessor.java10
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/ContextException.java8
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/LineReaderIterator.java4
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/block/FileBlocks.java18
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/TextSet.java4
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/AndPredicate.java8
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/OptimizedFilePredicateAdapter.java4
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/OrPredicate.java4
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRules.java2
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/AbstractDefaultIssue.java13
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Settings.java2
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/SimpleGetRequest.java3
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java5
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionary.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionary.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginRepository.java11
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoader.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/CiConfigurationProvider.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/JavaCpdBlockIndexerSensor.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssueReportValidator.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/RunMapper.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ActiveRulesPublisher.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisWarningsPublisher.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ChangedLinesPublisher.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ContextPropertiesPublisher.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultProjectRepositoriesLoader.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositories.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/DefaultLanguagesRepository.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractCoverageAndDuplicationExclusions.java10
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java19
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorExtensionDictionary.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorExtensionDictionary.java3
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java4
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java16
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlFragmentAssert.java3
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlListAssert.java3
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlParagraphAssert.java3
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/BaseRequest.java4
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java31
-rw-r--r--sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/GroupTester.java4
-rw-r--r--sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/QGateTester.java3
-rw-r--r--sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/QProfileTester.java3
-rw-r--r--sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/SettingTester.java6
-rw-r--r--sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/UserTester.java3
70 files changed, 143 insertions, 216 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/variant/CodeVariantSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/variant/CodeVariantSensor.java
index 53fa9f7e68a..7173402cae5 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/variant/CodeVariantSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/variant/CodeVariantSensor.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.rule.ActiveRules;
@@ -63,7 +62,7 @@ public abstract class CodeVariantSensor extends AbstractXooRuleSensor {
String contents = inputFile.contents();
List<String> identifiedVariants = variants.stream()
.filter(contents::contains)
- .collect(Collectors.toList());
+ .toList();
if (!identifiedVariants.isEmpty()) {
NewIssue newIssue = context.newIssue()
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java
index dc55110a24d..a82e7391545 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java
@@ -34,7 +34,6 @@ import org.sonar.api.batch.scm.BlameLine;
import org.sonar.api.utils.DateUtils;
import static com.google.common.base.Preconditions.checkState;
-import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang.StringUtils.trimToNull;
public class XooBlameCommand extends BlameCommand {
@@ -73,7 +72,7 @@ public class XooBlameCommand extends BlameCommand {
List<CSVRecord> records = csvParser.getRecords();
return records.stream()
.map(r -> convertToBlameLine(now, r))
- .collect(toList());
+ .toList();
}
}
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/MultilineIssuesSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/MultilineIssuesSensorTest.java
index e610ad65e19..8654b8028e6 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/MultilineIssuesSensorTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/MultilineIssuesSensorTest.java
@@ -22,7 +22,6 @@ package org.sonar.xoo.rule;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
-import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -79,7 +78,7 @@ public class MultilineIssuesSensorTest {
List<Issue.Flow> flows = issue.flows();
assertThat(flows).hasSize(2);
- List<DefaultIssueFlow> defaultIssueFlows = flows.stream().map(DefaultIssueFlow.class::cast).collect(Collectors.toList());
+ List<DefaultIssueFlow> defaultIssueFlows = flows.stream().map(DefaultIssueFlow.class::cast).toList();
assertThat(defaultIssueFlows).extracting(DefaultIssueFlow::type).containsExactlyInAnyOrder(FlowType.DATA, FlowType.EXECUTION);
assertThat(flows.get(0).locations()).extracting(IssueLocation::messageFormattings).isNotEmpty();
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/PersistIssuesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/PersistIssuesStepIT.java
index 6aca4f1c5b8..9f1e99230a6 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/PersistIssuesStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/PersistIssuesStepIT.java
@@ -22,7 +22,6 @@ package org.sonar.ce.task.projectanalysis.step;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
-import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.assertj.core.groups.Tuple;
import org.junit.After;
@@ -427,7 +426,7 @@ public class PersistIssuesStepIT extends BaseStepTest {
.setResolution(null)
.setCreatedAt(NOW - 1_000_000_000L)
.setUpdatedAt(NOW - 1_000_000_000L)))
- .collect(Collectors.toList());
+ .toList();
CacheAppender issueCacheAppender = protoIssueCache.newAppender();
issues.forEach(issue -> issueCacheAppender.append(issue.toDefaultIssue()
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TransitionIssuesToAnticipatedStatesVisitorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TransitionIssuesToAnticipatedStatesVisitorTest.java
index a053ee0dfc5..04608e52563 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TransitionIssuesToAnticipatedStatesVisitorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TransitionIssuesToAnticipatedStatesVisitorTest.java
@@ -21,7 +21,6 @@ package org.sonar.ce.task.projectanalysis.issue;
import java.util.Collection;
import java.util.Collections;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Rule;
import org.junit.Test;
@@ -183,11 +182,11 @@ public class TransitionIssuesToAnticipatedStatesVisitorTest {
}
private Collection<AnticipatedTransition> getAnticipatedTransitions(String projecKey, String fileName) {
- return Stream.of(new AnticipatedTransition("atuuid", projecKey, "admin", RuleKey.parse("repo:id"), "issue message", fileName, 1, "abcdefghi", DefaultTransitions.ACCEPT, "doing the transition in an anticipated way")).collect(Collectors.toList());
+ return Stream.of(new AnticipatedTransition("atuuid", projecKey, "admin", RuleKey.parse("repo:id"), "issue message", fileName, 1, "abcdefghi", DefaultTransitions.ACCEPT, "doing the transition in an anticipated way")).toList();
}
private Collection<AnticipatedTransition> getAnticipatedTransitionsWithEmptyComment(String projecKey, String fileName) {
- return Stream.of(new AnticipatedTransition("atuuid", projecKey, "admin", RuleKey.parse("repo:id"), "issue message", fileName, 1, "abcdefghi", DefaultTransitions.ACCEPT, null)).collect(Collectors.toList());
+ return Stream.of(new AnticipatedTransition("atuuid", projecKey, "admin", RuleKey.parse("repo:id"), "issue message", fileName, 1, "abcdefghi", DefaultTransitions.ACCEPT, null)).toList();
}
private Component getComponent(Component.Type type) {
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/qualityprofile/QProfileChangeDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/qualityprofile/QProfileChangeDaoIT.java
index 4dd8044f262..2fb5bd9a99b 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/qualityprofile/QProfileChangeDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/qualityprofile/QProfileChangeDaoIT.java
@@ -22,7 +22,6 @@ package org.sonar.db.qualityprofile;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.junit.Rule;
@@ -102,7 +101,7 @@ public class QProfileChangeDaoIT {
List<QProfileChangeDto> changes = Stream.generate(QProfileChangeDto::new)
.peek(dto -> dto.setRulesProfileUuid("rule_profil_uuid").setChangeType("type"))
.limit(3)
- .collect(Collectors.toList());
+ .toList();
underTest.bulkInsert(dbSession, changes);
diff --git a/server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/TelemetryDataLoaderImplIT.java b/server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/TelemetryDataLoaderImplIT.java
index 0cb082ad3fd..c55a8594557 100644
--- a/server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/TelemetryDataLoaderImplIT.java
+++ b/server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/TelemetryDataLoaderImplIT.java
@@ -33,7 +33,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
-import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.junit.Before;
import org.junit.Rule;
@@ -304,7 +303,7 @@ public class TelemetryDataLoaderImplIT {
.extracting(TelemetryData.QualityGate::uuid, TelemetryData.QualityGate::caycStatus,
qg -> qg.conditions().stream()
.map(condition -> tuple(condition.getMetricKey(), condition.getOperator().getDbValue(), condition.getErrorThreshold(), condition.isOnLeakPeriod()))
- .collect(Collectors.toList()))
+ .toList())
.containsExactlyInAnyOrder(
tuple(builtInDefaultQualityGate.getUuid(), "non-compliant", Collections.emptyList()),
tuple(qualityGate1.getUuid(), "non-compliant", List.of(tuple(vulnerabilitiesDto.getKey(), condition1.getOperator(), condition1.getErrorThreshold(), false))),
diff --git a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
index 1cd570ee65b..70115cc0e27 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
@@ -22,7 +22,6 @@ package org.sonar.core.config;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.api.CoreProperties;
import org.sonar.api.PropertyType;
import org.sonar.api.config.EmailSettings;
@@ -130,7 +129,7 @@ public class CorePropertyDefinitions {
.name("State of user plugins risk consent")
.description("Determine whether user is required to accept plugins risk consent")
.defaultValue(NOT_ACCEPTED.name())
- .options(Arrays.stream(PluginRiskConsent.values()).map(Enum::name).collect(Collectors.toList()))
+ .options(Arrays.stream(PluginRiskConsent.values()).map(Enum::name).toList())
.hidden()
.type(SINGLE_SELECT_LIST)
.build(),
diff --git a/sonar-core/src/main/java/org/sonar/core/extension/PlatformLevelPredicates.java b/sonar-core/src/main/java/org/sonar/core/extension/PlatformLevelPredicates.java
index e9b43c76b08..02e117fa6f6 100644
--- a/sonar-core/src/main/java/org/sonar/core/extension/PlatformLevelPredicates.java
+++ b/sonar-core/src/main/java/org/sonar/core/extension/PlatformLevelPredicates.java
@@ -49,9 +49,9 @@ public final class PlatformLevelPredicates {
String baseErrorMsg = "Only level 1, 2, 3 and 4 are supported";
if (annotatedObject == null) {
return baseErrorMsg;
- } else if (annotatedObject instanceof Class) {
+ } else if (annotatedObject instanceof Class classAnnotatedObject) {
return String.format("Invalid value for annotation %s on class '%s'. %s",
- PlatformLevel.class.getName(), ((Class) annotatedObject).getName(),
+ PlatformLevel.class.getName(), classAnnotatedObject.getName(),
baseErrorMsg);
} else {
return String.format("Invalid value for annotation %s on object of type %s. %s",
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
index d4acff8aef9..1bc2ab0fc30 100644
--- a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
+++ b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
@@ -40,11 +40,11 @@ import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.Startable;
import org.sonar.api.utils.SonarException;
import org.sonar.api.utils.System2;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.PluginRepository;
@@ -117,8 +117,8 @@ public class DefaultI18n implements I18n, Startable {
@Override
public void stop() {
- if (classloader instanceof Closeable) {
- IOUtils.closeQuietly((Closeable) classloader);
+ if (classloader instanceof Closeable closeable) {
+ IOUtils.closeQuietly(closeable);
}
classloader = null;
propertyToBundles = null;
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/status/IssueStatus.java b/sonar-core/src/main/java/org/sonar/core/issue/status/IssueStatus.java
index 8967460de51..0a01b9622cf 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/status/IssueStatus.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/status/IssueStatus.java
@@ -51,16 +51,14 @@ public enum IssueStatus {
}
switch (status) {
- case Issue.STATUS_OPEN:
- case Issue.STATUS_REOPENED:
+ case Issue.STATUS_OPEN, Issue.STATUS_REOPENED:
return IssueStatus.OPEN;
case Issue.STATUS_CONFIRMED:
return IssueStatus.CONFIRMED;
case Issue.STATUS_CLOSED:
return IssueStatus.FIXED;
// Security hotspot should not return issue status as they are deprecated.
- case Issue.STATUS_REVIEWED:
- case Issue.STATUS_TO_REVIEW:
+ case Issue.STATUS_REVIEWED, Issue.STATUS_TO_REVIEW:
return null;
default:
}
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/tracking/FilteringBaseInputWrapper.java b/sonar-core/src/main/java/org/sonar/core/issue/tracking/FilteringBaseInputWrapper.java
index 9eb0f09ef4b..3351fa86d13 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/tracking/FilteringBaseInputWrapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/tracking/FilteringBaseInputWrapper.java
@@ -22,7 +22,6 @@ package org.sonar.core.issue.tracking;
import java.util.Collection;
import java.util.List;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
class FilteringBaseInputWrapper<BASE extends Trackable> implements Input<BASE> {
private final Input<BASE> baseInput;
@@ -33,7 +32,7 @@ class FilteringBaseInputWrapper<BASE extends Trackable> implements Input<BASE> {
Collection<BASE> baseIssues = baseInput.getIssues();
this.nonClosedIssues = baseIssues.stream()
.filter(baseInputFilter)
- .collect(Collectors.toList());
+ .toList();
}
@Override
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/tracking/Tracker.java b/sonar-core/src/main/java/org/sonar/core/issue/tracking/Tracker.java
index a525f660fef..964b0d18693 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/tracking/Tracker.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/tracking/Tracker.java
@@ -21,7 +21,6 @@ package org.sonar.core.issue.tracking;
import java.util.Collection;
import java.util.List;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.sonar.api.issue.Issue;
import org.sonar.api.scanner.ScannerSide;
@@ -96,6 +95,6 @@ public class Tracker<RAW extends Trackable, BASE extends Trackable> extends Abst
Collection<BASE> nonClosedIssues = nonClosedTracking.getBaseInput().getIssues();
Collection<BASE> closeIssues = closedTracking.getBaseInput().getIssues();
return Stream.concat(nonClosedIssues.stream(), closeIssues.stream())
- .collect(Collectors.toList());
+ .toList();
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/ListContainer.java b/sonar-core/src/main/java/org/sonar/core/platform/ListContainer.java
index cd2f9336997..50d314e7e7b 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/ListContainer.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/ListContainer.java
@@ -39,8 +39,8 @@ public class ListContainer implements ExtensionContainer {
@Override
public Container add(Object... objects) {
for (Object o : objects) {
- if (o instanceof Module) {
- ((Module) o).configure(this);
+ if (o instanceof Module module) {
+ module.configure(this);
} else if (o instanceof Iterable) {
add(Iterables.toArray((Iterable<?>) o, Object.class));
} else {
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoader.java b/sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoader.java
index 0da6c64a26c..8096cd012db 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoader.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoader.java
@@ -27,8 +27,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang.SystemUtils;
-import org.sonar.api.Plugin;
import org.slf4j.LoggerFactory;
+import org.sonar.api.Plugin;
import org.sonar.updatecenter.common.Version;
import static java.util.Collections.singleton;
@@ -142,9 +142,9 @@ public class PluginClassLoader {
public void unload(Collection<Plugin> plugins) {
for (Plugin plugin : plugins) {
ClassLoader classLoader = plugin.getClass().getClassLoader();
- if (classLoader instanceof Closeable && classLoader != classloaderFactory.baseClassLoader()) {
+ if (classLoader instanceof Closeable closeable && classLoader != classloaderFactory.baseClassLoader()) {
try {
- ((Closeable) classLoader).close();
+ closeable.close();
} catch (Exception e) {
LoggerFactory.getLogger(getClass()).error("Fail to close classloader " + classLoader.toString(), e);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/PriorityBeanFactory.java b/sonar-core/src/main/java/org/sonar/core/platform/PriorityBeanFactory.java
index 37be85d7999..b0e9b61a216 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/PriorityBeanFactory.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/PriorityBeanFactory.java
@@ -22,7 +22,6 @@ package org.sonar.core.platform;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.springframework.beans.BeanWrapper;
@@ -45,7 +44,7 @@ public class PriorityBeanFactory extends DefaultListableBeanFactory {
List<Bean> candidateBeans = candidates.entrySet().stream()
.filter(e -> e.getValue() != null)
.map(e -> new Bean(e.getKey(), e.getValue()))
- .collect(Collectors.toList());
+ .toList();
List<Bean> beansAfterPriority = highestPriority(candidateBeans, b -> getPriority(b.getInstance()));
if (beansAfterPriority.isEmpty()) {
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/SpringComponentContainer.java b/sonar-core/src/main/java/org/sonar/core/platform/SpringComponentContainer.java
index 142b5780483..079bc8b19cc 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/SpringComponentContainer.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/SpringComponentContainer.java
@@ -98,8 +98,8 @@ public class SpringComponentContainer implements StartableContainer {
}
context.registerBean(componentKeys.ofClass(clazz), clazz);
declareExtension("", o);
- } else if (o instanceof Module) {
- ((Module) o).configure(this);
+ } else if (o instanceof Module module) {
+ module.configure(this);
} else if (o instanceof Iterable) {
add(Iterables.toArray((Iterable<?>) o, Object.class));
} else {
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/StartableBeanPostProcessor.java b/sonar-core/src/main/java/org/sonar/core/platform/StartableBeanPostProcessor.java
index e2d25d8e1ee..81bc632008e 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/StartableBeanPostProcessor.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/StartableBeanPostProcessor.java
@@ -19,8 +19,8 @@
*/
package org.sonar.core.platform;
-import org.sonar.api.Startable;
import org.slf4j.LoggerFactory;
+import org.sonar.api.Startable;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
import org.springframework.lang.Nullable;
@@ -29,8 +29,8 @@ public class StartableBeanPostProcessor implements DestructionAwareBeanPostProce
@Override
@Nullable
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
- if (bean instanceof Startable) {
- ((Startable) bean).start();
+ if (bean instanceof Startable startable) {
+ startable.start();
}
return bean;
}
@@ -44,8 +44,8 @@ public class StartableBeanPostProcessor implements DestructionAwareBeanPostProce
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
try {
// note: Spring will call close() on AutoCloseable beans.
- if (bean instanceof Startable) {
- ((Startable) bean).stop();
+ if (bean instanceof Startable startable) {
+ startable.stop();
}
} catch (Exception e) {
LoggerFactory.getLogger(StartableBeanPostProcessor.class)
diff --git a/sonar-core/src/main/java/org/sonar/core/util/ContextException.java b/sonar-core/src/main/java/org/sonar/core/util/ContextException.java
index a0dedf8b8d5..379dc0c9032 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/ContextException.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/ContextException.java
@@ -112,15 +112,15 @@ public class ContextException extends RuntimeException {
}
public static ContextException of(Throwable t) {
- if (t instanceof ContextException) {
- return new ContextException(t.getCause()).addContext((ContextException) t);
+ if (t instanceof ContextException contextException) {
+ return new ContextException(t.getCause()).addContext(contextException);
}
return new ContextException(t);
}
public static ContextException of(String message, Throwable t) {
- if (t instanceof ContextException) {
- return new ContextException(message, t.getCause()).addContext((ContextException) t);
+ if (t instanceof ContextException contextException) {
+ return new ContextException(message, t.getCause()).addContext(contextException);
}
return new ContextException(message, t);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/util/LineReaderIterator.java b/sonar-core/src/main/java/org/sonar/core/util/LineReaderIterator.java
index a56f4dddd85..aadb47ad592 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/LineReaderIterator.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/LineReaderIterator.java
@@ -32,8 +32,8 @@ public class LineReaderIterator extends CloseableIterator<String> {
private final BufferedReader reader;
public LineReaderIterator(Reader reader) {
- if (reader instanceof BufferedReader) {
- this.reader = (BufferedReader) reader;
+ if (reader instanceof BufferedReader bufferedReader) {
+ this.reader = bufferedReader;
} else {
this.reader = new BufferedReader(reader);
}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/block/FileBlocks.java b/sonar-duplications/src/main/java/org/sonar/duplications/block/FileBlocks.java
index 2ac876651a1..898200c8b36 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/block/FileBlocks.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/block/FileBlocks.java
@@ -24,22 +24,6 @@ import java.util.List;
/**
* Represents all blocks in a file.
*/
-public final class FileBlocks {
-
- private final String resourceId;
- private final List<Block> blocks;
-
- public FileBlocks(String resourceId, List<Block> blocks) {
- this.resourceId = resourceId;
- this.blocks = blocks;
- }
-
- public String resourceId() {
- return resourceId;
- }
-
- public List<Block> blocks() {
- return blocks;
- }
+public record FileBlocks(String resourceId, List<Block> blocks) {
}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/TextSet.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/TextSet.java
index 7c799001623..c48ced1f41b 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/TextSet.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/TextSet.java
@@ -69,8 +69,8 @@ public final class TextSet extends AbstractText {
@Override
public Object symbolAt(int index) {
Object obj = super.symbolAt(index);
- if (obj instanceof Block) {
- return ((Block) obj).getBlockHash();
+ if (obj instanceof Block block) {
+ return block.getBlockHash();
}
return obj;
}
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/AndPredicate.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/AndPredicate.java
index 4df4e05a72c..2239f686637 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/AndPredicate.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/AndPredicate.java
@@ -27,8 +27,6 @@ import org.sonar.api.batch.fs.FilePredicate;
import org.sonar.api.batch.fs.FileSystem.Index;
import org.sonar.api.batch.fs.InputFile;
-import static java.util.stream.Collectors.toList;
-
/**
* @since 4.2
*/
@@ -49,8 +47,8 @@ class AndPredicate extends AbstractFilePredicate implements OperatorPredicate {
continue;
} else if (filePredicate == FalsePredicate.FALSE) {
return FalsePredicate.FALSE;
- } else if (filePredicate instanceof AndPredicate) {
- result.predicates.addAll(((AndPredicate) filePredicate).predicates);
+ } else if (filePredicate instanceof AndPredicate andPredicate) {
+ result.predicates.addAll(andPredicate.predicates);
} else {
result.predicates.add(OptimizedFilePredicateAdapter.create(filePredicate));
}
@@ -97,7 +95,7 @@ class AndPredicate extends AbstractFilePredicate implements OperatorPredicate {
@Override
public List<FilePredicate> operands() {
- return predicates.stream().map(p -> (FilePredicate) p).collect(toList());
+ return predicates.stream().map(p -> (FilePredicate) p).toList();
}
}
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/OptimizedFilePredicateAdapter.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/OptimizedFilePredicateAdapter.java
index 01da55d7730..6ea67e615a1 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/OptimizedFilePredicateAdapter.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/OptimizedFilePredicateAdapter.java
@@ -36,8 +36,8 @@ public class OptimizedFilePredicateAdapter extends AbstractFilePredicate {
}
public static OptimizedFilePredicate create(FilePredicate predicate) {
- if (predicate instanceof OptimizedFilePredicate) {
- return (OptimizedFilePredicate) predicate;
+ if (predicate instanceof OptimizedFilePredicate optimizedFilePredicate) {
+ return optimizedFilePredicate;
} else {
return new OptimizedFilePredicateAdapter(predicate);
}
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/OrPredicate.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/OrPredicate.java
index c9ab3ad5b40..3c3817c33f1 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/OrPredicate.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/OrPredicate.java
@@ -45,8 +45,8 @@ class OrPredicate extends AbstractFilePredicate implements OperatorPredicate {
return TruePredicate.TRUE;
} else if (filePredicate == FalsePredicate.FALSE) {
continue;
- } else if (filePredicate instanceof OrPredicate) {
- result.predicates.addAll(((OrPredicate) filePredicate).predicates);
+ } else if (filePredicate instanceof OrPredicate orPredicate) {
+ result.predicates.addAll(orPredicate.predicates);
} else {
result.predicates.add(filePredicate);
}
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRules.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRules.java
index efac94ac794..60c2722c989 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRules.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRules.java
@@ -79,7 +79,7 @@ public class DefaultActiveRules implements ActiveRules {
@Override
public Collection<ActiveRule> findAll() {
- return activeRulesByRepository.entrySet().stream().flatMap(x -> x.getValue().stream()).collect(Collectors.toList());
+ return activeRulesByRepository.entrySet().stream().flatMap(x -> x.getValue().stream()).toList();
}
@Override
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/AbstractDefaultIssue.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/AbstractDefaultIssue.java
index 5218d874c36..cea5d4686c4 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/AbstractDefaultIssue.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/AbstractDefaultIssue.java
@@ -25,7 +25,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.batch.fs.InputComponent;
import org.sonar.api.batch.fs.internal.DefaultInputDir;
@@ -97,12 +96,10 @@ public abstract class AbstractDefaultIssue<T extends AbstractDefaultIssue> exten
InputComponent component = location.inputComponent();
Optional<Path> dirOrModulePath = Optional.empty();
- if (component instanceof DefaultInputDir) {
- DefaultInputDir dirComponent = (DefaultInputDir) component;
- dirOrModulePath = Optional.of(project.getBaseDir().relativize(dirComponent.path()));
- } else if (component instanceof DefaultInputModule && !Objects.equals(project.key(), component.key())) {
- DefaultInputModule moduleComponent = (DefaultInputModule) component;
- dirOrModulePath = Optional.of(project.getBaseDir().relativize(moduleComponent.getBaseDir()));
+ if (component instanceof DefaultInputDir defaultInputDir) {
+ dirOrModulePath = Optional.of(project.getBaseDir().relativize(defaultInputDir.path()));
+ } else if (component instanceof DefaultInputModule defaultInputModule && !Objects.equals(project.key(), component.key())) {
+ dirOrModulePath = Optional.of(project.getBaseDir().relativize(defaultInputModule.getBaseDir()));
}
if (dirOrModulePath.isPresent()) {
@@ -122,7 +119,7 @@ public abstract class AbstractDefaultIssue<T extends AbstractDefaultIssue> exten
List<NewMessageFormatting> paddedFormattings = location.messageFormattings().stream()
.map(m -> padMessageFormatting(m, prefixMessage.length()))
- .collect(Collectors.toList());
+ .toList();
fixedLocation.message(fullMessage.toString(), paddedFormattings);
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Settings.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Settings.java
index bedda5549dc..45f084a2a24 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Settings.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Settings.java
@@ -457,7 +457,7 @@ public abstract class Settings extends org.sonar.api.config.Settings {
public List<String> getKeysStartingWith(String prefix) {
return getProperties().keySet().stream()
.filter(key -> StringUtils.startsWith(key, prefix))
- .collect(Collectors.toList());
+ .toList();
}
}
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/SimpleGetRequest.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/SimpleGetRequest.java
index 6c5df649c61..2e6d7cce1c0 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/SimpleGetRequest.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/SimpleGetRequest.java
@@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.io.IOUtils;
@@ -91,7 +90,7 @@ public class SimpleGetRequest extends Request {
return null;
}
- return Arrays.stream(value.split(",")).map(String::trim).filter(x -> !x.isEmpty()).collect(Collectors.toList());
+ return Arrays.stream(value.split(",")).map(String::trim).filter(x -> !x.isEmpty()).toList();
}
@Override
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java
index af00beb1ef0..7505018c5cf 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java
@@ -23,7 +23,6 @@ import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.server.ws.LocalConnector;
@@ -132,7 +131,7 @@ public abstract class ValidatingRequest extends Request {
List<String> values = Arrays.stream(value.split(COMMA_SPLITTER))
.map(String::trim)
.filter(s -> !s.isEmpty())
- .collect(Collectors.toList());
+ .toList();
return validateValues(values, definition);
}
@@ -146,7 +145,7 @@ public abstract class ValidatingRequest extends Request {
return values.stream()
.filter(s -> !s.isEmpty())
.map(value -> Enum.valueOf(enumClass, value))
- .collect(Collectors.toList());
+ .toList();
}
@CheckForNull
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java
index 12ba62bb5b9..7f218967916 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java
@@ -29,7 +29,6 @@ import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Random;
-import java.util.stream.Collectors;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
@@ -1254,7 +1253,7 @@ public class FileSystemMediumIT {
}
private static void assertAnalysedFiles(AnalysisResult result, String... files) {
- assertThat(result.inputFiles().stream().map(InputFile::toString).collect(Collectors.toList())).contains(files);
+ assertThat(result.inputFiles().stream().map(InputFile::toString).toList()).contains(files);
}
private File createDir(File parentDir, String name, boolean isReadable) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
index 62eb7c619af..70179b7b42f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
@@ -82,8 +82,8 @@ public final class Batch {
Throwable y = t;
do {
- if (y instanceof MessageException) {
- return (MessageException) y;
+ if (y instanceof MessageException messageException) {
+ return messageException;
}
y = y.getCause();
} while (y != null);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionary.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionary.java
index 91f1a12842a..07faa102337 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionary.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionary.java
@@ -27,7 +27,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.apache.commons.lang.ClassUtils;
import org.sonar.api.batch.DependedUpon;
@@ -103,7 +102,7 @@ public abstract class AbstractExtensionDictionary {
return (Collection<T>) sortedList.stream()
.filter(extensions::contains)
- .collect(Collectors.toList());
+ .toList();
}
/**
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionary.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionary.java
index fe460fd7573..a59584ee5cc 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionary.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionary.java
@@ -20,7 +20,6 @@
package org.sonar.scanner.bootstrap;
import java.util.Collection;
-import java.util.stream.Collectors;
import org.sonar.api.batch.postjob.PostJob;
import org.sonar.api.batch.postjob.PostJobContext;
import org.sonar.core.platform.ExtensionContainer;
@@ -43,6 +42,6 @@ public class PostJobExtensionDictionary extends AbstractExtensionDictionary {
return result.stream()
.map(j -> new PostJobWrapper(j, postJobContext, postJobOptimizer))
.filter(PostJobWrapper::shouldExecute)
- .collect(Collectors.toList());
+ .toList();
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginRepository.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginRepository.java
index e96eb0889f4..af61c721555 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginRepository.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginRepository.java
@@ -24,10 +24,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
-import org.sonar.api.Plugin;
-import org.sonar.api.Startable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.sonar.api.Plugin;
+import org.sonar.api.Startable;
import org.sonar.core.platform.ExplodedPlugin;
import org.sonar.core.platform.PluginClassLoader;
import org.sonar.core.platform.PluginInfo;
@@ -35,7 +35,6 @@ import org.sonar.core.platform.PluginJarExploder;
import org.sonar.core.platform.PluginRepository;
import org.sonar.core.plugin.PluginType;
-import static java.util.stream.Collectors.toList;
import static org.sonar.api.utils.Preconditions.checkState;
/**
@@ -113,15 +112,15 @@ public class ScannerPluginRepository implements PluginRepository, Startable {
@Override
public Collection<PluginInfo> getPluginInfos() {
- return pluginsByKeys.values().stream().map(ScannerPlugin::getInfo).collect(toList());
+ return pluginsByKeys.values().stream().map(ScannerPlugin::getInfo).toList();
}
public Collection<PluginInfo> getExternalPluginsInfos() {
- return pluginsByKeys.values().stream().filter(p -> p.getType() == PluginType.EXTERNAL).map(ScannerPlugin::getInfo).collect(toList());
+ return pluginsByKeys.values().stream().filter(p -> p.getType() == PluginType.EXTERNAL).map(ScannerPlugin::getInfo).toList();
}
public Collection<PluginInfo> getBundledPluginsInfos() {
- return pluginsByKeys.values().stream().filter(p -> p.getType() == PluginType.BUNDLED).map(ScannerPlugin::getInfo).collect(toList());
+ return pluginsByKeys.values().stream().filter(p -> p.getType() == PluginType.BUNDLED).map(ScannerPlugin::getInfo).toList();
}
@Override
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoader.java
index dab9488a737..c145fc4de04 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoader.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoader.java
@@ -22,7 +22,6 @@ package org.sonar.scanner.cache;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
-import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import java.util.zip.GZIPInputStream;
import org.sonar.api.scanner.fs.InputProject;
@@ -103,7 +102,7 @@ public class DefaultAnalysisCacheLoader implements AnalysisCacheLoader {
public SensorCacheData read(InputStream is) {
Iterable<SensorCacheEntry> it = () -> Protobuf.readStream(is, SensorCacheEntry.parser());
- return new SensorCacheData(StreamSupport.stream(it.spliterator(), false).collect(Collectors.toList()));
+ return new SensorCacheData(StreamSupport.stream(it.spliterator(), false).toList());
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/CiConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/CiConfigurationProvider.java
index 37859742ddd..58917ef61c0 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/CiConfigurationProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/CiConfigurationProvider.java
@@ -22,7 +22,6 @@ package org.sonar.scanner.ci;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.config.Configuration;
@@ -43,10 +42,10 @@ public class CiConfigurationProvider {
List<CiVendor> detectedVendors = Arrays.stream(ciVendors)
.filter(CiVendor::isDetected)
- .collect(Collectors.toList());
+ .toList();
if (detectedVendors.size() > 1) {
- List<String> names = detectedVendors.stream().map(CiVendor::getName).collect(Collectors.toList());
+ List<String> names = detectedVendors.stream().map(CiVendor::getName).toList();
throw MessageException.of("Multiple CI environments are detected: " + names + ". Please check environment variables or set property " + PROP_DISABLED + " to true.");
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
index dca4e5dae28..ea2007a59c1 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
@@ -31,7 +31,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -150,7 +149,7 @@ public class CpdExecutor {
Predicate<CloneGroup> minimumTokensPredicate = DuplicationPredicates.numberOfUnitsNotLessThan(minTokens);
filtered = duplications.stream()
.filter(minimumTokensPredicate)
- .collect(Collectors.toList());
+ .toList();
} else {
filtered = duplications;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/JavaCpdBlockIndexerSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/JavaCpdBlockIndexerSensor.java
index f135ba8c40b..5f6f9a0088e 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/JavaCpdBlockIndexerSensor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/JavaCpdBlockIndexerSensor.java
@@ -25,7 +25,6 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.List;
-import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,7 +75,7 @@ public class JavaCpdBlockIndexerSensor implements ProjectSensor {
)
).spliterator(), false)
.filter(f -> !((DefaultInputFile) f).isExcludedForDuplication())
- .collect(Collectors.toList());
+ .toList();
if (sourceFiles.isEmpty()) {
return;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java
index 38ef6e48fdd..c87db3b0584 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.InputFile;
@@ -67,7 +66,7 @@ public class SonarCpdBlockIndex extends AbstractCloneIndex {
builder.setEndTokenIndex(block.getEndUnit());
builder.setHash(block.getBlockHash().toHexString());
return builder.build();
- }).collect(Collectors.toList()));
+ }).toList());
}
for (Block block : blocks) {
mem.insert(block);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssueReportValidator.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssueReportValidator.java
index 82541cd2767..f0a57100b7a 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssueReportValidator.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssueReportValidator.java
@@ -140,7 +140,7 @@ public class ExternalIssueReportValidator {
}
private static void mandatoryField(@Nullable Object value, String fieldName, Path reportPath) {
- if (value == null || (value instanceof String && ((String) value).isEmpty())) {
+ if (value == null || (value instanceof String string && string.isEmpty())) {
throw new IllegalStateException(String.format("Failed to parse report '%s': missing mandatory field '%s'.", reportPath, fieldName));
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/RunMapper.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/RunMapper.java
index b711648d658..009af5878d2 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/RunMapper.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/RunMapper.java
@@ -37,7 +37,6 @@ import org.sonar.core.sarif.Run;
import org.sonar.core.sarif.Tool;
import static java.util.Collections.emptyList;
-import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static org.sonar.api.utils.Preconditions.checkArgument;
import static org.sonar.scanner.externalissue.sarif.RulesSeverityDetector.detectRulesSeverities;
@@ -90,7 +89,7 @@ public class RunMapper {
return Stream.concat(driverRules.stream(), extensionRules.stream())
.distinct()
.map(rule -> ruleMapper.mapRule(rule, driverName, ruleSeveritiesByRuleId.get(rule.getId()), ruleSeveritiesByRuleIdForNewCCT.get(rule.getId())))
- .collect(toList());
+ .toList();
}
private static boolean hasExtensions(Tool tool) {
@@ -103,7 +102,7 @@ public class RunMapper {
.map(result -> toNewExternalIssue(driverName, ruleSeveritiesByRuleId.get(result.getRuleId()), ruleSeveritiesByRuleIdForNewCCT.get(result.getRuleId()), result))
.filter(Optional::isPresent)
.map(Optional::get)
- .collect(toList());
+ .toList();
}
private Optional<NewExternalIssue> toNewExternalIssue(String driverName, @Nullable String ruleSeverity, @Nullable String ruleSeverityForNewTaxonomy, Result result) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java
index c8f4dce11e0..f01b46d074b 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java
@@ -24,7 +24,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import org.apache.commons.lang.StringUtils;
@@ -157,7 +156,7 @@ public class IssuePublisher {
.setEnd(m.end())
.setType(ScannerReport.MessageFormattingType.valueOf(m.type().name()))
.build())
- .collect(Collectors.toList());
+ .toList();
}
private static ScannerReport.ExternalIssue createReportExternalIssue(ExternalIssue issue, int componentRef) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java
index 5f2b993cf89..c0bd0030c94 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java
@@ -89,7 +89,7 @@ public class IssueExclusionsRegexpScanner extends CharHandler {
if (!lineExclusions.isEmpty()) {
Set<LineRange> lineRanges = convertLineExclusionsToLineRanges();
LOG.debug(" - Line exclusions found: {}", lineRanges.stream().map(LineRange::toString).collect(Collectors.joining(",")));
- inputFile.addIgnoreIssuesOnLineRanges(lineRanges.stream().map(r -> new int[] {r.from(), r.to()}).collect(Collectors.toList()));
+ inputFile.addIgnoreIssuesOnLineRanges(lineRanges.stream().map(r -> new int[] {r.from(), r.to()}).toList());
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ActiveRulesPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ActiveRulesPublisher.java
index 350823c0713..de31fac475d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ActiveRulesPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ActiveRulesPublisher.java
@@ -25,8 +25,6 @@ import org.sonar.scanner.protocol.Constants;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReportWriter;
-import static java.util.stream.Collectors.toList;
-
public class ActiveRulesPublisher implements ReportPublisherStep {
private final ActiveRules activeRules;
@@ -50,7 +48,7 @@ public class ActiveRulesPublisher implements ReportPublisherStep {
builder.setQProfileKey(input.qpKey());
builder.getMutableParamsByKey().putAll(input.params());
return builder.build();
- }).collect(toList()));
+ }).toList());
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java
index 2eaec549dd3..f2fd23ce80c 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java
@@ -41,8 +41,6 @@ import org.sonar.scanner.protocol.output.ScannerReportWriter;
import org.sonar.scanner.scan.ProjectServerSettings;
import org.sonar.scanner.scan.filesystem.InputComponentStore;
-import static java.util.stream.Collectors.toList;
-
public class AnalysisContextReportPublisher {
private static final String KEY_VALUE_FORMAT = " - %s=%s";
@@ -124,7 +122,7 @@ public class AnalysisContextReportPublisher {
}
private void writeScannerProps(BufferedWriter fileWriter, Map<String, String> props) throws IOException {
- for (Map.Entry<String, String> prop : props.entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey)).collect(toList())) {
+ for (Map.Entry<String, String> prop : props.entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey)).toList()) {
if (isSystemProp(prop.getKey()) || isEnvVariable(prop.getKey()) || !isSqProp(prop.getKey())) {
continue;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisWarningsPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisWarningsPublisher.java
index 42801ed5ab1..18d7790fca8 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisWarningsPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisWarningsPublisher.java
@@ -20,7 +20,6 @@
package org.sonar.scanner.report;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.scanner.notifications.DefaultAnalysisWarnings;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReportWriter;
@@ -41,7 +40,7 @@ public class AnalysisWarningsPublisher implements ReportPublisherStep {
}
writer.writeAnalysisWarnings(warnings.stream()
.map(AnalysisWarningsPublisher::toProtobufAnalysisWarning)
- .collect(Collectors.toList()));
+ .toList());
}
private static ScannerReport.AnalysisWarning toProtobufAnalysisWarning(DefaultAnalysisWarnings.Message message) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ChangedLinesPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ChangedLinesPublisher.java
index d523a7b854e..4564c96dee7 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ChangedLinesPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ChangedLinesPublisher.java
@@ -133,8 +133,8 @@ public class ChangedLinesPublisher implements ReportPublisherStep {
@CheckForNull
private static Map<Path, Set<Integer>> getBranchChangedLinesByScm(ScmProvider scmProvider, String targetScmBranch, Path rootBaseDir, Map<Path, ChangedFile> changedFiles) {
- if (scmProvider instanceof GitScmProvider) {
- return ((GitScmProvider) scmProvider).branchChangedLinesWithFileMovementDetection(targetScmBranch, rootBaseDir, changedFiles);
+ if (scmProvider instanceof GitScmProvider gitScmProvider) {
+ return gitScmProvider.branchChangedLinesWithFileMovementDetection(targetScmBranch, rootBaseDir, changedFiles);
}
return scmProvider.branchChangedLines(targetScmBranch, rootBaseDir, changedFiles.keySet());
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ContextPropertiesPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ContextPropertiesPublisher.java
index 4ae36e62454..115bd2ca965 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ContextPropertiesPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ContextPropertiesPublisher.java
@@ -23,7 +23,6 @@ import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import org.sonar.api.batch.scm.ScmProvider;
import org.sonar.core.config.CorePropertyDefinitions;
import org.sonar.scanner.ci.CiConfiguration;
@@ -59,7 +58,7 @@ public class ContextPropertiesPublisher implements ReportPublisherStep {
properties.addAll(config.getProperties().entrySet()
.stream()
.filter(e -> e.getKey().startsWith(CorePropertyDefinitions.SONAR_ANALYSIS))
- .collect(Collectors.toList()));
+ .toList());
writer.writeContextProperties(properties
.stream()
@@ -67,7 +66,7 @@ public class ContextPropertiesPublisher implements ReportPublisherStep {
.setKey(e.getKey())
.setValue(e.getValue())
.build())
- .collect(Collectors.toList()));
+ .toList());
}
private Map.Entry<String, String> constructScmInfo() {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultProjectRepositoriesLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultProjectRepositoriesLoader.java
index 6f6026d55ed..a62897c1e2b 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultProjectRepositoriesLoader.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultProjectRepositoriesLoader.java
@@ -77,7 +77,7 @@ public class DefaultProjectRepositoriesLoader implements ProjectRepositoriesLoad
Throwable t = e;
do {
- if (t instanceof HttpException && ((HttpException) t).code() == HttpURLConnection.HTTP_NOT_FOUND) {
+ if (t instanceof HttpException httpException && httpException.code() == HttpURLConnection.HTTP_NOT_FOUND) {
return false;
}
t = t.getCause();
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositories.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositories.java
index 2991a863044..328e062acd2 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositories.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositories.java
@@ -37,8 +37,8 @@ public abstract class ProjectRepositories {
@CheckForNull
public FileData fileData(String moduleKeyWithBranch, DefaultInputFile inputFile) {
- if (this instanceof SingleProjectRepository) {
- return ((SingleProjectRepository) this).fileData(inputFile.getProjectRelativePath());
+ if (this instanceof SingleProjectRepository singleProjectRepository) {
+ return singleProjectRepository.fileData(inputFile.getProjectRelativePath());
} else {
return ((MultiModuleProjectRepository) this).fileData(moduleKeyWithBranch, inputFile.getModuleRelativePath());
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/DefaultLanguagesRepository.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/DefaultLanguagesRepository.java
index 353c7b2d492..1812a3dbde6 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/DefaultLanguagesRepository.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/language/DefaultLanguagesRepository.java
@@ -21,7 +21,6 @@ package org.sonar.scanner.repository.language;
import java.util.Arrays;
import java.util.Collection;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.concurrent.Immutable;
import org.sonar.api.Startable;
@@ -64,7 +63,7 @@ public class DefaultLanguagesRepository implements LanguagesRepository, Startabl
public Collection<Language> all() {
return Arrays.stream(languages.all())
.map(Language::new)
- .collect(Collectors.toList());
+ .toList();
}
@Override
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
index 05c051f7190..7560840c54d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
@@ -51,7 +51,6 @@ import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer;
import org.sonar.scanner.issue.ignore.pattern.IssueInclusionPatternInitializer;
import static java.util.Arrays.asList;
-import static java.util.stream.Collectors.toList;
import static org.sonar.api.config.internal.MultivalueProperty.parseAsCsv;
/**
@@ -110,7 +109,7 @@ public class ProjectReactorBuilder {
* Properties that must not be passed from the parent project to its children.
*/
private static final List<String> NON_HERITED_PROPERTIES_FOR_CHILD = Stream.concat(Stream.of(PROPERTY_PROJECT_BASEDIR, CoreProperties.WORKING_DIRECTORY, PROPERTY_MODULES,
- CoreProperties.PROJECT_DESCRIPTION_PROPERTY), UNSUPPORTED_PROPS_FOR_MODULES.stream()).collect(toList());
+ CoreProperties.PROJECT_DESCRIPTION_PROPERTY), UNSUPPORTED_PROPS_FOR_MODULES.stream()).toList();
private final ScannerProperties scannerProps;
private final AnalysisWarnings analysisWarnings;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractCoverageAndDuplicationExclusions.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractCoverageAndDuplicationExclusions.java
index 0f059dbc2cf..333c097cd22 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractCoverageAndDuplicationExclusions.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractCoverageAndDuplicationExclusions.java
@@ -24,13 +24,11 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.Immutable;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.utils.WildcardPattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.sonar.api.CoreProperties;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-
-import static java.util.stream.Collectors.toList;
+import org.sonar.api.utils.WildcardPattern;
@Immutable
public abstract class AbstractCoverageAndDuplicationExclusions {
@@ -45,9 +43,9 @@ public abstract class AbstractCoverageAndDuplicationExclusions {
public AbstractCoverageAndDuplicationExclusions(Function<String, String[]> configProvider, Function<DefaultInputFile, String> pathExtractor) {
this.pathExtractor = pathExtractor;
coverageExclusionConfig = configProvider.apply(CoreProperties.PROJECT_COVERAGE_EXCLUSIONS_PROPERTY);
- coverageExclusionPatterns = Stream.of(coverageExclusionConfig).map(WildcardPattern::create).collect(toList());
+ coverageExclusionPatterns = Stream.of(coverageExclusionConfig).map(WildcardPattern::create).toList();
duplicationExclusionConfig = configProvider.apply(CoreProperties.CPD_EXCLUSIONS);
- duplicationExclusionPatterns = Stream.of(duplicationExclusionConfig).map(WildcardPattern::create).collect(toList());
+ duplicationExclusionPatterns = Stream.of(duplicationExclusionConfig).map(WildcardPattern::create).toList();
}
public String[] getCoverageExclusionConfig() {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java
index a6c2f4d382c..30965c22908 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java
@@ -87,8 +87,8 @@ public class ScmChangedFilesProvider {
}
private static Set<ChangedFile> getChangedFilesByScm(ScmProvider scmProvider, String targetBranchName, Path rootBaseDir) {
- if (scmProvider instanceof GitScmProvider) {
- return ((GitScmProvider) scmProvider).branchChangedFilesWithFileMovementDetection(targetBranchName, rootBaseDir);
+ if (scmProvider instanceof GitScmProvider gitScmProvider) {
+ return gitScmProvider.branchChangedFilesWithFileMovementDetection(targetBranchName, rootBaseDir);
}
return toChangedFiles(scmProvider.branchChangedFiles(targetBranchName, rootBaseDir));
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
index e679d683df9..47a44520515 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
@@ -79,7 +79,6 @@ import org.sonar.scanner.repository.ContextPropertiesCache;
import org.sonar.scanner.scan.branch.BranchConfiguration;
import static java.lang.Math.max;
-import static java.util.stream.Collectors.toList;
import static org.sonar.api.measures.CoreMetrics.COMMENT_LINES_DATA_KEY;
import static org.sonar.api.measures.CoreMetrics.LINES_KEY;
import static org.sonar.api.measures.CoreMetrics.PUBLIC_DOCUMENTED_API_DENSITY_KEY;
@@ -151,7 +150,7 @@ public class DefaultSensorStorage implements SensorStorage {
defaultInputFile.setPublished(true);
}
- if (component instanceof InputDir || (component instanceof DefaultInputModule && ((DefaultInputModule) component).definition().getParent() != null)) {
+ if (component instanceof InputDir || (component instanceof DefaultInputModule defaultInputModule && defaultInputModule.definition().getParent() != null)) {
logOnce(measure.metric().key(), "Storing measures on folders or modules is deprecated. Provided value of metric '{}' is ignored.", measure.metric().key());
return;
}
@@ -228,8 +227,7 @@ public class DefaultSensorStorage implements SensorStorage {
*/
@Override
public void store(Issue issue) {
- if (issue.primaryLocation().inputComponent() instanceof DefaultInputFile) {
- DefaultInputFile defaultInputFile = (DefaultInputFile) issue.primaryLocation().inputComponent();
+ if (issue.primaryLocation().inputComponent() instanceof DefaultInputFile defaultInputFile) {
if (shouldSkipStorage(defaultInputFile)) {
return;
}
@@ -243,8 +241,7 @@ public class DefaultSensorStorage implements SensorStorage {
*/
@Override
public void store(ExternalIssue externalIssue) {
- if (externalIssue.primaryLocation().inputComponent() instanceof DefaultInputFile) {
- DefaultInputFile defaultInputFile = (DefaultInputFile) externalIssue.primaryLocation().inputComponent();
+ if (externalIssue.primaryLocation().inputComponent() instanceof DefaultInputFile defaultInputFile) {
defaultInputFile.setPublished(true);
}
moduleIssues.initAndAddExternalIssue(externalIssue);
@@ -286,7 +283,7 @@ public class DefaultSensorStorage implements SensorStorage {
.map(e -> ScannerReport.Impact.newBuilder()
.setSoftwareQuality(e.getKey().name())
.setSeverity(e.getValue().name()).build())
- .collect(toList());
+ .toList();
}
@Override
@@ -315,7 +312,7 @@ public class DefaultSensorStorage implements SensorStorage {
.build());
builder.setType(ScannerReportUtils.toProtocolType(input.getTextType()));
return builder.build();
- }).collect(toList()));
+ }).toList());
}
@Override
@@ -352,7 +349,7 @@ public class DefaultSensorStorage implements SensorStorage {
.build());
}
return builder.build();
- }).collect(Collectors.toList()));
+ }).toList());
}
@Override
@@ -370,7 +367,7 @@ public class DefaultSensorStorage implements SensorStorage {
(value, builder) -> builder.setCoveredConditions(max(value, builder.getCoveredConditions())));
reportPublisher.getWriter().writeComponentCoverage(inputFile.scannerId(),
- coveragePerLine.values().stream().map(ScannerReport.LineCoverage.Builder::build).collect(Collectors.toList()));
+ coveragePerLine.values().stream().map(ScannerReport.LineCoverage.Builder::build).toList());
}
@@ -461,7 +458,7 @@ public class DefaultSensorStorage implements SensorStorage {
.setStartOffset(range.start().lineOffset())
.setEndOffset(range.end().lineOffset())
.build())
- .collect(Collectors.toList());
+ .toList();
writer.writeComponentSignificantCode(componentRef, protobuf);
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorExtensionDictionary.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorExtensionDictionary.java
index d8de7909936..27ca20314c8 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorExtensionDictionary.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorExtensionDictionary.java
@@ -20,7 +20,6 @@
package org.sonar.scanner.sensor;
import java.util.Collection;
-import java.util.stream.Collectors;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.core.platform.ExtensionContainer;
import org.sonar.scanner.bootstrap.AbstractExtensionDictionary;
@@ -48,6 +47,6 @@ public class ModuleSensorExtensionDictionary extends AbstractExtensionDictionary
return result.stream()
.map(s -> new ModuleSensorWrapper(s, sensorContext, sensorOptimizer, fileSystem, branchConfiguration))
.filter(s -> global == s.isGlobal() && s.shouldExecute())
- .collect(Collectors.toList());
+ .toList();
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorExtensionDictionary.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorExtensionDictionary.java
index 236857793b6..3853521cf2f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorExtensionDictionary.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorExtensionDictionary.java
@@ -21,7 +21,6 @@ package org.sonar.scanner.sensor;
import java.util.Collection;
import java.util.List;
-import java.util.stream.Collectors;
import org.sonar.api.scanner.sensor.ProjectSensor;
import org.sonar.core.platform.SpringComponentContainer;
import org.sonar.scanner.bootstrap.AbstractExtensionDictionary;
@@ -49,6 +48,6 @@ public class ProjectSensorExtensionDictionary extends AbstractExtensionDictionar
return result.stream()
.map(s -> new ProjectSensorWrapper(s, sensorContext, sensorOptimizer, fileSystem, branchConfiguration))
.filter(ProjectSensorWrapper::shouldExecute)
- .collect(Collectors.toList());
+ .toList();
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java
index 3178cf68327..74ad0ba414c 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java
@@ -100,7 +100,7 @@ public class CompositeBlameCommandIT {
"dummy-git-few-comitters"
);
- List<BlameAlgorithmEnum> blameStrategies = Arrays.stream(BlameAlgorithmEnum.values()).collect(Collectors.toList());
+ List<BlameAlgorithmEnum> blameStrategies = Arrays.stream(BlameAlgorithmEnum.values()).toList();
return testCases.stream()
.flatMap(t -> blameStrategies.stream().map(b -> new Object[]{t, b}))
.toArray(Object[][]::new);
@@ -128,7 +128,7 @@ public class CompositeBlameCommandIT {
Path expectedBlameFiles = new File(Utils.class.getResource("expected-blame/" + expectedBlameFolder).toURI()).toPath();
Map<Path, List<BlameLine>> expectedBlame = new HashMap<>();
- List<Path> filesInExpectedBlameFolder = Files.walk(expectedBlameFiles).filter(Files::isRegularFile).collect(Collectors.toList());
+ List<Path> filesInExpectedBlameFolder = Files.walk(expectedBlameFiles).filter(Files::isRegularFile).toList();
for (Path expectedFileBlamePath : filesInExpectedBlameFolder) {
List<BlameLine> blameLines = new ArrayList<>();
List<String> expectedBlameStrings = Files.readAllLines(expectedFileBlamePath);
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java b/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java
index d242008e947..37f1b6a98cb 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java
@@ -93,17 +93,17 @@ class JsonComparison {
if (expectedObject.getClass() != actualObject.getClass()) {
return false;
}
- if (expectedObject instanceof JSONArray) {
- return compareArrays((JSONArray) expectedObject, (JSONArray) actualObject);
+ if (expectedObject instanceof JSONArray jsonArray) {
+ return compareArrays(jsonArray, (JSONArray) actualObject);
}
- if (expectedObject instanceof JSONObject) {
- return compareObjects((JSONObject) expectedObject, (JSONObject) actualObject);
+ if (expectedObject instanceof JSONObject jsonObject) {
+ return compareObjects(jsonObject, (JSONObject) actualObject);
}
- if (expectedObject instanceof String) {
- return compareStrings((String) expectedObject, (String) actualObject);
+ if (expectedObject instanceof String string) {
+ return compareStrings(string, (String) actualObject);
}
- if (expectedObject instanceof Number) {
- return compareNumbers((Number) expectedObject, (Number) actualObject);
+ if (expectedObject instanceof Number number) {
+ return compareNumbers(number, (Number) actualObject);
}
return compareBooleans((Boolean) expectedObject, (Boolean) actualObject);
}
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlFragmentAssert.java b/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlFragmentAssert.java
index 7f460b60a60..09bc63b804b 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlFragmentAssert.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlFragmentAssert.java
@@ -26,7 +26,6 @@ import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
-import static java.util.stream.Collectors.toList;
import static org.sonar.test.html.HtmlParagraphAssert.verifyIsParagraph;
public class HtmlFragmentAssert extends AbstractAssert<HtmlFragmentAssert, String> {
@@ -45,7 +44,7 @@ public class HtmlFragmentAssert extends AbstractAssert<HtmlFragmentAssert, Strin
Document document = Jsoup.parseBodyFragment(actual);
Iterator<Element> blockIt = document.body().children().stream()
.filter(Element::isBlock)
- .collect(toList())
+ .toList()
.iterator();
Assertions.assertThat(blockIt.hasNext())
.describedAs("no bloc in fragment")
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlListAssert.java b/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlListAssert.java
index b1bf37e209f..cbb9e21dada 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlListAssert.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlListAssert.java
@@ -22,7 +22,6 @@ package org.sonar.test.html;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.assertj.core.api.Assertions;
import org.jsoup.nodes.Element;
@@ -53,7 +52,7 @@ public class HtmlListAssert extends HtmlBlockAssert<HtmlListAssert> {
.stream()
.filter(t -> t.tagName().equals("li"))
.map(Element::text)
- .collect(Collectors.toList());
+ .toList();
String[] itemTexts = Stream.concat(
Stream.of(firstItemText),
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlParagraphAssert.java b/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlParagraphAssert.java
index f00d1d46deb..0e2d59d11c1 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlParagraphAssert.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/test/html/HtmlParagraphAssert.java
@@ -153,8 +153,7 @@ public class HtmlParagraphAssert extends HtmlBlockAssert<HtmlParagraphAssert> {
} else {
currentLine.append(node.toString());
}
- } else if (node instanceof Element) {
- Element element = (Element) node;
+ } else if (node instanceof Element element) {
if (element.tagName().equals("br")) {
actualLines.add(currentLine == null ? "" : currentLine.toString());
currentLine = null;
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseRequest.java
index 6442a6d187d..8a0a4b39a20 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseRequest.java
@@ -137,7 +137,7 @@ abstract class BaseRequest<SELF extends BaseRequest<SELF>> implements WsRequest
parameters.setValues(key, values.stream()
.filter(Objects::nonNull)
.map(Object::toString)
- .collect(Collectors.toList()));
+ .toList());
return (T) this;
}
@@ -203,7 +203,7 @@ abstract class BaseRequest<SELF extends BaseRequest<SELF>> implements WsRequest
checkArgument(!isNullOrEmpty(key));
checkArgument(values != null && !values.isEmpty());
- keyValues.computeIfAbsent(key, k -> new ArrayList<>()).addAll(values.stream().map(Object::toString).filter(Objects::nonNull).collect(Collectors.toList()));
+ keyValues.computeIfAbsent(key, k -> new ArrayList<>()).addAll(values.stream().map(Object::toString).filter(Objects::nonNull).toList());
return this;
}
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java
index a4fec2726a4..b697095cae0 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java
@@ -21,6 +21,7 @@ package org.sonarqube.ws.client;
import java.io.IOException;
import java.net.Proxy;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
@@ -109,11 +110,11 @@ public class HttpConnector implements WsConnector {
@Override
public WsResponse call(WsRequest httpRequest) {
- if (httpRequest instanceof RequestWithoutPayload) {
- return executeRequest((RequestWithoutPayload) httpRequest);
+ if (httpRequest instanceof RequestWithoutPayload httpRequestWithoutPayload) {
+ return executeRequest(httpRequestWithoutPayload);
}
- if (httpRequest instanceof RequestWithPayload) {
- return executeRequest((RequestWithPayload) httpRequest);
+ if (httpRequest instanceof RequestWithPayload httpRequestWithPayload) {
+ return executeRequest(httpRequestWithPayload);
}
throw new IllegalArgumentException(format("Unsupported implementation: %s", httpRequest.getClass()));
}
@@ -213,19 +214,15 @@ public class HttpConnector implements WsConnector {
}
private Response checkRedirect(Response response, RequestWithPayload<?> postRequest) {
- switch (response.code()) {
- case HTTP_MOVED_PERM:
- case HTTP_MOVED_TEMP:
- case HTTP_TEMP_REDIRECT:
- case HTTP_PERM_REDIRECT:
- // OkHttpClient does not follow the redirect with the same HTTP method. A POST is
- // redirected to a GET. Because of that the redirect must be manually implemented.
- // See:
- // https://github.com/square/okhttp/blob/07309c1c7d9e296014268ebd155ebf7ef8679f6c/okhttp/src/main/java/okhttp3/internal/http/RetryAndFollowUpInterceptor.java#L316
- // https://github.com/square/okhttp/issues/936#issuecomment-266430151
- return followPostRedirect(response, postRequest);
- default:
- return response;
+ if (List.of(HTTP_MOVED_PERM, HTTP_MOVED_TEMP, HTTP_TEMP_REDIRECT, HTTP_PERM_REDIRECT).contains(response.code())) {
+ // OkHttpClient does not follow the redirect with the same HTTP method. A POST is
+ // redirected to a GET. Because of that the redirect must be manually implemented.
+ // See:
+ // https://github.com/square/okhttp/blob/07309c1c7d9e296014268ebd155ebf7ef8679f6c/okhttp/src/main/java/okhttp3/internal/http/RetryAndFollowUpInterceptor.java#L316
+ // https://github.com/square/okhttp/issues/936#issuecomment-266430151
+ return followPostRedirect(response, postRequest);
+ } else {
+ return response;
}
}
diff --git a/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/GroupTester.java b/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/GroupTester.java
index bf36e3b4d8e..00bff8cdccd 100644
--- a/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/GroupTester.java
+++ b/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/GroupTester.java
@@ -88,7 +88,7 @@ public class GroupTester {
public GroupTester deleteAllGenerated() {
List<String> allGroups = session.wsClient().userGroups().search(new SearchRequest()).getGroupsList().stream().map(UserGroups.Group::getName)
- .collect(Collectors.toList());
+ .toList();
allGroups.stream()
.filter(g -> g.matches("Group\\d+$"))
.forEach(g -> session.wsClient().userGroups().delete(new DeleteRequest().setName(g)));
@@ -97,7 +97,7 @@ public class GroupTester {
public GroupTester delete(UserGroups.Group... groups) {
List<String> allGroups = session.wsClient().userGroups().search(new SearchRequest()).getGroupsList().stream().map(UserGroups.Group::getName)
- .collect(Collectors.toList());
+ .toList();
stream(groups)
.filter(g -> allGroups.contains(g.getName()))
.forEach(g -> session.wsClient().userGroups().delete(new DeleteRequest().setName(g.getName())));
diff --git a/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/QGateTester.java b/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/QGateTester.java
index 232949dffa5..b7efbfc9d2f 100644
--- a/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/QGateTester.java
+++ b/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/QGateTester.java
@@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
import org.sonarqube.ws.Projects.CreateWsResponse.Project;
import org.sonarqube.ws.client.qualitygates.CreateRequest;
import org.sonarqube.ws.client.qualitygates.DestroyRequest;
@@ -54,7 +53,7 @@ public class QGateTester {
void deleteAll() {
List<ListWsResponse.QualityGate> builtInQualityGates = session.wsClient().qualitygates().list(new ListRequest()).getQualitygatesList().stream()
.filter(ListWsResponse.QualityGate::getIsBuiltIn)
- .collect(Collectors.toList());
+ .toList();
if (builtInQualityGates.size() == 1) {
session.wsClient().qualitygates().setAsDefault(new SetAsDefaultRequest().setName(builtInQualityGates.get(0).getName()));
}
diff --git a/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/QProfileTester.java b/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/QProfileTester.java
index 99202a15657..71130367f8d 100644
--- a/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/QProfileTester.java
+++ b/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/QProfileTester.java
@@ -27,7 +27,6 @@ package org.sonarqube.ws.tester;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonarqube.ws.Projects.CreateWsResponse.Project;
import org.sonarqube.ws.Qualityprofiles;
@@ -60,7 +59,7 @@ public class QProfileTester {
.filter(qp -> !qp.getIsDefault())
.filter(qp -> !qp.getIsBuiltIn())
.filter(qp -> qp.getParentKey() == null || qp.getParentKey().equals(""))
- .collect(Collectors.toList());
+ .toList();
qualityProfiles.forEach(
qp -> session.wsClient().qualityprofiles().delete(new DeleteRequest().setQualityProfile(qp.getName()).setLanguage(qp.getLanguage())));
diff --git a/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/SettingTester.java b/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/SettingTester.java
index abc45cacac0..c38b997b958 100644
--- a/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/SettingTester.java
+++ b/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/SettingTester.java
@@ -19,11 +19,9 @@
*/
package org.sonarqube.ws.tester;
-import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.sonarqube.ws.Settings;
@@ -38,7 +36,7 @@ import static java.util.Arrays.asList;
public class SettingTester {
- private static final Set<String> EMAIL_SETTINGS = ImmutableSet.of("email.smtp_host.secured", "email.smtp_port.secured", "email.smtp_secure_connection.secured",
+ private static final Set<String> EMAIL_SETTINGS = Set.of("email.smtp_host.secured", "email.smtp_port.secured", "email.smtp_secure_connection.secured",
"email.smtp_username.secured", "email.smtp_password.secured", "email.from", "email.prefix");
private final TesterSession session;
@@ -59,7 +57,7 @@ public class SettingTester {
.map(Settings.Definition::getKey)
.filter(key -> !key.equals(Tester.FORCE_AUTHENTICATION_PROPERTY_NAME)),
EMAIL_SETTINGS.stream())
- .collect(Collectors.toList());
+ .toList();
session.wsClient().settings().reset(new ResetRequest().setKeys(settingKeys));
}
diff --git a/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/UserTester.java b/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/UserTester.java
index 7966560052b..f5dbe9bb912 100644
--- a/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/UserTester.java
+++ b/sonar-ws/src/testFixtures/java/org/sonarqube/ws/tester/UserTester.java
@@ -25,7 +25,6 @@ import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonarqube.ws.UserTokens;
import org.sonarqube.ws.Users;
@@ -179,7 +178,7 @@ public class UserTester {
private Optional<Users.SearchWsResponse.User> queryForUser(String login, Predicate<Users.SearchWsResponse.User> predicate) {
List<Users.SearchWsResponse.User> users = session.wsClient().users().search(new SearchRequest().setQ(login)).getUsersList().stream()
- .filter(predicate).collect(Collectors.toList());
+ .filter(predicate).toList();
if (users.size() == 1) {
return Optional.of(users.get(0));
}