From: Duarte Meneses Date: Wed, 9 Nov 2016 08:43:06 +0000 (+0100) Subject: Improve quality X-Git-Tag: 6.2-RC1~181 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d23cb6ddfee1c0e88f85696b200ae90e4ac5b5db;p=sonarqube.git Improve quality --- diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/JavaCpdBlockIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/JavaCpdBlockIndexer.java index b1717e8b82e..635b1248b70 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/JavaCpdBlockIndexer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/JavaCpdBlockIndexer.java @@ -23,6 +23,7 @@ import com.google.common.collect.Lists; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.List; @@ -90,7 +91,8 @@ public class JavaCpdBlockIndexer extends CpdBlockIndexer { List statements; - try (Reader reader = new InputStreamReader(new FileInputStream(inputFile.file()), fs.encoding())) { + try (InputStream is = new FileInputStream(inputFile.file()); + Reader reader = new InputStreamReader(is, fs.encoding())) { statements = statementChunker.chunk(tokenChunker.chunk(reader)); } catch (FileNotFoundException e) { throw new IllegalStateException("Cannot find file " + inputFile.file(), e); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java index 19fad3cfdfb..2790d095511 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java @@ -60,9 +60,6 @@ public class ProjectBuildersExecutor { } private static String getDescription(ProjectBuilder projectBuilder) { - if (projectBuilder == null) { - return null; - } Method toString; try { toString = projectBuilder.getClass().getMethod("toString"); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/MeasureValueCoder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/MeasureValueCoder.java index 15655a1f46c..cdeb31e1877 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/MeasureValueCoder.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/MeasureValueCoder.java @@ -49,9 +49,8 @@ class MeasureValueCoder implements ValueCoder { if (metric == null) { throw new IllegalStateException("Unknow metric with key " + metricKey); } - DefaultMeasure m = new DefaultMeasure() + return new DefaultMeasure() .forMetric(metric) .withValue((Serializable) value.get()); - return m; } }