]> source.dussan.org Git - sonarqube.git/commitdiff
Code smell fix: Replacing ImmutableList from List
authorBruno Andrade <bruno@artsman.dev>
Wed, 14 Jul 2021 10:10:09 +0000 (07:10 -0300)
committersonartech <sonartech@sonarsource.com>
Thu, 29 Jul 2021 20:04:50 +0000 (20:04 +0000)
24 files changed:
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/duplication/DuplicationMeasures.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CommentMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ComplexityMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CoverageMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LanguageDistributionMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewCoverageMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewSizeMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/UnitTestMeasuresStep.java
server/sonar-db-core/src/main/java/org/sonar/db/dialect/Oracle.java
server/sonar-db-core/src/main/java/org/sonar/db/dialect/PostgreSql.java
server/sonar-db-dao/src/main/java/org/sonar/core/permission/GlobalPermissions.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ProjectLinkDto.java
server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssueChangeWSSupport.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleQueryFactory.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/ResetAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SetAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/text/MacroInterpreter.java
server/sonar-webserver/src/main/java/org/sonar/server/platform/web/RedirectFilter.java

index f156f8be540880b289962fc2b8395c2a4f70469a..fcf48afb20b9c504b704cc7a64558bfba33c096e 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.ce.task.projectanalysis.duplication;
 
-import com.google.common.collect.ImmutableList;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Optional;
 import java.util.Set;
 import javax.annotation.CheckForNull;
