From: Gabor Liptak Date: Tue, 9 Jun 2015 11:36:36 +0000 (-0400) Subject: Cleanup warnings X-Git-Tag: 2.5-rc1~85^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=648bbdd90f1c590900c769048392179024186412;p=sonar-scanner-cli.git Cleanup warnings --- diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/Dirs.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/Dirs.java index 369a745..1ed4a04 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/api/Dirs.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/Dirs.java @@ -25,7 +25,7 @@ import java.io.File; class Dirs { - void init(Runner runner) { + void init(Runner runner) { boolean onProject = Utils.taskRequiresProject(runner.properties()); if (onProject) { initProjectDirs(runner); @@ -34,7 +34,7 @@ class Dirs { } } - private void initProjectDirs(Runner runner) { + private void initProjectDirs(Runner runner) { String path = runner.property(ScanProperties.PROJECT_BASEDIR, "."); File projectDir = new File(path); if (!projectDir.isDirectory()) { @@ -61,7 +61,7 @@ class Dirs { /** * Non-scan task */ - private void initTaskDirs(Runner runner) { + private void initTaskDirs(Runner runner) { String path = runner.property(RunnerProperties.WORK_DIR, "."); File workDir = new File(path); runner.setProperty(RunnerProperties.WORK_DIR, workDir.getAbsolutePath()); diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/SourceEncoding.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/SourceEncoding.java index 1f3915e..44d243b 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/api/SourceEncoding.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/SourceEncoding.java @@ -26,7 +26,7 @@ import java.util.Locale; class SourceEncoding { - void init(Runner runner) { + void init(Runner runner) { boolean onProject = Utils.taskRequiresProject(runner.properties()); if (onProject) { String sourceEncoding = runner.property(ScanProperties.PROJECT_SOURCE_ENCODING, ""); diff --git a/sonar-runner-api/src/test/java/org/sonar/runner/api/DirsTest.java b/sonar-runner-api/src/test/java/org/sonar/runner/api/DirsTest.java index 8313760..b66d075 100644 --- a/sonar-runner-api/src/test/java/org/sonar/runner/api/DirsTest.java +++ b/sonar-runner-api/src/test/java/org/sonar/runner/api/DirsTest.java @@ -29,7 +29,7 @@ import static org.fest.assertions.Assertions.assertThat; public class DirsTest { - Runner runner = new SimpleRunner(); + Runner runner = new SimpleRunner(); Dirs dirs = new Dirs(); @Rule diff --git a/sonar-runner-api/src/test/java/org/sonar/runner/api/SimpleRunner.java b/sonar-runner-api/src/test/java/org/sonar/runner/api/SimpleRunner.java index fd443d1..25b8c6b 100644 --- a/sonar-runner-api/src/test/java/org/sonar/runner/api/SimpleRunner.java +++ b/sonar-runner-api/src/test/java/org/sonar/runner/api/SimpleRunner.java @@ -19,7 +19,7 @@ */ package org.sonar.runner.api; -class SimpleRunner extends Runner { +class SimpleRunner extends Runner { @Override protected void doExecute() { } diff --git a/sonar-runner-api/src/test/java/org/sonar/runner/api/SourceEncodingTest.java b/sonar-runner-api/src/test/java/org/sonar/runner/api/SourceEncodingTest.java index 6fc994e..78b0ec4 100644 --- a/sonar-runner-api/src/test/java/org/sonar/runner/api/SourceEncodingTest.java +++ b/sonar-runner-api/src/test/java/org/sonar/runner/api/SourceEncodingTest.java @@ -28,7 +28,7 @@ import static org.fest.assertions.Assertions.assertThat; public class SourceEncodingTest { SourceEncoding encoding = new SourceEncoding(); - Runner runner = new SimpleRunner(); + Runner runner = new SimpleRunner(); @Test public void should_set_default_platform_encoding() throws Exception { diff --git a/sonar-runner-dist/src/main/java/org/sonar/runner/RunnerFactory.java b/sonar-runner-dist/src/main/java/org/sonar/runner/RunnerFactory.java index 7f1dddf..0396428 100644 --- a/sonar-runner-dist/src/main/java/org/sonar/runner/RunnerFactory.java +++ b/sonar-runner-dist/src/main/java/org/sonar/runner/RunnerFactory.java @@ -27,8 +27,8 @@ import java.util.Properties; class RunnerFactory { - Runner create(Properties props) { - Runner runner; + Runner create(Properties props) { + Runner runner; if ("fork".equals(props.getProperty("sonarRunner.mode"))) { runner = ForkedRunner.create(); String jvmArgs = props.getProperty("sonarRunner.fork.jvmArgs", ""); diff --git a/sonar-runner-dist/src/test/java/org/sonar/runner/RunnerFactoryTest.java b/sonar-runner-dist/src/test/java/org/sonar/runner/RunnerFactoryTest.java index 6c003c8..56124d8 100644 --- a/sonar-runner-dist/src/test/java/org/sonar/runner/RunnerFactoryTest.java +++ b/sonar-runner-dist/src/test/java/org/sonar/runner/RunnerFactoryTest.java @@ -35,7 +35,7 @@ public class RunnerFactoryTest { @Test public void should_create_embedded_runner_by_default() { props.setProperty("foo", "bar"); - Runner runner = new RunnerFactory().create(props); + Runner runner = new RunnerFactory().create(props); assertThat(runner).isInstanceOf(EmbeddedRunner.class); assertThat(runner.properties().get("foo")).isEqualTo("bar"); @@ -46,7 +46,7 @@ public class RunnerFactoryTest { props.setProperty("foo", "bar"); props.setProperty("sonarRunner.mode", "fork"); props.setProperty("sonarRunner.fork.jvmArgs", "-Xms128m -Xmx512m"); - Runner runner = new RunnerFactory().create(props); + Runner runner = new RunnerFactory().create(props); assertThat(runner).isInstanceOf(ForkedRunner.class); assertThat(runner.properties().get("foo")).isEqualTo("bar"); @@ -57,7 +57,7 @@ public class RunnerFactoryTest { public void should_create_forked_runner_with_jvm_arguments() { props.setProperty("foo", "bar"); props.setProperty("sonarRunner.mode", "fork"); - Runner runner = new RunnerFactory().create(props); + Runner runner = new RunnerFactory().create(props); assertThat(runner).isInstanceOf(ForkedRunner.class); assertThat(runner.properties().get("foo")).isEqualTo("bar"); diff --git a/sonar-runner-impl/src/test/java/org/sonar/runner/impl/BatchLauncherMainTest.java b/sonar-runner-impl/src/test/java/org/sonar/runner/impl/BatchLauncherMainTest.java index e959409..996fc42 100644 --- a/sonar-runner-impl/src/test/java/org/sonar/runner/impl/BatchLauncherMainTest.java +++ b/sonar-runner-impl/src/test/java/org/sonar/runner/impl/BatchLauncherMainTest.java @@ -50,7 +50,7 @@ public class BatchLauncherMainTest { }), argThat(new ArgumentMatcher>() { @Override public boolean matches(Object o) { - return ((List) o).isEmpty(); + return ((List) o).isEmpty(); } })); } diff --git a/sonar-runner-impl/src/test/java/org/sonar/runner/impl/IsolatedClassloaderTest.java b/sonar-runner-impl/src/test/java/org/sonar/runner/impl/IsolatedClassloaderTest.java index 1adaa0d..222a2f5 100644 --- a/sonar-runner-impl/src/test/java/org/sonar/runner/impl/IsolatedClassloaderTest.java +++ b/sonar-runner-impl/src/test/java/org/sonar/runner/impl/IsolatedClassloaderTest.java @@ -19,6 +19,8 @@ */ package org.sonar.runner.impl; +import java.io.IOException; + import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -30,7 +32,7 @@ public class IsolatedClassloaderTest { public ExpectedException thrown = ExpectedException.none(); @Test - public void should_restrict_loading_from_parent() throws Exception { + public void should_restrict_loading_from_parent() throws IOException { ClassLoader parentClassloader = getClass().getClassLoader(); IsolatedClassloader classLoader = new IsolatedClassloader(parentClassloader, new String[][] {new String[] {"UNMASK", "org.apache.ant."}}); @@ -39,10 +41,11 @@ public class IsolatedClassloaderTest { assertThat(classLoader.canLoadFromParent("org.apache.ant.Foo")).isTrue(); assertThat(classLoader.canLoadFromParent("org.apache.ant.project.Project")).isTrue(); + classLoader.close(); } @Test - public void should_use_isolated_system_classloader_when_parent_is_excluded() throws ClassNotFoundException { + public void should_use_isolated_system_classloader_when_parent_is_excluded() throws ClassNotFoundException, IOException { thrown.expect(ClassNotFoundException.class); thrown.expectMessage("org.junit.Test"); ClassLoader parent = getClass().getClassLoader(); @@ -51,14 +54,16 @@ public class IsolatedClassloaderTest { // JUnit is available in the parent classloader (classpath used to execute this test) but not in the core JVM assertThat(classLoader.loadClass("java.lang.String", false)).isNotNull(); classLoader.loadClass("org.junit.Test", false); + classLoader.close(); } @Test - public void should_find_in_parent_when_matches_unmasked_packages() throws ClassNotFoundException { + public void should_find_in_parent_when_matches_unmasked_packages() throws ClassNotFoundException, IOException { ClassLoader parent = getClass().getClassLoader(); IsolatedClassloader classLoader = new IsolatedClassloader(parent, new String[][] {new String[] {"UNMASK", "org.junit."}}); // JUnit is available in the parent classloader (classpath used to execute this test) but not in the core JVM assertThat(classLoader.loadClass("org.junit.Test", false)).isNotNull(); + classLoader.close(); } } diff --git a/sonar-runner-impl/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java b/sonar-runner-impl/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java index c8bf525..b1a94c7 100644 --- a/sonar-runner-impl/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java +++ b/sonar-runner-impl/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java @@ -28,8 +28,6 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import java.io.File; -import java.io.IOException; -import java.nio.file.Paths; import java.util.Properties; import static org.fest.assertions.Assertions.assertThat;