]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorJulien HENRY <julien.henry@sonarsource.com>
Fri, 21 Nov 2014 10:02:55 +0000 (11:02 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Fri, 21 Nov 2014 10:02:55 +0000 (11:02 +0100)
sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java
sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java
sonar-graph/src/main/java/org/sonar/graph/Dsm.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java

index c3916e739eb7ff1e09b1e23bfef515f5b01282ea..0ff6fbe57c2d9eec2ef1e19a1babfc36df4e3369 100644 (file)
@@ -215,7 +215,8 @@ public class SourcePersister implements ScanPersister {
     return result;
   }
 
-  private void writeRule(DefaultInputFile file, SyntaxHighlightingRule rule, StringBuilder[] highlightingPerLine, int currentLineIdx) {
+  private void writeRule(DefaultInputFile file, SyntaxHighlightingRule rule, StringBuilder[] highlightingPerLine, int currentLine) {
+    int currentLineIdx = currentLine;
     // We know current rule starts on current line
     long ruleStartOffsetCurrentLine = rule.getStartPosition();
     while (currentLineIdx < file.lines() && rule.getEndPosition() >= file.originalLineOffsets()[currentLineIdx]) {
index 1e880a6b31d0ecef0cba983a5fc233415a744cb0..5997f636ba291648c536dd63cb6b758096a1b2cc 100644 (file)
@@ -72,7 +72,7 @@ public class ModuleIssues {
   }
 
   private DefaultIssue newIssue(Violation violation) {
-    return (DefaultIssue) new DefaultIssueBuilder()
+    return new DefaultIssueBuilder()
       .componentKey(violation.getResource().getEffectiveKey())
       // Project can be null but Violation not used by scan2
       .projectKey(project.getRoot().getEffectiveKey())
index 32741b9e69df7ed1496a3d86118aec5524a4313a..a148c03d1903e67d72ef06d443c28b9a9ffde878 100644 (file)
@@ -27,7 +27,6 @@ import org.sonar.api.batch.SonarIndex;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.InputFile.Status;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
 import org.sonar.api.resources.File;
 import org.sonar.api.resources.Languages;
@@ -72,7 +71,6 @@ public class ComponentIndexer implements BatchComponent {
     migration.migrateIfNeeded(module, fs);
 
     for (InputFile inputFile : fs.inputFiles(fs.predicates().all())) {
-      DefaultInputFile defaultInputFile = (DefaultInputFile) inputFile;
       String languageKey = inputFile.language();
       boolean unitTest = InputFile.Type.TEST == inputFile.type();
       String pathFromSourceDir = ((DeprecatedDefaultInputFile) inputFile).pathRelativeToSourceDir();
index 69e85c251dafc5974d98732c085f739e4a7975c1..4d8673d1992e4cc45306004b1f829bccca5f3043 100644 (file)
@@ -49,7 +49,7 @@ public class Dsm<V> {
   }
 
   private DsmCell[][] initCells(Set<Edge> feedbackEdges) {
-    DsmCell[][] cells = new DsmCell[dimension][dimension];
+    DsmCell[][] result = new DsmCell[dimension][dimension];
     for (int x = 0; x < dimension; x++) {
       for (int y = 0; y < dimension; y++) {
         V from = vertices[x];
@@ -59,21 +59,21 @@ public class Dsm<V> {
         if (edge != null) {
           atLeastOneDependency = true;
           boolean isFeedbackEdge = feedbackEdges.contains(edge);
-          cells[x][y] = new DsmCell(edge, isFeedbackEdge);
+          result[x][y] = new DsmCell(edge, isFeedbackEdge);
         }
       }
     }
-    return cells;
+    return result;
   }
 
   private V[] initVertices(Collection<V> verticesCol) {
-    V[] vertices = (V[]) new Object[dimension];
+    V[] result = (V[]) new Object[dimension];
     int i = 0;
     for (V vertex : verticesCol) {
-      vertices[i] = vertex;
+      result[i] = vertex;
       i++;
     }
-    return vertices;
+    return result;
   }
 
   public V getVertex(int rowIndex) {
index e340f8051242f793a2cf6540f3e4de7f42d75ff1..d542a667eda9a65f2cb791249042228a3c5fa6a8 100644 (file)
@@ -48,7 +48,7 @@ public class Duration implements Serializable {
   }
 
   private Duration(int days, int hours, int minutes, int hoursInDay) {
-    this(((long) days * hoursInDay * MINUTES_IN_ONE_HOUR) + (hours * MINUTES_IN_ONE_HOUR) + minutes);
+    this((days * hoursInDay * MINUTES_IN_ONE_HOUR) + (hours * MINUTES_IN_ONE_HOUR) + minutes);
   }
 
   /**
index 7bbfe5821225b17680d31a55b864dd98e6825b2e..7dd8167daf5f0b75ace9136b1a5412f632a1b029 100644 (file)
@@ -100,7 +100,7 @@ public class WorkDuration implements Serializable {
   }
 
   static WorkDuration createFromMinutes(long duration, int hoursInDay) {
-    int days = ((Double) ((double) duration / hoursInDay / 60d)).intValue();
+    int days = ((Double) (duration / hoursInDay / 60d)).intValue();
     Long currentDurationInMinutes = duration - (60L * days * hoursInDay);
     int hours = ((Double) (currentDurationInMinutes / 60d)).intValue();
     currentDurationInMinutes = currentDurationInMinutes - (60L * hours);