From 41a1e1d7e67d81cb566ba75e9a4a5ee91b95309e Mon Sep 17 00:00:00 2001 From: "antoine.vinot" Date: Fri, 10 Jan 2025 11:47:50 +0100 Subject: [PATCH] SCANCLI-165 Remove Redundant loggin as moved to the Scanner Java Library --- .../org/sonarsource/scanner/cli/Main.java | 11 -------- .../org/sonarsource/scanner/cli/MainTest.java | 26 ------------------- 2 files changed, 37 deletions(-) diff --git a/src/main/java/org/sonarsource/scanner/cli/Main.java b/src/main/java/org/sonarsource/scanner/cli/Main.java index b1034186..fe53f1c5 100644 --- a/src/main/java/org/sonarsource/scanner/cli/Main.java +++ b/src/main/java/org/sonarsource/scanner/cli/Main.java @@ -25,7 +25,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonarsource.scanner.lib.ScannerEngineBootstrapper; -import org.sonarsource.scanner.lib.ScannerEngineFacade; import org.sonarsource.scanner.lib.ScannerProperties; /** @@ -73,7 +72,6 @@ void analyze() { configureLogging(p); init(p); try (var engine = scannerEngineBootstrapper.bootstrap()) { - logServerType(engine); var success = engine.analyze((Map) p); if (success) { displayExecutionResult(stats, "SUCCESS"); @@ -92,15 +90,6 @@ void analyze() { } } - private static void logServerType(ScannerEngineFacade engine) { - if (engine.isSonarCloud()) { - LOG.info("Communicating with SonarCloud"); - } else { - String serverVersion = engine.getServerVersion(); - LOG.info("Communicating with SonarQube Server {}", serverVersion); - } - } - private void checkSkip(Properties properties) { if ("true".equalsIgnoreCase(properties.getProperty(ScannerProperties.SKIP))) { LOG.info("SonarScanner CLI analysis skipped"); diff --git a/src/test/java/org/sonarsource/scanner/cli/MainTest.java b/src/test/java/org/sonarsource/scanner/cli/MainTest.java index 36e21a4b..746f5c98 100644 --- a/src/test/java/org/sonarsource/scanner/cli/MainTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/MainTest.java @@ -226,32 +226,6 @@ void should_skip() { inOrder.verify(scannerEngineBootstrapperFactory, times(1)).create(p, ""); } - @Test - void shouldLogServerVersion() { - when(engine.isSonarCloud()).thenReturn(false); - when(engine.getServerVersion()).thenReturn("5.5"); - Properties p = new Properties(); - when(cli.isDisplayVersionOnly()).thenReturn(true); - when(cli.getInvokedFrom()).thenReturn(""); - when(conf.properties()).thenReturn(p); - - Main main = new Main(exit, cli, conf, scannerEngineBootstrapperFactory); - main.analyze(); - assertThat(logTester.logs(Level.INFO)).contains("Communicating with SonarQube Server 5.5"); - } - - @Test - void should_log_SonarCloud_server() { - when(engine.isSonarCloud()).thenReturn(true); - Properties p = new Properties(); - when(conf.properties()).thenReturn(p); - when(cli.getInvokedFrom()).thenReturn(""); - - Main main = new Main(exit, cli, conf, scannerEngineBootstrapperFactory); - main.analyze(); - assertThat(logTester.logs(Level.INFO)).contains("Communicating with SonarCloud"); - } - @Test void should_configure_logging() { Properties analysisProps = testLogging("sonar.verbose", "true");