]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
Fix violations
authorEvgeny Mandrikov <mandrikov@gmail.com>
Thu, 15 Dec 2011 08:38:36 +0000 (08:38 +0000)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Thu, 15 Dec 2011 08:38:36 +0000 (08:38 +0000)
src/main/java/org/sonar/runner/Main.java
src/main/java/org/sonar/runner/Runner.java
src/test/java/org/sonar/runner/RunnerTest.java

index 839275e17c9a7d21c4c7d57470e814579d2d835c..0580c8bc65c6abde7b631ea454e35ec08f44462b 100644 (file)
@@ -33,7 +33,8 @@ import java.util.Properties;
  * Arguments :
  * <ul>
  * <li>runner.home: optional path to runner home (root directory with sub-directories bin, lib and conf)</li>
- * <li>runner.settings: optional path to runner global settings, usually ${runner.home}/conf/sonar-runner.properties. This property is used only if ${runner.home} is not defined</li>
+ * <li>runner.settings: optional path to runner global settings, usually ${runner.home}/conf/sonar-runner.properties.
+ * This property is used only if ${runner.home} is not defined</li>
  * <li>project.home: path to project root directory. If not set, then it's supposed to be the directory where the runner is executed</li>
  * <li>project.settings: optional path to project settings. Default value is ${project.home}/sonar-project.properties.</li>
  * </ul>
index 25e3932bac8aee399b931ac14972a0ff0e696aef..5928c8f4a19d44a71dd8aa9929dd49b171c659a8 100644 (file)
@@ -118,7 +118,7 @@ public final class Runner {
 
   private void checkSonarVersion(Bootstrapper bootstrapper) {
     String serverVersion = bootstrapper.getServerVersion();
-    if (isVersionPriorTo2Dot6(serverVersion)) {
+    if (isUnsupportedVersion(serverVersion)) {
       throw new BootstrapException("Sonar " + serverVersion
           + " does not support Standalone Runner. Please upgrade Sonar to version 2.6 or more.");
     }
@@ -131,14 +131,15 @@ public final class Runner {
         getClass().getClassLoader());
   }
 
-  static boolean isVersionPriorTo2Dot6(String version) {
-    return isVersion(version, "1")
-        || isVersion(version, "2.0")
-        || isVersion(version, "2.1")
-        || isVersion(version, "2.2")
-        || isVersion(version, "2.3")
-        || isVersion(version, "2.4")
-        || isVersion(version, "2.5");
+  private static final String[] unsupportedVersions = { "1", "2.0", "2.1", "2.2", "2.3", "2.4", "2.5" };
+
+  static boolean isUnsupportedVersion(String version) {
+    for (String unsupportedVersion : unsupportedVersions) {
+      if (isVersion(version, unsupportedVersion)) {
+        return true;
+      }
+    }
+    return false;
   }
 
   static boolean isVersion(String version, String prefix) {
index 97188300d6b41c375ddb0712644bb6dc239487f9..e7473130cebe40114a8ce4d720823dc53b96e067 100644 (file)
@@ -32,15 +32,15 @@ import static org.junit.Assert.assertThat;
 public class RunnerTest {
   @Test
   public void shouldCheckVersion() {
-    assertThat(Runner.isVersionPriorTo2Dot6("1.0"), is(true));
-    assertThat(Runner.isVersionPriorTo2Dot6("2.0"), is(true));
-    assertThat(Runner.isVersionPriorTo2Dot6("2.1"), is(true));
-    assertThat(Runner.isVersionPriorTo2Dot6("2.2"), is(true));
-    assertThat(Runner.isVersionPriorTo2Dot6("2.3"), is(true));
-    assertThat(Runner.isVersionPriorTo2Dot6("2.4"), is(true));
-    assertThat(Runner.isVersionPriorTo2Dot6("2.4.1"), is(true));
-    assertThat(Runner.isVersionPriorTo2Dot6("2.5"), is(true));
-    assertThat(Runner.isVersionPriorTo2Dot6("2.6"), is(false));
+    assertThat(Runner.isUnsupportedVersion("1.0"), is(true));
+    assertThat(Runner.isUnsupportedVersion("2.0"), is(true));
+    assertThat(Runner.isUnsupportedVersion("2.1"), is(true));
+    assertThat(Runner.isUnsupportedVersion("2.2"), is(true));
+    assertThat(Runner.isUnsupportedVersion("2.3"), is(true));
+    assertThat(Runner.isUnsupportedVersion("2.4"), is(true));
+    assertThat(Runner.isUnsupportedVersion("2.4.1"), is(true));
+    assertThat(Runner.isUnsupportedVersion("2.5"), is(true));
+    assertThat(Runner.isUnsupportedVersion("2.6"), is(false));
   }
 
   /**