Skip to content

Commit

Permalink
SCANCLI-165 Remove Redundant loggin as moved to the Scanner Java Library
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-vinot-sonarsource committed Jan 10, 2025
1 parent 4b01d1b commit 41a1e1d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
11 changes: 0 additions & 11 deletions src/main/java/org/sonarsource/scanner/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down
26 changes: 0 additions & 26 deletions src/test/java/org/sonarsource/scanner/cli/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 41a1e1d

Please sign in to comment.