aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-12-15 08:38:36 +0000
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-12-15 08:38:36 +0000
commit650807cc45fbdb2a8f732f00a91da259b07e9fbd (patch)
tree0a79809e3a2cf87c9382c8e2b26b47e9ec80d204 /src
parent0be0b4df98034d96d0ec4b0ca5fa29a310a2fd22 (diff)
downloadsonar-scanner-cli-650807cc45fbdb2a8f732f00a91da259b07e9fbd.tar.gz
sonar-scanner-cli-650807cc45fbdb2a8f732f00a91da259b07e9fbd.zip
Fix violations
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/sonar/runner/Main.java3
-rw-r--r--src/main/java/org/sonar/runner/Runner.java19
-rw-r--r--src/test/java/org/sonar/runner/RunnerTest.java18
3 files changed, 21 insertions, 19 deletions
diff --git a/src/main/java/org/sonar/runner/Main.java b/src/main/java/org/sonar/runner/Main.java
index 839275e..0580c8b 100644
--- a/src/main/java/org/sonar/runner/Main.java
+++ b/src/main/java/org/sonar/runner/Main.java
@@ -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>
diff --git a/src/main/java/org/sonar/runner/Runner.java b/src/main/java/org/sonar/runner/Runner.java
index 25e3932..5928c8f 100644
--- a/src/main/java/org/sonar/runner/Runner.java
+++ b/src/main/java/org/sonar/runner/Runner.java
@@ -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) {
diff --git a/src/test/java/org/sonar/runner/RunnerTest.java b/src/test/java/org/sonar/runner/RunnerTest.java
index 9718830..e747313 100644
--- a/src/test/java/org/sonar/runner/RunnerTest.java
+++ b/src/test/java/org/sonar/runner/RunnerTest.java
@@ -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));
}
/**