Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCANCLI-165 Remove Redundant loggin as moved to the Scanner Java Library #207

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading