diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2022-03-23 11:52:56 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-03-23 20:02:45 +0000 |
commit | 6abdf0edd97aa76ccc42d65ed0e30f401d75f79f (patch) | |
tree | 2c184885c32cdcb6588f09348b7728b8f28fe238 | |
parent | 6a65e721a78da9cb82b5990100bb62b907311310 (diff) | |
download | sonarqube-6abdf0edd97aa76ccc42d65ed0e30f401d75f79f.tar.gz sonarqube-6abdf0edd97aa76ccc42d65ed0e30f401d75f79f.zip |
Fix SonarQube quality issues
19 files changed, 185 insertions, 105 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/measurecomputer/MeasureComputerContextImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/measurecomputer/MeasureComputerContextImpl.java index 57f1a171133..f5c2283b3ff 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/measurecomputer/MeasureComputerContextImpl.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/measurecomputer/MeasureComputerContextImpl.java @@ -19,13 +19,12 @@ */ package org.sonar.ce.task.projectanalysis.api.measurecomputer; -import com.google.common.base.Function; -import com.google.common.base.Predicates; -import com.google.common.collect.FluentIterable; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.function.Function; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -120,10 +119,11 @@ public class MeasureComputerContextImpl implements MeasureComputerContext { @Override public Iterable<Measure> getChildrenMeasures(String metric) { validateInputMetric(metric); - return FluentIterable.from(internalComponent.getChildren()) - .transform(new ComponentToMeasure(metricRepository.getByKey(metric))) - .transform(ToMeasureAPI.INSTANCE) - .filter(Predicates.notNull()); + return () -> internalComponent.getChildren().stream() + .map(new ComponentToMeasure(metricRepository.getByKey(metric))) + .map(ToMeasureAPI.INSTANCE) + .filter(Objects::nonNull) + .iterator(); } @Override diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/ConditionToCondition.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/ConditionToCondition.java index e2054ae5e17..7eed2074526 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/ConditionToCondition.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/ConditionToCondition.java @@ -19,9 +19,8 @@ */ package org.sonar.ce.task.projectanalysis.api.posttask; -import com.google.common.base.Function; import java.util.Map; -import javax.annotation.Nonnull; +import java.util.function.Function; import org.sonar.api.ce.posttask.QualityGate; import org.sonar.ce.task.projectanalysis.qualitygate.Condition; import org.sonar.ce.task.projectanalysis.qualitygate.ConditionStatus; @@ -42,7 +41,6 @@ class ConditionToCondition implements Function<Condition, QualityGate.Condition> } @Override - @Nonnull public QualityGate.Condition apply(Condition input) { String metricKey = input.getMetric().getKey(); ConditionStatus conditionStatus = statusPerConditions.get(input); diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java index b7ec255e4b0..2f5d3b0067b 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java @@ -212,7 +212,7 @@ public class PostProjectAnalysisTasksExecutor implements ComputationStepExecutor private static Collection<QualityGate.Condition> convert(Set<Condition> conditions, Map<Condition, ConditionStatus> statusPerConditions) { return conditions.stream() - .map(new ConditionToCondition(statusPerConditions)::apply) + .map(new ConditionToCondition(statusPerConditions)) .collect(MoreCollectors.toList(statusPerConditions.size())); } diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/VisitorsCrawler.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/VisitorsCrawler.java index 8b041950a3c..32da9e33c9a 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/VisitorsCrawler.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/VisitorsCrawler.java @@ -19,19 +19,18 @@ */ package org.sonar.ce.task.projectanalysis.component; -import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.sonar.api.utils.log.Loggers; import org.sonar.core.util.logs.Profiler; -import static com.google.common.collect.FluentIterable.from; import static com.google.common.collect.Iterables.concat; import static java.util.Objects.requireNonNull; @@ -45,23 +44,21 @@ public class VisitorsCrawler implements ComponentCrawler { private final List<VisitorWrapper> preOrderVisitorWrappers; private final List<VisitorWrapper> postOrderVisitorWrappers; - public VisitorsCrawler(Iterable<ComponentVisitor> visitors) { + public VisitorsCrawler(Collection<ComponentVisitor> visitors) { this(visitors, false); } - public VisitorsCrawler(Iterable<ComponentVisitor> visitors, boolean computeDuration) { - List<VisitorWrapper> visitorWrappers = from(visitors).transform(ToVisitorWrapper.INSTANCE).toList(); - this.preOrderVisitorWrappers = from(visitorWrappers).filter(MathPreOrderVisitor.INSTANCE).toList(); - this.postOrderVisitorWrappers = from(visitorWrappers).filter(MatchPostOrderVisitor.INSTANCE).toList(); + public VisitorsCrawler(Collection<ComponentVisitor> visitors, boolean computeDuration) { + List<VisitorWrapper> visitorWrappers = visitors.stream().map(ToVisitorWrapper.INSTANCE).collect(Collectors.toList()); + this.preOrderVisitorWrappers = visitorWrappers.stream().filter(MathPreOrderVisitor.INSTANCE).collect(Collectors.toList()); + this.postOrderVisitorWrappers = visitorWrappers.stream().filter(MatchPostOrderVisitor.INSTANCE).collect(Collectors.toList()); this.computeDuration = computeDuration; - this.visitorCumulativeDurations = computeDuration ? from(visitors).toMap(VisitorWrapperToInitialDuration.INSTANCE) : Collections.emptyMap(); + this.visitorCumulativeDurations = computeDuration ? visitors.stream().collect(Collectors.toMap(v -> v, v -> new VisitorDuration())) : Collections.emptyMap(); } public Map<ComponentVisitor, Long> getCumulativeDurations() { if (computeDuration) { - return ImmutableMap.copyOf( - Maps.transformValues(this.visitorCumulativeDurations, VisitorDurationToDuration.INSTANCE) - ); + return visitorCumulativeDurations.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getDuration())); } return Collections.emptyMap(); } @@ -80,8 +77,8 @@ public class VisitorsCrawler implements ComponentCrawler { private void visitImpl(Component component) { MatchVisitorMaxDepth visitorMaxDepth = MatchVisitorMaxDepth.forComponent(component); - List<VisitorWrapper> preOrderVisitorWrappersToExecute = from(preOrderVisitorWrappers).filter(visitorMaxDepth).toList(); - List<VisitorWrapper> postOrderVisitorWrappersToExecute = from(postOrderVisitorWrappers).filter(visitorMaxDepth).toList(); + List<VisitorWrapper> preOrderVisitorWrappersToExecute = preOrderVisitorWrappers.stream().filter(visitorMaxDepth).collect(Collectors.toList()); + List<VisitorWrapper> postOrderVisitorWrappersToExecute = postOrderVisitorWrappers.stream().filter(visitorMaxDepth).collect(Collectors.toList()); if (preOrderVisitorWrappersToExecute.isEmpty() && postOrderVisitorWrappersToExecute.isEmpty()) { return; } @@ -183,7 +180,7 @@ public class VisitorsCrawler implements ComponentCrawler { } @Override - public boolean apply(@Nonnull VisitorWrapper visitorWrapper) { + public boolean test(VisitorWrapper visitorWrapper) { CrawlerDepthLimit maxDepth = visitorWrapper.getMaxDepth(); return maxDepth.isSameAs(type) || maxDepth.isDeeperThan(type); } @@ -193,7 +190,7 @@ public class VisitorsCrawler implements ComponentCrawler { INSTANCE; @Override - public boolean apply(@Nonnull VisitorWrapper visitorWrapper) { + public boolean test(VisitorWrapper visitorWrapper) { return visitorWrapper.getOrder() == ComponentVisitor.Order.PRE_ORDER; } } @@ -202,7 +199,7 @@ public class VisitorsCrawler implements ComponentCrawler { INSTANCE; @Override - public boolean apply(@Nonnull VisitorWrapper visitorWrapper) { + public boolean test(VisitorWrapper visitorWrapper) { return visitorWrapper.getOrder() == ComponentVisitor.Order.POST_ORDER; } } @@ -218,24 +215,4 @@ public class VisitorsCrawler implements ComponentCrawler { return duration; } } - - private enum VisitorWrapperToInitialDuration implements Function<ComponentVisitor, VisitorDuration> { - INSTANCE; - - @Override - @Nonnull - public VisitorDuration apply(@Nonnull ComponentVisitor visitorWrapper) { - return new VisitorDuration(); - } - } - - private enum VisitorDurationToDuration implements Function<VisitorDuration, Long> { - INSTANCE; - - @Nullable - @Override - public Long apply(VisitorDuration input) { - return input.getDuration(); - } - } } diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImpl.java index e0cb1ddd6ad..75147777989 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImpl.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImpl.java @@ -19,31 +19,28 @@ */ package org.sonar.ce.task.projectanalysis.metric; -import com.google.common.base.Function; -import com.google.common.collect.FluentIterable; import java.util.HashSet; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.sonar.api.measures.Metric; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.core.metric.ScannerMetrics; +import org.sonar.core.util.stream.MoreCollectors; public class ReportMetricValidatorImpl implements ReportMetricValidator { - private static final Logger LOG = Loggers.get(ReportMetricValidatorImpl.class); - private Map<String, org.sonar.api.measures.Metric> metricByKey; - private Set<String> alreadyLoggedMetricKeys = new HashSet<>(); + private final Map<String, Metric> metricByKey; + private final Set<String> alreadyLoggedMetricKeys = new HashSet<>(); public ReportMetricValidatorImpl(ScannerMetrics scannerMetrics) { - this.metricByKey = FluentIterable.from(scannerMetrics.getMetrics()).uniqueIndex(MetricToKey.INSTANCE); + this.metricByKey = scannerMetrics.getMetrics().stream().collect(MoreCollectors.uniqueIndex(Metric::getKey)); } @Override public boolean validate(String metricKey) { - org.sonar.api.measures.Metric metric = metricByKey.get(metricKey); + Metric metric = metricByKey.get(metricKey); if (metric == null) { if (!alreadyLoggedMetricKeys.contains(metricKey)) { LOG.debug("The metric '{}' is ignored and should not be send in the batch report", metricKey); @@ -53,14 +50,4 @@ public class ReportMetricValidatorImpl implements ReportMetricValidator { } return true; } - - private enum MetricToKey implements Function<org.sonar.api.measures.Metric, String> { - INSTANCE; - - @Nullable - @Override - public String apply(@Nonnull org.sonar.api.measures.Metric input) { - return input.key(); - } - } } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistScannerAnalysisCacheStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistScannerAnalysisCacheStepTest.java index 696b79d0dbf..f18ea7abacb 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistScannerAnalysisCacheStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistScannerAnalysisCacheStepTest.java @@ -66,4 +66,10 @@ public class PersistScannerAnalysisCacheStepTest { client.scannerAnalysisCacheDao().insert(dbTester.getSession(), "branch", new ByteArrayInputStream("test".getBytes(UTF_8))); inserts_cache(); } + + @Test + public void do_nothing_if_no_analysis_cache() { + step.execute(mock(ComputationStep.Context.class)); + assertThat(dbTester.countRowsOfTable("scanner_analysis_cache")).isZero(); + } } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/package-info.java b/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/package-info.java new file mode 100644 index 00000000000..ea36cf155e9 --- /dev/null +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.db.scannercache; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/engine/MigrationContainerPopulatorImpl.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/engine/MigrationContainerPopulatorImpl.java index 22a92d3c059..542475b9888 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/engine/MigrationContainerPopulatorImpl.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/engine/MigrationContainerPopulatorImpl.java @@ -19,14 +19,12 @@ */ package org.sonar.server.platform.db.migration.engine; -import java.util.Arrays; import java.util.HashSet; import java.util.Set; import org.sonar.server.platform.db.migration.step.MigrationStep; import org.sonar.server.platform.db.migration.step.MigrationSteps; import org.sonar.server.platform.db.migration.step.MigrationStepsExecutor; import org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl; -import org.sonar.server.platform.db.migration.version.DbVersion; /** * Responsible for: diff --git a/server/sonar-main/src/main/java/org/sonar/application/process/StreamGobbler.java b/server/sonar-main/src/main/java/org/sonar/application/process/StreamGobbler.java index 9675647631e..109ed66467b 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/process/StreamGobbler.java +++ b/server/sonar-main/src/main/java/org/sonar/application/process/StreamGobbler.java @@ -75,6 +75,7 @@ public class StreamGobbler extends Thread { } } } catch (Exception ignored) { + // ignore } } diff --git a/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/package-info.java b/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/package-info.java new file mode 100644 index 00000000000..bb92e50d142 --- /dev/null +++ b/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/package-info.java @@ -0,0 +1,21 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.sonar.server.pushapi; diff --git a/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/qualityprofile/package-info.java b/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/qualityprofile/package-info.java new file mode 100644 index 00000000000..13d0d07bafc --- /dev/null +++ b/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/qualityprofile/package-info.java @@ -0,0 +1,21 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.sonar.server.pushapi.qualityprofile; diff --git a/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/sonarlint/package-info.java b/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/sonarlint/package-info.java new file mode 100644 index 00000000000..05bece2c149 --- /dev/null +++ b/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/sonarlint/package-info.java @@ -0,0 +1,21 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.sonar.server.pushapi.sonarlint; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java index 19dbf4ff7ca..27f29fe0978 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java @@ -19,7 +19,6 @@ */ package org.sonar.server.issue.ws; -import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; import java.util.Collection; import java.util.Collections; @@ -30,6 +29,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.function.Function; import java.util.stream.Collectors; import javax.annotation.Nullable; import org.sonar.api.rule.RuleKey; @@ -286,12 +286,6 @@ public class SearchResponseLoader { } } - void addComponentUuids(@Nullable Collection<String> uuids) { - if (uuids != null) { - this.componentUuids.addAll(uuids); - } - } - void addProjectUuid(String uuid) { this.projectUuids.add(uuid); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/PermissionTemplateDtoToPermissionTemplateResponse.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/PermissionTemplateDtoToPermissionTemplateResponse.java index 2ffd9bbff3c..724c9d47605 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/PermissionTemplateDtoToPermissionTemplateResponse.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/PermissionTemplateDtoToPermissionTemplateResponse.java @@ -19,8 +19,7 @@ */ package org.sonar.server.permission.ws.template; -import com.google.common.base.Function; -import javax.annotation.Nonnull; +import java.util.function.Function; import org.sonar.api.utils.DateUtils; import org.sonar.db.permission.template.PermissionTemplateDto; import org.sonarqube.ws.Permissions.PermissionTemplate; @@ -40,7 +39,7 @@ public class PermissionTemplateDtoToPermissionTemplateResponse { private enum Singleton implements Function<PermissionTemplateDto, PermissionTemplate> { INSTANCE; @Override - public PermissionTemplate apply(@Nonnull PermissionTemplateDto permissionTemplate) { + public PermissionTemplate apply(PermissionTemplateDto permissionTemplate) { PermissionTemplate.Builder permissionTemplateBuilder = PermissionTemplate.newBuilder() .setId(permissionTemplate.getUuid()) .setName(permissionTemplate.getName()) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java index fdff832b6be..7a3c7698b92 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java @@ -19,7 +19,6 @@ */ package org.sonar.server.qualityprofile; -import com.google.common.base.Function; import com.google.common.collect.MapDifference; import com.google.common.collect.Maps; import java.util.Collection; @@ -28,7 +27,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; import org.sonar.api.rule.RuleKey; import org.sonar.api.server.ServerSide; import org.sonar.db.DbClient; @@ -86,7 +84,7 @@ public class QProfileComparison { } private Map<RuleKey, OrgActiveRuleDto> loadActiveRules(DbSession dbSession, QProfileDto profile) { - return Maps.uniqueIndex(dbClient.activeRuleDao().selectByProfile(dbSession, profile), ActiveRuleToRuleKey.INSTANCE); + return Maps.uniqueIndex(dbClient.activeRuleDao().selectByProfile(dbSession, profile), ActiveRuleDto::getRuleKey); } public static class QProfileComparisonResult { @@ -155,15 +153,6 @@ public class QProfileComparison { } } - private enum ActiveRuleToRuleKey implements Function<ActiveRuleDto, RuleKey> { - INSTANCE; - - @Override - public RuleKey apply(@Nonnull ActiveRuleDto input) { - return input.getRuleKey(); - } - } - private static Map<String, String> paramDtoToMap(List<ActiveRuleParamDto> params) { Map<String, String> map = new HashMap<>(); for (ActiveRuleParamDto dto : params) { diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/PlatformImpl.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/PlatformImpl.java index 0d422108d49..ae731d5c025 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/PlatformImpl.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/PlatformImpl.java @@ -52,14 +52,14 @@ public class PlatformImpl implements Platform { private static final PlatformImpl INSTANCE = new PlatformImpl(); private AutoStarter autoStarter = null; - private Properties properties; - private ServletContext servletContext; - private PlatformLevel level1; - private PlatformLevel level2; - private PlatformLevel levelSafeMode; - private PlatformLevel level3; - private PlatformLevel level4; - private PlatformLevel currentLevel; + private Properties properties = null; + private ServletContext servletContext = null; + private PlatformLevel level1 = null; + private PlatformLevel level2 = null; + private PlatformLevel levelSafeMode = null; + private PlatformLevel level3 = null; + private PlatformLevel level4 = null; + private PlatformLevel currentLevel = null; private boolean dbConnected = false; private boolean started = false; private final List<Object> level4AddedComponents = new ArrayList<>(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/cache/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/cache/package-info.java new file mode 100644 index 00000000000..3efdfe29d2d --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/cache/package-info.java @@ -0,0 +1,21 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@javax.annotation.ParametersAreNonnullByDefault +package org.sonar.api.batch.sensor.cache; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/package-info.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/package-info.java new file mode 100644 index 00000000000..e12301670ed --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.scanner.cache; + +import javax.annotation.ParametersAreNonnullByDefault; 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 1a7acc61189..5a46e41a90f 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 @@ -37,10 +37,10 @@ public class ScmChangedFilesProvider { @Bean("ScmChangedFiles") public ScmChangedFiles provide(ScmConfiguration scmConfiguration, BranchConfiguration branchConfiguration, DefaultInputProject project) { - Path rootBaseDir = project.getBaseDir(); - Collection<Path> changedFiles = loadChangedFilesIfNeeded(scmConfiguration, branchConfiguration, rootBaseDir); - validatePaths(changedFiles); - return new ScmChangedFiles(changedFiles); + Path rootBaseDir = project.getBaseDir(); + Collection<Path> changedFiles = loadChangedFilesIfNeeded(scmConfiguration, branchConfiguration, rootBaseDir); + validatePaths(changedFiles); + return new ScmChangedFiles(changedFiles); } private static void validatePaths(@javax.annotation.Nullable Collection<Path> paths) { |