aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2024-05-02 15:04:30 +0200
committersonartech <sonartech@sonarsource.com>2024-05-02 20:02:38 +0000
commitf8755ae02ed58f5b3ce55e33d90589202aadd15e (patch)
tree04d6c374bf92c30e4a1c993bb3793d4e2803bc99 /sonar-scanner-engine
parent87ead0c47d63672052ff50b541b9d69e8c9757a2 (diff)
downloadsonarqube-f8755ae02ed58f5b3ce55e33d90589202aadd15e.tar.gz
sonarqube-f8755ae02ed58f5b3ce55e33d90589202aadd15e.zip
Fix some quality flaws
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/bootstrap/BootstrapMediumIT.java30
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java9
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/http/ScannerWsClientProviderTest.java8
4 files changed, 26 insertions, 23 deletions
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/bootstrap/BootstrapMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/bootstrap/BootstrapMediumIT.java
index 8320b9dc0e7..d7e0f7fc758 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/bootstrap/BootstrapMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/bootstrap/BootstrapMediumIT.java
@@ -57,9 +57,11 @@ class BootstrapMediumIT {
@BeforeEach
void mockBareMinimalServerEndpoints() {
sonarqube.stubFor(get("/api/plugins/installed")
- .willReturn(okJson("{\n"
- + " \"plugins\": []\n"
- + "}")));
+ .willReturn(okJson("""
+ {
+ "plugins": []
+ }
+ """)));
sonarqube.stubFor(get("/api/qualityprofiles/search.protobuf?project=" + PROJECT_KEY)
.willReturn(aResponse()
@@ -77,17 +79,21 @@ class BootstrapMediumIT {
.build()))));
sonarqube.stubFor(get("/api/languages/list")
- .willReturn(okJson("{\n"
- + " \"languages\": []\n"
- + "}")));
+ .willReturn(okJson("""
+ {
+ "languages": []
+ }
+ """)));
sonarqube.stubFor(get("/api/metrics/search?ps=500&p=1")
- .willReturn(okJson("{\n"
- + " \"metrics\": [],\n"
- + " \"total\": 0,\n"
- + " \"p\": 1,\n"
- + " \"ps\": 100"
- + "}")));
+ .willReturn(okJson("""
+ {
+ "metrics": [],
+ "total": 0,
+ "p": 1,
+ "ps": 100
+ }
+ """)));
sonarqube.stubFor(post("/api/ce/submit?projectKey=" + PROJECT_KEY)
.willReturn(aResponse()
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java
index 9d8522a897f..2a27b7c5653 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalTempFolderProviderTest.java
@@ -19,7 +19,6 @@
*/
package org.sonar.scanner.bootstrap;
-import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@@ -49,7 +48,7 @@ class GlobalTempFolderProviderTest {
Files.delete(workingDir);
var tempFolder = underTest.provide(
- new ScannerProperties(ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.toAbsolutePath().toString())), sonarUserHome);
+ new ScannerProperties(Map.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.toAbsolutePath().toString())), sonarUserHome);
tempFolder.newDir();
tempFolder.newFile();
@@ -71,7 +70,7 @@ class GlobalTempFolderProviderTest {
}
underTest.provide(
- new ScannerProperties(ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.toAbsolutePath().toString())), sonarUserHome);
+ new ScannerProperties(Map.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.toAbsolutePath().toString())), sonarUserHome);
// this also checks that all other temps were deleted
assertThat(workingDir.toFile().list()).hasSize(1);
@@ -88,7 +87,7 @@ class GlobalTempFolderProviderTest {
}
@Test
- void createTempFolderFromSonarHome(@TempDir Path sonarUserHomePath) throws Exception {
+ void createTempFolderFromSonarHome(@TempDir Path sonarUserHomePath) {
// with sonar home, it will be in {sonar.home}/.sonartmp
when(sonarUserHome.getPath()).thenReturn(sonarUserHomePath);
@@ -109,7 +108,7 @@ class GlobalTempFolderProviderTest {
when(sonarUserHome.getPath()).thenReturn(sonarUserHomePath);
String globalWorkDir = ".";
ScannerProperties globalProperties = new ScannerProperties(
- ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, globalWorkDir));
+ Map.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, globalWorkDir));
var tempFolder = underTest.provide(globalProperties, sonarUserHome);
File newFile = tempFolder.newFile();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java
index 907e13f92bc..97d33f200fa 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java
@@ -78,7 +78,7 @@ class PluginFilesTest {
private PluginFiles underTest;
@BeforeEach
- void setUp(@TempDir Path sonarUserHomeDir) throws Exception {
+ void setUp(@TempDir Path sonarUserHomeDir) {
when(sonarUserHome.getPath()).thenReturn(sonarUserHomeDir);
HttpConnector connector = HttpConnector.newBuilder().acceptGzip(true).url(sonarqube.url("/")).build();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/http/ScannerWsClientProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/http/ScannerWsClientProviderTest.java
index e0ee3121acc..e605999ddd3 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/http/ScannerWsClientProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/http/ScannerWsClientProviderTest.java
@@ -66,9 +66,7 @@ class ScannerWsClientProviderTest {
private static final GlobalAnalysisMode GLOBAL_ANALYSIS_MODE = new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap()));
private static final AnalysisWarnings ANALYSIS_WARNINGS = warning -> {
};
- @TempDir
- private Path sonarUserHomeDir;
- private final SonarUserHome sonarUserHome = mock(SonarUserHome.class);
+ private SonarUserHome sonarUserHome = mock(SonarUserHome.class);
private final Map<String, String> scannerProps = new HashMap<>();
private final ScannerWsClientProvider underTest = new ScannerWsClientProvider();
@@ -78,9 +76,9 @@ class ScannerWsClientProviderTest {
private final Properties systemProps = new Properties();
@BeforeEach
- void configureMocks() {
+ void configureMocks(@TempDir Path sonarUserHomeDir) {
when(system2.properties()).thenReturn(systemProps);
- when(sonarUserHome.getPath()).thenReturn(sonarUserHomeDir);
+ sonarUserHome = new SonarUserHome(sonarUserHomeDir);
}
@Test