From 2f007dc04cbf922c14a3f91e85e21b1bb6cd7247 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Fri, 31 Jul 2015 10:07:46 +0200 Subject: [PATCH] Improve quality --- .../java/org/sonar/runner/api/EmbeddedRunner.java | 2 +- .../src/main/java/org/sonar/runner/api/Issue.java | 2 -- .../java/org/sonar/runner/impl/ServerConnection.java | 11 +++++++++-- .../org/sonar/runner/impl/ServerConnectionTest.java | 2 +- .../java/org/sonar/runner/batch/IssueListener.java | 2 -- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java index c24bbb6..6d9f0fe 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java @@ -275,5 +275,5 @@ public class EmbeddedRunner { public void debug(String msg) { logOutput.log(msg, LogOutput.Level.DEBUG); } - }; + } } diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/Issue.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/Issue.java index 184a0b5..eb765dd 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/api/Issue.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/Issue.java @@ -21,8 +21,6 @@ package org.sonar.runner.api; import javax.annotation.concurrent.Immutable; -import java.util.Date; - @Immutable public final class Issue { private final String key; diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/impl/ServerConnection.java b/sonar-runner-api/src/main/java/org/sonar/runner/impl/ServerConnection.java index 45a7606..457e355 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/impl/ServerConnection.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/impl/ServerConnection.java @@ -71,11 +71,18 @@ class ServerConnection { String serverUrl = properties.getProperty("sonar.host.url"); String app = properties.getProperty(InternalProperties.RUNNER_APP); String appVersion = properties.getProperty(InternalProperties.RUNNER_APP_VERSION); + boolean enableCache = isCacheEnabled(properties); + + return new ServerConnection(serverUrl, app, appVersion, enableCache, cache, logger); + } + + private static boolean isCacheEnabled(Properties properties) { String analysisMode = properties.getProperty("sonar.analysis.mode"); String enableOffline = properties.getProperty("sonar.enableOffline"); - boolean enableCache = "preview".equalsIgnoreCase(analysisMode) && "true".equals(enableOffline); + boolean isPreview = "preview".equalsIgnoreCase(analysisMode) || "quick".equalsIgnoreCase(analysisMode) || + "incremental".equalsIgnoreCase(analysisMode); - return new ServerConnection(serverUrl, app, appVersion, enableCache, cache, logger); + return isPreview && "true".equals(enableOffline); } /** diff --git a/sonar-runner-api/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java b/sonar-runner-api/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java index 09f7811..4a147f6 100644 --- a/sonar-runner-api/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java +++ b/sonar-runner-api/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java @@ -86,7 +86,7 @@ public class ServerConnectionTest { httpServer.setMockResponseData("abcde"); Properties props = new Properties(); props.setProperty("sonar.host.url", httpServer.url() + "/"); - props.setProperty("sonar.analysis.mode", "preview"); + props.setProperty("sonar.analysis.mode", "quick"); props.setProperty("sonar.enableOffline", "true"); assertThat(cacheDir.list().length).isEqualTo(0); diff --git a/sonar-runner-batch-interface/src/main/java/org/sonar/runner/batch/IssueListener.java b/sonar-runner-batch-interface/src/main/java/org/sonar/runner/batch/IssueListener.java index 72a94e4..da59d80 100644 --- a/sonar-runner-batch-interface/src/main/java/org/sonar/runner/batch/IssueListener.java +++ b/sonar-runner-batch-interface/src/main/java/org/sonar/runner/batch/IssueListener.java @@ -19,8 +19,6 @@ */ package org.sonar.runner.batch; -import java.util.Date; - public interface IssueListener { void handle(Issue issue); -- 2.39.5