From 55607c1aec3e980c096b108eb659a6ae45e628cb Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 20 Jun 2013 09:25:57 +0200 Subject: [PATCH] Fix some quality flaws --- .../org/sonar/runner/api/EmbeddedRunner.java | 2 +- .../java/org/sonar/runner/api/Runner.java | 2 +- .../org/sonar/runner/impl/BatchLauncher.java | 21 ++++++++++++------- 3 files changed, 15 insertions(+), 10 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 f83218f..fe14024 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 @@ -36,7 +36,7 @@ public class EmbeddedRunner extends Runner { private final BatchLauncher batchLauncher; private final List extensions = new ArrayList(); - private final static String MASK_RULES_PROP = "sonarRunner.maskRules"; + private static final String MASK_RULES_PROP = "sonarRunner.maskRules"; EmbeddedRunner(BatchLauncher bl) { this.batchLauncher = bl; diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java index afa5c37..85dd22f 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java @@ -22,6 +22,7 @@ package org.sonar.runner.api; import org.sonar.runner.impl.InternalProperties; import javax.annotation.Nullable; + import java.util.Properties; /** @@ -93,7 +94,6 @@ public abstract class Runner { private void initDefaultValues() { setDefaultValue(RunnerProperties.HOST_URL, "http://localhost:9000"); - //setDefaultValue(RunnerProperties.TASK, "scan"); setDefaultValue(InternalProperties.RUNNER_APP, "SonarRunner"); setDefaultValue(InternalProperties.RUNNER_APP_VERSION, RunnerVersion.version()); } diff --git a/sonar-runner-impl/src/main/java/org/sonar/runner/impl/BatchLauncher.java b/sonar-runner-impl/src/main/java/org/sonar/runner/impl/BatchLauncher.java index 96c28db..a862a38 100644 --- a/sonar-runner-impl/src/main/java/org/sonar/runner/impl/BatchLauncher.java +++ b/sonar-runner-impl/src/main/java/org/sonar/runner/impl/BatchLauncher.java @@ -50,6 +50,18 @@ public class BatchLauncher { doExecute(jarDownloader, props, extensions); } + private static String[][] getMaskRules(final Properties props) { + String maskRulesProp = props.getProperty(InternalProperties.RUNNER_MASK_RULES, null); + String[] maskRulesConcat = maskRulesProp != null ? maskRulesProp.split(",") : new String[0]; + String[][] maskRules = new String[maskRulesConcat.length][2]; + for (int i = 0; i < maskRulesConcat.length; i++) { + String[] splitted = maskRulesConcat[i].split("\\|"); + maskRules[i][0] = splitted[0]; + maskRules[i][1] = splitted.length > 1 ? splitted[1] : ""; + } + return maskRules; + } + /** * @return the {@link org.sonar.runner.batch.IsolatedLauncher} instance for unit tests */ @@ -57,14 +69,7 @@ public class BatchLauncher { Object launcher = AccessController.doPrivileged(new PrivilegedAction() { public Object run() { List jarFiles = jarDownloader.download(); - String maskRulesProp = props.getProperty(InternalProperties.RUNNER_MASK_RULES, null); - String[] maskRulesConcat = maskRulesProp != null ? maskRulesProp.split(",") : new String[0]; - String[][] maskRules = new String[maskRulesConcat.length][2]; - for (int i = 0; i < maskRulesConcat.length; i++) { - String[] splitted = maskRulesConcat[i].split("\\|"); - maskRules[i][0] = splitted[0]; - maskRules[i][1] = splitted.length > 1 ? splitted[1] : ""; - } + String[][] maskRules = getMaskRules(props); IsolatedClassloader classloader = new IsolatedClassloader(getClass().getClassLoader(), maskRules); classloader.addFiles(jarFiles); Object launcher = delegateExecution(classloader, props, extensions); -- 2.39.5