]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
Improve quality
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Fri, 31 Jul 2015 08:07:46 +0000 (10:07 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Fri, 31 Jul 2015 08:07:46 +0000 (10:07 +0200)
sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java
sonar-runner-api/src/main/java/org/sonar/runner/api/Issue.java
sonar-runner-api/src/main/java/org/sonar/runner/impl/ServerConnection.java
sonar-runner-api/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java
sonar-runner-batch-interface/src/main/java/org/sonar/runner/batch/IssueListener.java

index c24bbb6e2b9918dbd4f711705d32750650d46f0e..6d9f0fea73515a88f236599922a826c537123ab6 100644 (file)
@@ -275,5 +275,5 @@ public class EmbeddedRunner {
     public void debug(String msg) {
       logOutput.log(msg, LogOutput.Level.DEBUG);
     }
-  };
+  }
 }
index 184a0b51e7a6732e890c3f96b1a4c6e23c8989cc..eb765ddafafe12e6ae6d8afa24d70897a2651337 100644 (file)
@@ -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;
index 45a76064e356682902667052c448bbfe8156a378..457e3555428d488a9a7ab311ebe24dec85ab7be9 100644 (file)
@@ -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);
   }
 
   /**
index 09f78119ef3c16b899d8fbb1b9052e8cf7ca41da..4a147f64f2cb9d1d9f04f046cc3da6ef62ed253b 100644 (file)
@@ -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);
index 72a94e49a5853a4cc900d4f47f2ee953ba5e4368..da59d804e192ba4e9d40cc59ad381340b8d3d406 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.runner.batch;
 
-import java.util.Date;
-
 public interface IssueListener {
   void handle(Issue issue);