]> source.dussan.org Git - sonarqube.git/commitdiff
Improve quality
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 9 Nov 2016 08:43:06 +0000 (09:43 +0100)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 9 Nov 2016 08:43:08 +0000 (09:43 +0100)
sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/JavaCpdBlockIndexer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/measure/MeasureValueCoder.java

index b1717e8b82e999e05c7bc590bb88c8dbb6b222bd..635b1248b7006f4d4671626f6fc33112c776d50c 100644 (file)
@@ -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<Statement> 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);
index 19fad3cfdfb972bc245a999832f3024db89df149..2790d095511a73c42cec062299caabfd68f1ea7c 100644 (file)
@@ -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");
index 15655a1f46c4037d6914cfba432951c689faf724..cdeb31e187727a2462d27b03ef54e06067ad67e8 100644 (file)
@@ -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;
   }
 }