@@ -47,7 +47,7 @@ import static org.sonar.api.measures.CoreMetrics.DUPLICATED_LINES_KEY;
 import static org.sonar.api.measures.CoreMetrics.LINES_KEY;
 
 public class DuplicationMeasures {
-  protected final ImmutableList<Formula> formulas;
+  protected final List<Formula> formulas;
   protected final TreeRootHolder treeRootHolder;
   protected final MetricRepository metricRepository;
   protected final MeasureRepository measureRepository;
@@ -60,7 +60,7 @@ public class DuplicationMeasures {
     this.measureRepository = measureRepository;
     // will be null for views
     this.duplicationRepository = duplicationRepository;
-    this.formulas = ImmutableList.of(new DuplicationFormula());
+    this.formulas = List.of(new DuplicationFormula());
   }
 
   /**
index 290dab0f08537d9204bc24977a4494c16e5e0433..505e53851b3a1ca411230e47253df2af00a137ce 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.ce.task.projectanalysis.step;
 
-import com.google.common.collect.ImmutableList;
+import java.util.List;
 import java.util.Optional;
 import org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit;
 import org.sonar.ce.task.projectanalysis.component.PathAwareCrawler;
@@ -52,15 +52,16 @@ public class CommentMeasuresStep implements ComputationStep {
   private final TreeRootHolder treeRootHolder;
   private final MetricRepository metricRepository;
   private final MeasureRepository measureRepository;
-  private final ImmutableList<Formula> formulas;
+  private final List<Formula> formulas;
 
   public CommentMeasuresStep(TreeRootHolder treeRootHolder, MetricRepository metricRepository, MeasureRepository measureRepository) {
     this.treeRootHolder = treeRootHolder;
     this.metricRepository = metricRepository;
     this.measureRepository = measureRepository;
-    this.formulas = ImmutableList.of(
+    this.formulas = List.of(
       new DocumentationFormula(),
-      new CommentDensityFormula());
+      new CommentDensityFormula()
+    );
   }
 
   @Override
index 45ea3787f8e8d84aa7e095d6e6ef7f55a9687de2..52e5fe825775ab043154deaf5e268e7879f851b9 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.ce.task.projectanalysis.step;
 
-import com.google.common.collect.ImmutableList;
+import java.util.List;
 import org.sonar.ce.task.projectanalysis.component.PathAwareCrawler;
 import org.sonar.ce.task.projectanalysis.component.TreeRootHolder;
 import org.sonar.ce.task.projectanalysis.formula.AverageFormula;
@@ -48,8 +48,7 @@ import static org.sonar.ce.task.projectanalysis.formula.SumFormula.createIntSumF
  * Computes complexity measures on files and then aggregates them on higher components.
  */
 public class ComplexityMeasuresStep implements ComputationStep {
-
-  private static final ImmutableList<Formula> FORMULAS = ImmutableList.of(
+  private static final List<Formula> FORMULAS = List.of(
     createIntSumFormula(COMPLEXITY_KEY),
     createIntSumFormula(COMPLEXITY_IN_CLASSES_KEY),
     createIntSumFormula(COMPLEXITY_IN_FUNCTIONS_KEY),
@@ -67,7 +66,8 @@ public class ComplexityMeasuresStep implements ComputationStep {
     AverageFormula.Builder.newBuilder().setOutputMetricKey(FUNCTION_COMPLEXITY_KEY)
       .setMainMetricKey(COMPLEXITY_IN_FUNCTIONS_KEY)
       .setByMetricKey(FUNCTIONS_KEY)
-      .build());
+      .build()
+  );
 
   private final TreeRootHolder treeRootHolder;
   private final MetricRepository metricRepository;
index bc5acfc0c44b0bd2b4e5f631f78440882d87ad53..ecaad9b10bd9416ccf5d2ef9f47500effbef6b72 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.ce.task.projectanalysis.step;
 
-import com.google.common.collect.ImmutableList;
+import java.util.List;
 import org.sonar.ce.task.projectanalysis.batch.BatchReportReader;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit;
@@ -55,14 +55,15 @@ import static org.sonar.ce.task.projectanalysis.formula.SumFormula.createIntSumF
  * Computes coverage measures on files and then aggregates them on higher components.
  */
 public class CoverageMeasuresStep implements ComputationStep {
-  private static final ImmutableList<Formula> COVERAGE_FORMULAS = ImmutableList.of(
+  private static final List<Formula> COVERAGE_FORMULAS = List.of(
     createIntSumFormula(LINES_TO_COVER_KEY),
     createIntSumFormula(UNCOVERED_LINES_KEY),
     createIntSumFormula(CONDITIONS_TO_COVER_KEY),
     createIntSumFormula(UNCOVERED_CONDITIONS_KEY),
     new CodeCoverageFormula(),
     new BranchCoverageFormula(),
-    new LineCoverageFormula());
+    new LineCoverageFormula()
+  );
 
   private final TreeRootHolder treeRootHolder;
   private final MetricRepository metricRepository;
index 129e7fdc7cb5459777bedb973dc440c1f273cd0f..5d858fac4accd95a5e6233d800984bc3e510c94a 100644 (file)
@@ -20,9 +20,9 @@
 package org.sonar.ce.task.projectanalysis.step;
 
 import com.google.common.base.Function;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Multiset;
 import com.google.common.collect.TreeMultiset;
+import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import javax.annotation.Nonnull;
@@ -50,10 +50,9 @@ import static org.sonar.api.utils.KeyValueFormat.newStringConverter;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
 
 public class LanguageDistributionMeasuresStep implements ComputationStep {
-
   private static final String UNKNOWN_LANGUAGE_KEY = "<null>";
 
-  private static final ImmutableList<Formula> FORMULAS = ImmutableList.of(new LanguageDistributionFormula());
+  private static final List<Formula> FORMULAS = List.of(new LanguageDistributionFormula());
 
   private static final String[] LANGUAGE_DISTRIBUTION_FORMULA_METRICS = new String[] {NCLOC_LANGUAGE_DISTRIBUTION_KEY};
 
index 639d078ff082fa01fc8dc2925fdf0c0495945348..bbb6777d20a5f83d5ef123620ab40e3a0525609a 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.ce.task.projectanalysis.step;
 
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import java.util.Collections;
 import java.util.List;
@@ -60,12 +59,12 @@ import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilde
  * Computes measures related to the New Coverage. These measures do not have values, only variations.
  */
 public class NewCoverageMeasuresStep implements ComputationStep {
-
-  private static final List<Formula> FORMULAS = ImmutableList.of(
+  private static final List<Formula> FORMULAS = List.of(
     // UT coverage
     new NewCoverageFormula(),
     new NewBranchCoverageFormula(),
-    new NewLineCoverageFormula());
+    new NewLineCoverageFormula()
+  );
 
   private final TreeRootHolder treeRootHolder;
   private final MetricRepository metricRepository;
index 24402acdc8409a09a78b14abd309ad5486d11535..6a33321b52b6cfb4847dedf81bc43493103fe1a7 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.ce.task.projectanalysis.step;
 
-import com.google.common.collect.ImmutableList;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Optional;
 import java.util.Set;
 import java.util.stream.IntStream;
@@ -53,7 +53,6 @@ import static org.sonar.api.measures.CoreMetrics.NEW_LINES_KEY;
  * Computes measures on new code related to the size
  */
 public class NewSizeMeasuresStep implements ComputationStep {
-
   private final TreeRootHolder treeRootHolder;
   private final MetricRepository metricRepository;
   private final MeasureRepository measureRepository;
@@ -76,7 +75,7 @@ public class NewSizeMeasuresStep implements ComputationStep {
   public void execute(ComputationStep.Context context) {
     new PathAwareCrawler<>(
       FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
-        .buildFor(ImmutableList.of(duplicationFormula)))
+        .buildFor(List.of(duplicationFormula)))
       .visit(treeRootHolder.getRoot());
   }
 
index 3eab05cf3f3c232495b3c1350030c6674532cf6e..eb1d1bae8934c07be086809c15b6bf3a2f1ef1ed 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.ce.task.projectanalysis.step;
 
-import com.google.common.collect.ImmutableList;
+import java.util.List;
 import java.util.Optional;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.component.PathAwareCrawler;
@@ -47,10 +47,9 @@ import static org.sonar.api.measures.CoreMetrics.TEST_SUCCESS_DENSITY_KEY;
  * Computes unit test measures on files and then aggregates them on higher components.
  */
 public class UnitTestMeasuresStep implements ComputationStep {
-
   private static final String[] METRICS = new String[] {TESTS_KEY, TEST_ERRORS_KEY, TEST_FAILURES_KEY, SKIPPED_TESTS_KEY, TEST_SUCCESS_DENSITY_KEY, TEST_EXECUTION_TIME_KEY};
 
-  private static final ImmutableList<Formula> FORMULAS = ImmutableList.of(new UnitTestsFormula());
+  private static final List<Formula> FORMULAS = List.of(new UnitTestsFormula());
 
   private final TreeRootHolder treeRootHolder;
   private final MetricRepository metricRepository;
index 36731c12f77ecadff1a3e30eb2ad2e0ce6edd978..e374d7934b194f2faa4e913d57855f6489d52b7f 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.db.dialect;
 
-import com.google.common.collect.ImmutableList;
 import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
 import java.util.List;
@@ -28,12 +27,10 @@ import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.Version;
 
 public class Oracle extends AbstractDialect {
-
   public static final String ID = "oracle";
-  private static final List<String> INIT_STATEMENTS = ImmutableList.of("ALTER SESSION SET NLS_SORT='BINARY'");
+  private static final List<String> INIT_STATEMENTS = List.of("ALTER SESSION SET NLS_SORT='BINARY'");
   private static final Version MIN_SUPPORTED_VERSION = Version.create(11, 0, 0);
 
-
   public Oracle() {
     super(ID, "oracle.jdbc.OracleDriver", "1", "0", "SELECT 1 FROM DUAL");
   }
index ce441f099d6cb0aba5e891952ba2f5ed466c7ff7..de38c155669a286586d787ac579de02c5f41242c 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.db.dialect;
 
-import com.google.common.collect.ImmutableList;
 import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
 import java.util.List;
@@ -30,9 +29,8 @@ import org.sonar.api.utils.log.Loggers;
 import static com.google.common.base.Preconditions.checkState;
 
 public class PostgreSql extends AbstractDialect {
-
   public static final String ID = "postgresql";
-  static final List<String> INIT_STATEMENTS = ImmutableList.of("SET standard_conforming_strings=on", "SET backslash_quote=off");
+  static final List<String> INIT_STATEMENTS = List.of("SET standard_conforming_strings=on", "SET backslash_quote=off");
   private static final Version MIN_SUPPORTED_VERSION = Version.create(9, 3, 0);
   private static final Version MIN_UPSERT_VERSION = Version.create(9, 5, 0);
 
index 9462a758c4ab5869fec086a5379e95826098d051..38eba07a727bee493fa541764cb81badec28b867 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.core.permission;
 
 import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
 import java.util.List;
 import org.sonar.db.permission.GlobalPermission;
 
@@ -31,7 +30,6 @@ import org.sonar.db.permission.GlobalPermission;
  */
 @Deprecated
 public final class GlobalPermissions {
-
   public static final String SYSTEM_ADMIN = "admin";
   public static final String QUALITY_PROFILE_ADMIN = "profileadmin";
   public static final String QUALITY_GATE_ADMIN = "gateadmin";
@@ -41,12 +39,16 @@ public final class GlobalPermissions {
   /**
    * All the global permissions values, ordered from {@link #SYSTEM_ADMIN} to {@link #PROVISIONING}.
    */
-  public static final List<String> ALL = ImmutableList.of(
-    SYSTEM_ADMIN, QUALITY_PROFILE_ADMIN, QUALITY_GATE_ADMIN, SCAN_EXECUTION, PROVISIONING);
+  public static final List<String> ALL = List.of(
+    SYSTEM_ADMIN,
+    QUALITY_PROFILE_ADMIN,
+    QUALITY_GATE_ADMIN,
+    SCAN_EXECUTION,
+    PROVISIONING
+  );
   public static final String ALL_ON_ONE_LINE = Joiner.on(", ").join(GlobalPermissions.ALL);
 
   private GlobalPermissions() {
     // only static methods
   }
-
 }
index eb8f0994f573d58eb99187f97c126f1596f0e671..bf6bfba6580cc3a33d9e8c5bbc88adfe093217cc 100644 (file)
  */
 package org.sonar.db.component;
 
-import com.google.common.collect.ImmutableList;
 import java.util.List;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 
 public class ProjectLinkDto {
-
   public static final String TYPE_HOME_PAGE = "homepage";
   public static final String TYPE_CI = "ci";
   public static final String TYPE_ISSUE_TRACKER = "issue";
@@ -33,7 +31,13 @@ public class ProjectLinkDto {
 
   public static final String TYPE_SOURCES_DEV = "scm_dev";
 
-  public static final List<String> PROVIDED_TYPES = ImmutableList.of(TYPE_HOME_PAGE, TYPE_CI, TYPE_ISSUE_TRACKER, TYPE_SOURCES, TYPE_SOURCES_DEV);
+  public static final List<String> PROVIDED_TYPES = List.of(
+    TYPE_HOME_PAGE,
+    TYPE_CI,
+    TYPE_ISSUE_TRACKER,
+    TYPE_SOURCES,
+    TYPE_SOURCES_DEV
+  );
 
   private String uuid;
   private String projectUuid;
index e1aaaed9aad7944ebc0d4b27244b3105a32c5242..1ac31cbf7ba1001b739bb6d254be9d281af3989d 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.permission;
 
-import com.google.common.collect.ImmutableList;
 import java.util.List;
 import javax.annotation.concurrent.Immutable;
 import org.sonar.api.resources.Qualifiers;
@@ -31,21 +30,26 @@ import static java.util.stream.Collectors.toList;
 
 @Immutable
 public class PermissionServiceImpl implements PermissionService {
+  private static final List<String> ALL_PROJECT_PERMISSIONS = List.of(
+    UserRole.ADMIN,
+    UserRole.CODEVIEWER,
+    UserRole.ISSUE_ADMIN,
+    UserRole.SECURITYHOTSPOT_ADMIN,
+    UserRole.SCAN,
+    UserRole.USER
+  );
 
-  private static final List<String> ALL_PROJECT_PERMISSIONS = ImmutableList.of(
-    UserRole.ADMIN, UserRole.CODEVIEWER, UserRole.ISSUE_ADMIN, UserRole.SECURITYHOTSPOT_ADMIN, UserRole.SCAN, UserRole.USER);
-
-  private static final List<GlobalPermission> ALL_GLOBAL_PERMISSIONS = ImmutableList.copyOf(GlobalPermission.values());
+  private static final List<GlobalPermission> ALL_GLOBAL_PERMISSIONS = List.of(GlobalPermission.values());
 
   private final List<GlobalPermission> globalPermissions;
   private final List<String> projectPermissions;
 
   public PermissionServiceImpl(ResourceTypes resourceTypes) {
-    globalPermissions = ImmutableList.copyOf(ALL_GLOBAL_PERMISSIONS.stream()
+    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()));
-    projectPermissions = ImmutableList.copyOf(ALL_PROJECT_PERMISSIONS.stream()
+    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()));
index 855d248205b008f586be956772faa7ee95326085..d5c8e3aaa908e77449e4c63b3bdb4e0ad3bd7b51 100644 (file)
@@ -72,7 +72,6 @@ import org.sonarqube.ws.Components.SearchProjectsWsResponse;
 
 import static com.google.common.base.MoreObjects.firstNonNull;
 import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.ImmutableList.of;
 import static com.google.common.collect.Sets.newHashSet;
 import static java.util.Collections.emptyMap;
 import static java.util.Objects.requireNonNull;
@@ -95,7 +94,6 @@ import static org.sonarqube.ws.client.project.ProjectsWsParameters.FILTER_LANGUA
 import static org.sonarqube.ws.client.project.ProjectsWsParameters.FILTER_TAGS;
 
 public class SearchProjectsAction implements ComponentsWsAction {
-
   public static final int MAX_PAGE_SIZE = 500;
   public static final int DEFAULT_PAGE_SIZE = 100;
   private static final String ALL = "_all";
@@ -368,7 +366,7 @@ public class SearchProjectsAction implements ComponentsWsAction {
     if (httpRequest.hasParam(FIELDS)) {
       List<String> paramsAsString = httpRequest.mandatoryParamAsStrings(FIELDS);
       if (paramsAsString.contains(ALL)) {
-        request.setAdditionalFields(of(ANALYSIS_DATE, LEAK_PERIOD_DATE));
+        request.setAdditionalFields(List.of(ANALYSIS_DATE, LEAK_PERIOD_DATE));
       } else {
         request.setAdditionalFields(paramsAsString);
       }
index 0fb20222fe89db315bfd8c5b4bc9192c27614dab..63fcd54367c6134692bef4eae52a16b4df06ac65 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.hotspot.ws;
 
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import java.util.Arrays;
 import java.util.Collection;
@@ -109,7 +108,7 @@ public class SearchAction implements HotspotsWsAction {
   private static final String PARAM_CWE = "cwe";
   private static final String PARAM_FILES = "files";
 
-  private static final List<String> STATUSES = ImmutableList.of(STATUS_TO_REVIEW, STATUS_REVIEWED);
+  private static final List<String> STATUSES = List.of(STATUS_TO_REVIEW, STATUS_REVIEWED);
 
   private final DbClient dbClient;
   private final UserSession userSession;
index a46a82e7920f2003bb65766277affd2f367d003b..c2a6b868d374b0a8072f1a4082839fe6be71c1a4 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.issue;
 
 import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Ordering;
@@ -105,8 +104,8 @@ public class IssueChangeWSSupport {
     Set<UserDto> preloadedUsers, Set<ComponentDto> preloadedComponents) {
     Set<String> issueKeys = dtos.stream().map(IssueDto::getKey).collect(toSet());
 
-    List<IssueChangeDto> changes = ImmutableList.of();
-    List<IssueChangeDto> comments = ImmutableList.of();
+    List<IssueChangeDto> changes = List.of();
+    List<IssueChangeDto> comments = List.of();
     switch (load) {
       case CHANGE_LOG:
         changes = dbClient.issueChangeDao().selectByTypeAndIssueKeys(dbSession, issueKeys, TYPE_FIELD_CHANGE);
@@ -316,18 +315,18 @@ public class IssueChangeWSSupport {
     public List<FieldDiffs> getChanges(IssueDto dto) {
       List<FieldDiffs> fieldDiffs = changesByIssueKey.get(dto.getKey());
       if (fieldDiffs == null) {
-        return ImmutableList.of();
+        return List.of();
       }
-      return ImmutableList.copyOf(fieldDiffs);
+      return List.copyOf(fieldDiffs);
     }
 
     @Override
     public List<IssueChangeDto> getComments(IssueDto dto) {
       List<IssueChangeDto> comments = commentsByIssueKey.get(dto.getKey());
       if (comments == null) {
-        return ImmutableList.of();
+        return List.of();
       }
-      return ImmutableList.copyOf(comments);
+      return List.copyOf(comments);
     }
 
     @Override
index a41aa0c794353d7f4ad942c136d804d0077bba17..26b5bbc97a219babdff584982e7d2219ca1b47b2 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.issue.ws;
 
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -131,12 +130,11 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TIMEZONE;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TYPES;
 
 public class SearchAction implements IssuesWsAction {
-
   private static final String LOGIN_MYSELF = "__me__";
   private static final Set<String> ISSUE_SCOPES = Arrays.stream(IssueScope.values()).map(Enum::name).collect(Collectors.toSet());
   private static final EnumSet<RuleType> ALL_RULE_TYPES_EXCEPT_SECURITY_HOTSPOTS = EnumSet.complementOf(EnumSet.of(RuleType.SECURITY_HOTSPOT));
 
-  static final List<String> SUPPORTED_FACETS = ImmutableList.of(
+  static final List<String> SUPPORTED_FACETS = List.of(
     FACET_PROJECTS,
     PARAM_MODULE_UUIDS,
     PARAM_FILES,
@@ -157,7 +155,8 @@ public class SearchAction implements IssuesWsAction {
     PARAM_SANS_TOP_25,
     PARAM_CWE,
     PARAM_CREATED_AT,
-    PARAM_SONARSOURCE_SECURITY);
+    PARAM_SONARSOURCE_SECURITY
+  );
 
   private static final String INTERNAL_PARAMETER_DISCLAIMER = "This parameter is mostly used by the Issues page, please prefer usage of the componentKeys parameter. ";
   private static final Set<String> FACETS_REQUIRING_PROJECT = newHashSet(PARAM_MODULE_UUIDS, PARAM_FILES, PARAM_DIRECTORIES);
@@ -422,7 +421,7 @@ public class SearchAction implements IssuesWsAction {
       collectFacets(collector, facets);
     }
     SearchResponseData preloadedData = new SearchResponseData(emptyList());
-    preloadedData.addRules(ImmutableList.copyOf(query.rules()));
+    preloadedData.addRules(List.copyOf(query.rules()));
     SearchResponseData data = searchResponseLoader.load(preloadedData, collector, additionalFields, facets);
 
     // FIXME allow long in Paging
@@ -588,7 +587,7 @@ public class SearchAction implements IssuesWsAction {
     List<String> assigneeUuid = userDtos.stream().map(UserDto::getUuid).collect(toList());
 
     if ((assigneeLogins != null) && firstNonNull(assigneeUuid, emptyList()).isEmpty()) {
-      assigneeUuid = ImmutableList.of("non-existent-uuid");
+      assigneeUuid = List.of("non-existent-uuid");
     }
     return assigneeUuid;
   }
index 8c1d215855c7518869edfc1abe1b5cf9c7db9aa4..b7954a53ea1ed213ea60aa958cc013e1d0bcf00c 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.issue.ws;
 
 import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ListMultimap;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -44,7 +43,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
  * All the data required to write response of api/issues/search
  */
 public class SearchResponseData {
-
   private final List<IssueDto> issues;
 
   private Long effortTotal = null;
@@ -58,7 +56,7 @@ public class SearchResponseData {
 
   public SearchResponseData(IssueDto issue) {
     checkNotNull(issue);
-    this.issues = ImmutableList.of(issue);
+    this.issues = List.of(issue);
   }
 
   public SearchResponseData(List<IssueDto> issues) {
index f90ebb93d183ec8e89d784a8f09251401460a181..6cac5bdbcea75374d902ed421c2c6496ff125ea9 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.server.permission.ws;
 
-import com.google.common.collect.ImmutableList;
+import java.util.List;
 import java.util.Optional;
 import org.sonar.api.server.ws.Change;
 import org.sonar.api.server.ws.Request;
@@ -41,7 +41,6 @@ import static org.sonar.server.permission.ws.WsParameters.createProjectParameter
 import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION;
 
 public class AddGroupAction implements PermissionsWsAction {
-
   public static final String ACTION = "add_group";
 
   private final DbClient dbClient;
@@ -95,9 +94,8 @@ public class AddGroupAction implements PermissionsWsAction {
         request.mandatoryParam(PARAM_PERMISSION),
         project.orElse(null),
         group, permissionService);
-      permissionUpdater.apply(dbSession, ImmutableList.of(change));
+      permissionUpdater.apply(dbSession, List.of(change));
     }
     response.noContent();
   }
-
 }
index cd5888e2e7e7ec80ebc236b5241c1bd25f3c01d4..e8b9af6f62b7b282a87f55dce1015c816adce1cd 100644 (file)
@@ -19,8 +19,8 @@
  */
 package org.sonar.server.rule.ws;
 
-import com.google.common.collect.ImmutableList;
 import java.util.Date;
+import java.util.List;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rules.RuleType;
 import org.sonar.api.server.ServerSide;
@@ -56,7 +56,6 @@ import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TYPES;
 
 @ServerSide
 public class RuleQueryFactory {
-
   private final DbClient dbClient;
 
   public RuleQueryFactory(DbClient dbClient) {
@@ -90,7 +89,7 @@ public class RuleQueryFactory {
     setProfile(dbSession, query, request);
     setCompareToProfile(dbSession, query, request);
     QProfileDto profile = query.getQProfile();
-    query.setLanguages(profile == null ? request.paramAsStrings(PARAM_LANGUAGES) : ImmutableList.of(profile.getLanguage()));
+    query.setLanguages(profile == null ? request.paramAsStrings(PARAM_LANGUAGES) : List.of(profile.getLanguage()));
     query.setActivation(request.paramAsBoolean(PARAM_ACTIVATION));
     query.setTags(request.paramAsStrings(PARAM_TAGS));
     query.setInheritance(request.paramAsStrings(PARAM_INHERITANCE));
index e09641b88d2a4c994a7eb1ea6ed2b26d3ad57ad3..3ba655bb2ff7a4a0de24b475bbe735cfb365b8ab 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.setting.ws;
 
-import com.google.common.collect.ImmutableList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
@@ -50,7 +49,6 @@ import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
 import static org.sonar.server.ws.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001;
 
 public class ResetAction implements SettingsWsAction {
-
   private final DbClient dbClient;
   private final ComponentFinder componentFinder;
   private final SettingsUpdater settingsUpdater;
@@ -114,7 +112,7 @@ public class ResetAction implements SettingsWsAction {
       resetRequest.getKeys().forEach(key -> {
         SettingsWsSupport.validateKey(key);
         SettingData data = new SettingData(key, emptyList(), component.orElse(null));
-        ImmutableList.of(validations.scope(), validations.qualifier())
+        List.of(validations.scope(), validations.qualifier())
           .forEach(validation -> validation.accept(data));
       });
 
index a0a346b911cda853b922fce25dc327ba1dcb4af9..bfa2f5d524cc0d51f57f41ca215f0d1daae62b0b 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.setting.ws;
 
 import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ListMultimap;
 import com.google.gson.Gson;
 import com.google.gson.JsonSyntaxException;
@@ -205,7 +204,7 @@ public class SetAction implements SettingsWsAction {
     checkValueIsSet(request);
     String settingKey = request.getKey();
     SettingData settingData = new SettingData(settingKey, valuesFromRequest(request), component.orElse(null));
-    ImmutableList.of(validations.scope(), validations.qualifier(), validations.valueType())
+    List.of(validations.scope(), validations.qualifier(), validations.valueType())
       .forEach(validation -> validation.accept(settingData));
   }
 
index 1cad70a35b443fb333958999b37b9e137764cced..e55ee0da620c6d45bf511770fd840e591b2b1404 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.text;
 
-import com.google.common.collect.ImmutableList;
 import org.sonar.api.server.ServerSide;
 import org.sonar.api.platform.Server;
 
@@ -27,13 +26,12 @@ import java.util.List;
 
 @ServerSide
 public class MacroInterpreter {
-
   private final List<Macro> macros;
 
   public MacroInterpreter(Server server) {
-    this.macros = ImmutableList.of(
+    this.macros = List.of(
       new RuleMacro(server.getContextPath())
-      );
+    );
   }
 
   public String interpret(String text) {
@@ -43,5 +41,4 @@ public class MacroInterpreter {
     }
     return textReplaced;
   }
-
 }
index 6af2e0672cd23be6b5f872dfeac1df3ff7bf3bbe..c676ca0b779383fad2daab7038676683c70adc46 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.platform.web;
 
-import com.google.common.collect.ImmutableList;
 import java.io.IOException;
 import java.util.List;
 import java.util.function.Function;
@@ -37,11 +36,11 @@ import org.sonar.core.util.stream.MoreCollectors;
 import static java.lang.String.format;
 
 public class RedirectFilter implements Filter {
-
   private static final String EMPTY = "";
 
-  private static final List<Redirect> REDIRECTS = ImmutableList.of(
-    newSimpleRedirect("/api", "/api/webservices/list"));
+  private static final List<Redirect> REDIRECTS = List.of(
+    newSimpleRedirect("/api", "/api/webservices/list")
+  );
 
   @Override
   public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {