aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-01-22 09:53:57 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2013-01-22 09:53:57 +0100
commite727146d35b4053e8703e57753356ea33710f9cc (patch)
treedb474cebba5cb8b31bea3f8b3de3ac94dd445937 /src/main/java
parent4007cde0f968c9fe63ebb6a30b49732992260593 (diff)
downloadsonar-scanner-cli-e727146d35b4053e8703e57753356ea33710f9cc.tar.gz
sonar-scanner-cli-e727146d35b4053e8703e57753356ea33710f9cc.zip
Fix some quality flaws.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/sonar/runner/IOUtils.java3
-rw-r--r--src/main/java/org/sonar/runner/Main.java12
-rw-r--r--src/main/java/org/sonar/runner/Runner.java10
-rw-r--r--src/main/java/org/sonar/runner/internal/batch/Launcher.java3
-rw-r--r--src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java2
5 files changed, 21 insertions, 9 deletions
diff --git a/src/main/java/org/sonar/runner/IOUtils.java b/src/main/java/org/sonar/runner/IOUtils.java
index 6c566a2..248d18d 100644
--- a/src/main/java/org/sonar/runner/IOUtils.java
+++ b/src/main/java/org/sonar/runner/IOUtils.java
@@ -130,7 +130,8 @@ final class IOUtils {
}
File[] files = directory.listFiles();
- if (files == null) { // null if security restricted
+ // null if security restricted
+ if (files == null) {
throw new IOException("Failed to list contents of " + directory);
}
diff --git a/src/main/java/org/sonar/runner/Main.java b/src/main/java/org/sonar/runner/Main.java
index 9cb9d47..add38bf 100644
--- a/src/main/java/org/sonar/runner/Main.java
+++ b/src/main/java/org/sonar/runner/Main.java
@@ -49,10 +49,14 @@ public final class Main {
// TODO Remove this after everything is updated to support tasks
private static final String TASK_COMMAND = "sonar.task";
- private boolean debugMode = false;
- private boolean displayVersionOnly = false;
- private boolean displayStackTrace = false;
- private String command;
+ @VisibleForTesting
+ boolean debugMode = false;
+ @VisibleForTesting
+ boolean displayVersionOnly = false;
+ @VisibleForTesting
+ boolean displayStackTrace = false;
+ @VisibleForTesting
+ String command;
@VisibleForTesting
Properties globalProperties;
@VisibleForTesting
diff --git a/src/main/java/org/sonar/runner/Runner.java b/src/main/java/org/sonar/runner/Runner.java
index e075f62..9d404da 100644
--- a/src/main/java/org/sonar/runner/Runner.java
+++ b/src/main/java/org/sonar/runner/Runner.java
@@ -19,6 +19,8 @@
*/
package org.sonar.runner;
+import com.google.common.annotations.VisibleForTesting;
+
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -244,7 +246,8 @@ public final class Runner {
/**
* @return global properties, project properties and command-line properties
*/
- protected Properties getProperties() {
+ @VisibleForTesting
+ public Properties getProperties() {
Properties props = new Properties();
props.putAll(globalProperties);
props.putAll(projectProperties);
@@ -266,7 +269,8 @@ public final class Runner {
private BootstrapClassLoader createClassLoader(Bootstrapper bootstrapper) {
URL url = getJarPath();
return bootstrapper.createClassLoader(
- new URL[] {url}, // Add JAR with Sonar Runner - it's a Jar which contains this class
+ // Add JAR with Sonar Runner - it's a Jar which contains this class
+ new URL[] {url},
getClass().getClassLoader(),
unmaskedPackages);
}
@@ -293,7 +297,7 @@ public final class Runner {
if (uri != null) {
try {
return new URL(uri);
- } catch (MalformedURLException e) { // NOSONAR
+ } catch (MalformedURLException e) {
}
}
}
diff --git a/src/main/java/org/sonar/runner/internal/batch/Launcher.java b/src/main/java/org/sonar/runner/internal/batch/Launcher.java
index 5e36cfa..1aebbd9 100644
--- a/src/main/java/org/sonar/runner/internal/batch/Launcher.java
+++ b/src/main/java/org/sonar/runner/internal/batch/Launcher.java
@@ -50,6 +50,9 @@ public class Launcher {
private Properties projectProperties;
private List<Object> containerExtensions;
+ /**
+ * @deprecated Use {@link Launcher#Launcher(String, Properties, Properties, List)} instead
+ */
@Deprecated
public Launcher(Properties properties, List<Object> containerExtensions) {
this("project-analysis", new Properties(), properties, containerExtensions);
diff --git a/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java b/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java
index 46171b4..84b8788 100644
--- a/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java
+++ b/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java
@@ -128,7 +128,7 @@ public final class SonarProjectBuilder {
}
public ProjectDefinition generateProjectDefinition() {
- if (StringUtils.isBlank(command) || command.equals("inspect")) {
+ if (StringUtils.isBlank(command) || "inspect".equals(command)) {
ProjectDefinition rootProject = defineProject(properties, null);
rootProjectWorkDir = rootProject.getWorkDir();
defineChildren(rootProject);