From 88e2e5ad2b82147dfe18cfd17ca967a79461ec8b Mon Sep 17 00:00:00 2001 From: Janos Gyerik Date: Thu, 20 Jul 2017 16:17:39 +0200 Subject: [PATCH] Improve quality (#34) --- src/main/java/org/sonarsource/scanner/cli/Conf.java | 6 +++--- src/main/java/org/sonarsource/scanner/cli/Main.java | 5 ++--- .../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(); } } -- 2.39.5