diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-11-21 11:02:55 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-11-21 11:02:55 +0100 |
commit | 50050c7ea204110ee4ac3bf59e8f42f510622f12 (patch) | |
tree | 58aa3ca674545cdfec4aa91f8481edbaafac6efd | |
parent | dd04e9f9518e0b84009d21ec5a99bd1f00d796f7 (diff) | |
download | sonarqube-50050c7ea204110ee4ac3bf59e8f42f510622f12.tar.gz sonarqube-50050c7ea204110ee4ac3bf59e8f42f510622f12.zip |
Fix some quality flaws
6 files changed, 11 insertions, 12 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java index c3916e739eb..0ff6fbe57c2 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java @@ -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]) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java index 1e880a6b31d..5997f636ba2 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java +++ b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java @@ -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()) diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java index 32741b9e69d..a148c03d190 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java @@ -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(); diff --git a/sonar-graph/src/main/java/org/sonar/graph/Dsm.java b/sonar-graph/src/main/java/org/sonar/graph/Dsm.java index 69e85c251da..4d8673d1992 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/Dsm.java +++ b/sonar-graph/src/main/java/org/sonar/graph/Dsm.java @@ -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) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java index e340f805124..d542a667eda 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java @@ -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); } /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java index 7bbfe582122..7dd8167daf5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java @@ -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); |