diff options
author | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-07-20 16:17:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-20 16:17:39 +0200 |
commit | 88e2e5ad2b82147dfe18cfd17ca967a79461ec8b (patch) | |
tree | e39e5ad4071dff1173f2943f6d2cf84d651ef856 | |
parent | 20e32e602d3ea4a23e27e5b3fd22299b5a7790f7 (diff) | |
download | sonar-scanner-cli-88e2e5ad2b82147dfe18cfd17ca967a79461ec8b.tar.gz sonar-scanner-cli-88e2e5ad2b82147dfe18cfd17ca967a79461ec8b.zip |
Improve quality (#34)
-rw-r--r-- | src/main/java/org/sonarsource/scanner/cli/Conf.java | 6 | ||||
-rw-r--r-- | src/main/java/org/sonarsource/scanner/cli/Main.java | 5 | ||||
-rw-r--r-- | src/main/java/org/sonarsource/scanner/cli/ScannerVersion.java | 7 |
3 files changed, 7 insertions, 11 deletions
diff --git a/src/main/java/org/sonarsource/scanner/cli/Conf.java b/src/main/java/org/sonarsource/scanner/cli/Conf.java index 8bfe39c..26f44f0 100644 --- a/src/main/java/org/sonarsource/scanner/cli/Conf.java +++ b/src/main/java/org/sonarsource/scanner/cli/Conf.java @@ -55,7 +55,7 @@ class Conf { this.env = env; } - Properties properties() throws IOException { + Properties properties() { Properties result = new Properties(); result.putAll(loadGlobalProperties()); result.putAll(loadProjectProperties()); @@ -79,7 +79,7 @@ class Conf { return Utils.loadEnvironmentProperties(env); } - private Properties loadGlobalProperties() throws IOException { + private Properties loadGlobalProperties() { Path settingsFile = locatePropertiesFile(cli.properties(), SCANNER_HOME, "conf/sonar-scanner.properties", SCANNER_SETTINGS); if (settingsFile != null && Files.isRegularFile(settingsFile)) { @@ -90,7 +90,7 @@ class Conf { return new Properties(); } - private Properties loadProjectProperties() throws IOException { + private Properties loadProjectProperties() { Properties rootProps = new Properties(); Properties knownProps = new Properties(); diff --git a/src/main/java/org/sonarsource/scanner/cli/Main.java b/src/main/java/org/sonarsource/scanner/cli/Main.java index fe7ad94..d93116b 100644 --- a/src/main/java/org/sonarsource/scanner/cli/Main.java +++ b/src/main/java/org/sonarsource/scanner/cli/Main.java @@ -19,7 +19,6 @@ */ package org.sonarsource.scanner.cli; -import java.io.IOException; import java.util.Properties; import org.sonarsource.scanner.api.EmbeddedScanner; import org.sonarsource.scanner.api.ScanProperties; @@ -102,7 +101,7 @@ public class Main { } } - private void init(Properties p) throws IOException { + private void init(Properties p) { SystemInfo.print(logger); if (cli.isDisplayVersionOnly()) { exit.exit(Exit.SUCCESS); @@ -111,7 +110,7 @@ public class Main { runner = runnerFactory.create(p); } - private void configureLogging(Properties props) throws IOException { + private void configureLogging(Properties props) { if ("true".equals(props.getProperty("sonar.verbose")) || "DEBUG".equalsIgnoreCase(props.getProperty("sonar.log.level")) || "TRACE".equalsIgnoreCase(props.getProperty("sonar.log.level"))) { diff --git a/src/main/java/org/sonarsource/scanner/cli/ScannerVersion.java b/src/main/java/org/sonarsource/scanner/cli/ScannerVersion.java index 3184439..8e05244 100644 --- a/src/main/java/org/sonarsource/scanner/cli/ScannerVersion.java +++ b/src/main/java/org/sonarsource/scanner/cli/ScannerVersion.java @@ -27,12 +27,9 @@ public enum ScannerVersion { private String version; - private ScannerVersion() { - Scanner scanner = new Scanner(getClass().getResourceAsStream("/version.txt"), "UTF-8"); - try { + ScannerVersion() { + try (Scanner scanner = new Scanner(getClass().getResourceAsStream("/version.txt"), "UTF-8")) { this.version = scanner.next(); - } finally { - scanner.close(); } } |