aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-protocol
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2023-01-24 09:05:09 -0600
committersonartech <sonartech@sonarsource.com>2023-02-02 20:03:39 +0000
commit3d33985aa46148329696d0955e32563273f1a7a2 (patch)
tree371baae5d4131500f579f034a84135e102af372c /sonar-scanner-protocol
parent6d6ce351677a037bbbd49d0ed0f64f1fdd9eb1ec (diff)
downloadsonarqube-3d33985aa46148329696d0955e32563273f1a7a2.tar.gz
sonarqube-3d33985aa46148329696d0955e32563273f1a7a2.zip
SONAR-17706 Drop support for modules in WS
Diffstat (limited to 'sonar-scanner-protocol')
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepository.java52
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/ProjectRepositories.java24
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/SingleProjectRepository.java45
-rw-r--r--sonar-scanner-protocol/src/main/protobuf/scanner_report.proto3
-rw-r--r--sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepositoryTest.java68
-rw-r--r--sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/ProjectRepositoriesTest.java (renamed from sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/SingleProjectRepositoryTest.java)9
6 files changed, 27 insertions, 174 deletions
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepository.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepository.java
deleted file mode 100644
index 1f2fa5c7ba4..00000000000
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepository.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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.protocol.input;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-public class MultiModuleProjectRepository implements ProjectRepositories {
- private Map<String, SingleProjectRepository> repositoryPerModule = new HashMap<>();
-
- public MultiModuleProjectRepository addFileDataToModule(String moduleKey, @Nullable String path, FileData fileData) {
- if (path == null || (fileData.hash() == null && fileData.revision() == null)) {
- return this;
- }
-
- SingleProjectRepository repository = repositoryPerModule.computeIfAbsent(moduleKey, k -> new SingleProjectRepository());
- repository.addFileData(path, fileData);
- return this;
- }
-
- public Map<String, SingleProjectRepository> repositoriesByModule() {
- return repositoryPerModule;
- }
-
- @CheckForNull
- public FileData fileData(String moduleKeyWithBranch, @Nullable String path) {
- Optional<SingleProjectRepository> moduleRepository = Optional.ofNullable(repositoryPerModule.get(moduleKeyWithBranch));
- return moduleRepository
- .map(singleProjectRepository -> singleProjectRepository.fileDataByPath(path))
- .orElse(null);
- }
-}
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/ProjectRepositories.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/ProjectRepositories.java
index 7060b449830..699ee681867 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/ProjectRepositories.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/ProjectRepositories.java
@@ -19,5 +19,27 @@
*/
package org.sonar.scanner.protocol.input;
-public interface ProjectRepositories {
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+
+public class ProjectRepositories {
+ private final Map<String, FileData> fileDataByPath = new HashMap<>();
+
+ public ProjectRepositories addFileData(@Nullable String path, FileData fileData) {
+ if (path == null || (fileData.hash() == null && fileData.revision() == null)) {
+ return this;
+ }
+
+ fileDataByPath.put(path, fileData);
+ return this;
+ }
+
+ public Map<String, FileData> fileData() {
+ return fileDataByPath;
+ }
+
+ public FileData fileDataByPath(@Nullable String path) {
+ return fileDataByPath.get(path);
+ }
}
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/SingleProjectRepository.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/SingleProjectRepository.java
deleted file mode 100644
index e9311e4d20a..00000000000
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/SingleProjectRepository.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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.protocol.input;
-
-import java.util.HashMap;
-import java.util.Map;
-import javax.annotation.Nullable;
-
-public class SingleProjectRepository implements ProjectRepositories {
- private Map<String, FileData> fileDataByPath = new HashMap<>();
-
- public SingleProjectRepository addFileData(@Nullable String path, FileData fileData) {
- if (path == null || (fileData.hash() == null && fileData.revision() == null)) {
- return this;
- }
-
- fileDataByPath.put(path, fileData);
- return this;
- }
-
- public Map<String, FileData> fileData() {
- return fileDataByPath;
- }
-
- public FileData fileDataByPath(@Nullable String path) {
- return fileDataByPath.get(path);
- }
-}
diff --git a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
index beb59561354..62973c2e01e 100644
--- a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
+++ b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
@@ -49,7 +49,8 @@ message Metadata {
string scm_revision_id = 13;
string pull_request_key = 14;
- map<string, string> modules_project_relative_path_by_key = 15;
+
+ reserved 15; // modules_project_relative_path_by_key (no longer used)
string projectVersion = 16;
string buildString = 17;
diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepositoryTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepositoryTest.java
deleted file mode 100644
index d10d479ef82..00000000000
--- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepositoryTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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.protocol.input;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class MultiModuleProjectRepositoryTest {
-
- private MultiModuleProjectRepository repository;
-
- @Before
- public void setUp() {
- repository = new MultiModuleProjectRepository();
- }
-
- @Test
- public void add_file_data_to_nodule() {
- FileData fileData1 = new FileData("123", "456");
- FileData fileData2 = new FileData("153", "6432");
- FileData fileData3 = new FileData("987", "6343");
-
- repository.addFileDataToModule("Module1", "/Abc.java", fileData1);
- repository.addFileDataToModule("Module1", "/Xyz.java", fileData2);
- repository.addFileDataToModule("Module2", "/Def.java", fileData3);
-
- assertThat(repository.repositoriesByModule()).hasSize(2);
- assertThat(repository.fileData("Module1", "/Xyz.java")).isEqualTo(fileData2);
- assertThat(repository.fileData("Module2", "/Def.java")).isEqualTo(fileData3);
- }
-
- @Test
- public void add_file_does_not_add_the_file_without_path() {
- FileData fileData = new FileData("123", "456");
-
- repository.addFileDataToModule("module1", null, fileData);
-
- assertThat(repository.repositoriesByModule()).isEmpty();
- }
-
- @Test
- public void add_file_does_not_add_the_file_without_revision_and_hash() {
- FileData fileData = new FileData(null, null);
-
- repository.addFileDataToModule("module2", "/Abc.java", fileData);
-
- assertThat(repository.repositoriesByModule()).isEmpty();
- }
-}
diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/SingleProjectRepositoryTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/ProjectRepositoriesTest.java
index eb2185faa00..2918a438acc 100644
--- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/SingleProjectRepositoryTest.java
+++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/ProjectRepositoriesTest.java
@@ -25,13 +25,8 @@ import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
-public class SingleProjectRepositoryTest {
- private SingleProjectRepository repository;
-
- @Before
- public void setUp() {
- repository = new SingleProjectRepository();
- }
+public class ProjectRepositoriesTest {
+ private final ProjectRepositories repository = new ProjectRepositories();
@Test
public void add_file_data() {