diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2022-12-02 17:08:38 -0600 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-12-09 20:03:10 +0000 |
commit | 271bc37b16625c393d47503a235a626645d77641 (patch) | |
tree | 831936744f86bafd5fa7fb565682c63d460689d0 /sonar-scanner-engine/src/main/java/org/sonar/scanner | |
parent | b2148cbf445e56d8d36d48b2a0e679d8cadaa882 (diff) | |
download | sonarqube-271bc37b16625c393d47503a235a626645d77641.tar.gz sonarqube-271bc37b16625c393d47503a235a626645d77641.zip |
SONAR-17722 Scanner doesn't need to download list of PRs
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner')
7 files changed, 3 insertions, 193 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java index 38198a08e42..cd20aa1f1e3 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java @@ -110,7 +110,6 @@ import org.sonar.scanner.scan.branch.BranchConfiguration; import org.sonar.scanner.scan.branch.BranchConfigurationProvider; import org.sonar.scanner.scan.branch.BranchType; import org.sonar.scanner.scan.branch.ProjectBranchesProvider; -import org.sonar.scanner.scan.branch.ProjectPullRequestsProvider; import org.sonar.scanner.scan.filesystem.DefaultProjectFileSystem; import org.sonar.scanner.scan.filesystem.FileIndexer; import org.sonar.scanner.scan.filesystem.InputComponentStore; @@ -171,7 +170,6 @@ public class SpringProjectScanContainer extends SpringComponentContainer { new RulesProvider(), new BranchConfigurationProvider(), new ProjectBranchesProvider(), - new ProjectPullRequestsProvider(), ProjectRepositoriesProvider.class, new ProjectServerSettingsProvider(), AnalysisCacheEnabled.class, diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationLoader.java index 4bd974ec68d..d0c341e84bd 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationLoader.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationLoader.java @@ -24,5 +24,5 @@ import org.sonar.api.scanner.ScannerSide; @ScannerSide public interface BranchConfigurationLoader { - BranchConfiguration load(Map<String, String> projectSettings, ProjectBranches branches, ProjectPullRequests pullRequests); + BranchConfiguration load(Map<String, String> projectSettings, ProjectBranches branches); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationProvider.java index 87287fadd29..02da2514ff6 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationProvider.java @@ -32,13 +32,12 @@ public class BranchConfigurationProvider { private static final String LOG_MSG = "Load branch configuration"; @Bean("BranchConfiguration") - public BranchConfiguration provide(@Nullable BranchConfigurationLoader loader, ProjectConfiguration projectConfiguration, - ProjectBranches branches, ProjectPullRequests pullRequests) { + public BranchConfiguration provide(@Nullable BranchConfigurationLoader loader, ProjectConfiguration projectConfiguration, ProjectBranches branches) { if (loader == null) { return new DefaultBranchConfiguration(); } else { Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG); - BranchConfiguration branchConfiguration = loader.load(projectConfiguration.getProperties(), branches, pullRequests); + BranchConfiguration branchConfiguration = loader.load(projectConfiguration.getProperties(), branches); profiler.stopInfo(); return branchConfiguration; } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequests.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequests.java deleted file mode 100644 index e79b22f1624..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequests.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. - */ -package org.sonar.scanner.scan.branch; - -import java.util.List; -import java.util.Map; -import java.util.function.BinaryOperator; -import java.util.function.Function; -import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.concurrent.Immutable; - -/** - * Container class for information about the pull requests of a project. - */ -@Immutable -public class ProjectPullRequests { - private static final BinaryOperator<PullRequestInfo> PICK_MOST_RECENT_ANALYSIS = (a, b) -> a.getAnalysisDate() < b.getAnalysisDate() ? b : a; - private final Map<String, PullRequestInfo> pullRequestsByBranchName; - - public ProjectPullRequests(List<PullRequestInfo> pullRequestInfos) { - this.pullRequestsByBranchName = pullRequestInfos.stream().collect(Collectors.toMap(PullRequestInfo::getBranch, Function.identity(), PICK_MOST_RECENT_ANALYSIS)); - } - - @CheckForNull - public PullRequestInfo get(String branch) { - return pullRequestsByBranchName.get(branch); - } - - public boolean isEmpty() { - return pullRequestsByBranchName.isEmpty(); - } -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsLoader.java deleted file mode 100644 index 164a8d714b3..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsLoader.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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. - */ -package org.sonar.scanner.scan.branch; - -import org.sonar.api.scanner.ScannerSide; - -@ScannerSide -public interface ProjectPullRequestsLoader { - - /** - * Load the pull requests of a project. - */ - ProjectPullRequests load(String projectKey); - -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProvider.java deleted file mode 100644 index 0b2ebde0fa5..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectPullRequestsProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ -package org.sonar.scanner.scan.branch; - -import java.util.Collections; -import javax.annotation.Nullable; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.api.utils.log.Profiler; -import org.sonar.scanner.bootstrap.ScannerProperties; -import org.springframework.context.annotation.Bean; - -public class ProjectPullRequestsProvider { - - private static final Logger LOG = Loggers.get(ProjectPullRequestsProvider.class); - private static final String LOG_MSG = "Load project pull requests"; - - @Bean("ProjectPullRequests") - public ProjectPullRequests provide(@Nullable ProjectPullRequestsLoader loader, ScannerProperties scannerProperties) { - if (loader == null) { - return new ProjectPullRequests(Collections.emptyList()); - } - - Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG); - ProjectPullRequests pullRequests = loader.load(scannerProperties.getProjectKey()); - profiler.stopInfo(); - return pullRequests; - } -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/PullRequestInfo.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/PullRequestInfo.java deleted file mode 100644 index b30742cf2fc..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/PullRequestInfo.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ -package org.sonar.scanner.scan.branch; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -/** - * Container class for information about a pull request. - */ -@Immutable -public class PullRequestInfo { - private final String key; - private final String branch; - private final String base; - private final long analysisDate; - - public PullRequestInfo(String key, String branch, @Nullable String base, long analysisDate) { - this.key = key; - this.branch = branch; - this.base = base; - this.analysisDate = analysisDate; - } - - public String getKey() { - return key; - } - - public String getBranch() { - return branch; - } - - @CheckForNull - public String getBase() { - return base; - } - - public long getAnalysisDate() { - return analysisDate; - } -} |