]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 16 Oct 2014 07:09:34 +0000 (09:09 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 16 Oct 2014 07:09:34 +0000 (09:09 +0200)
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/CoveragePerTestSensor.java
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/DependencySensor.java
sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java

index 70fe9b78ff77f5a266bc4e4dcbc2920180e0b79e..e16829385c85ff0551de8ed1bd530b807aa708b4 100644 (file)
@@ -75,6 +75,9 @@ public class CoveragePerTestSensor implements Sensor {
       String mainFileRelativePath = split.next();
       FileSystem fs = context.fileSystem();
       InputFile mainFile = fs.inputFile(fs.predicates().hasRelativePath(mainFileRelativePath));
+      if (mainFile == null) {
+        throw new IllegalStateException("Unable to find file " + mainFileRelativePath);
+      }
       List<Integer> coveredLines = new ArrayList<Integer>();
       Iterator<String> lines = Splitter.on(",").split(split.next()).iterator();
       while (lines.hasNext()) {
index 929092da866d1cb7385f4f15f38dcba4165ce06f..7ffca61bb62c26a71e28eca7dd05eb0a56853910 100644 (file)
@@ -73,6 +73,9 @@ public class DependencySensor implements Sensor {
       String otherFileRelativePath = split.next();
       FileSystem fs = context.fileSystem();
       InputFile otherFile = fs.inputFile(fs.predicates().hasRelativePath(otherFileRelativePath));
+      if (otherFile == null) {
+        throw new IllegalStateException("Unable to find file " + otherFileRelativePath);
+      }
       int weight = Integer.parseInt(split.next());
       context.newDependency()
         .from(file)
index ab8ff21c33c95352827f40c322a3159d8650984b..2886cfbc28c87f413f6d6cad4a360ba8555663d4 100644 (file)
@@ -269,7 +269,8 @@ public class BatchMediumTester {
         if (!coveragePerTest.get(testFileKey).containsKey(testName)) {
           coveragePerTest.get(testFileKey).put(testName, new HashMap<String, List<Integer>>());
         }
-        coveragePerTest.get(testFileKey).get(testName).put(entry.key()[2].toString(), entry.value().coveredLines());
+        TestCaseCoverage value = entry.value();
+        coveragePerTest.get(testFileKey).get(testName).put(entry.key()[2].toString(), value != null ? value.coveredLines() : null);
       }
     }