*/
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;
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;
this.measureRepository = measureRepository;
// will be null for views
this.duplicationRepository = duplicationRepository;
- this.formulas = ImmutableList.of(new DuplicationFormula());
+ this.formulas = List.of(new DuplicationFormula());
}
/**
*/
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;
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
*/
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;
* 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),
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;
*/
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;
* 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;
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;
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};
*/
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;
* 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;
*/
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;
* 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;
public void execute(ComputationStep.Context context) {
new PathAwareCrawler<>(
FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
- .buildFor(ImmutableList.of(duplicationFormula)))
+ .buildFor(List.of(duplicationFormula)))
.visit(treeRootHolder.getRoot());
}
*/
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;
* 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;
*/
package org.sonar.db.dialect;
-import com.google.common.collect.ImmutableList;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.List;
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");
}
*/
package org.sonar.db.dialect;
-import com.google.common.collect.ImmutableList;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.List;
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);
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;
*/
@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";
/**
* 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
}
-
}
*/
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";
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;
*/
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;
@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()));
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;
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";
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);
}
*/
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;
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;
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;
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);
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
*/
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;
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,
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);
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
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;
}
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;
* All the data required to write response of api/issues/search
*/
public class SearchResponseData {
-
private final List<IssueDto> issues;
private Long effortTotal = null;
public SearchResponseData(IssueDto issue) {
checkNotNull(issue);
- this.issues = ImmutableList.of(issue);
+ this.issues = List.of(issue);
}
public SearchResponseData(List<IssueDto> issues) {
*/
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;
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;
request.mandatoryParam(PARAM_PERMISSION),
project.orElse(null),
group, permissionService);
- permissionUpdater.apply(dbSession, ImmutableList.of(change));
+ permissionUpdater.apply(dbSession, List.of(change));
}
response.noContent();
}
-
}
*/
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;
@ServerSide
public class RuleQueryFactory {
-
private final DbClient dbClient;
public RuleQueryFactory(DbClient dbClient) {
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));
*/
package org.sonar.server.setting.ws;
-import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
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;
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));
});
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;
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));
}
*/
package org.sonar.server.text;
-import com.google.common.collect.ImmutableList;
import org.sonar.api.server.ServerSide;
import org.sonar.api.platform.Server;
@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) {
}
return textReplaced;
}
-
}
*/
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;
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 {