aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java4
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionBarChart.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java2
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/cpd/CPD.java31
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java23
-rw-r--r--sonar-server/src/main/java/org/sonar/server/charts/deprecated/SparkLinesChart.java12
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/BatchResourcesServlet.java2
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java6
8 files changed, 34 insertions, 48 deletions
diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java
index 129d1ac4b91..98ba2bb0cf6 100644
--- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java
+++ b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java
@@ -32,8 +32,8 @@ import java.io.File;
*/
public final class CoberturaUtils {
- public static String COBERTURA_GROUP_ID = MavenUtils.GROUP_ID_CODEHAUS_MOJO;
- public static String COBERTURA_ARTIFACT_ID = "cobertura-maven-plugin";
+ public static final String COBERTURA_GROUP_ID = MavenUtils.GROUP_ID_CODEHAUS_MOJO;
+ public static final String COBERTURA_ARTIFACT_ID = "cobertura-maven-plugin";
public static File getReport(Project project) {
File report = getReportFromProperty(project);
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionBarChart.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionBarChart.java
index 58d2f3cbf85..4cac585fe9f 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionBarChart.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/charts/DistributionBarChart.java
@@ -69,7 +69,7 @@ public class DistributionBarChart extends AbstractChart {
return plot;
}
- private void configureValues(DefaultCategoryDataset dataset, String[] series, String xSuffix) {
+ static void configureValues(DefaultCategoryDataset dataset, String[] series, String xSuffix) {
int index = 0;
while (index < series.length) {
String[] pairs = StringUtils.split(series[index], ";");
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
index ec2a38426d3..4962be2b8e6 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
@@ -64,7 +64,7 @@ public class PastSnapshotFinder implements BatchExtension {
case 2: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2; break;
case 3: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_3; break;
case 4: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4; break;
- case 5: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5; break;
+ case 5: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5; break;// NOSONAR false-positive: constant 5 is the same than 4 (empty string)
}
return conf.getString(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + index, defaultValue);
}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/cpd/CPD.java b/sonar-duplications/src/main/java/org/sonar/duplications/cpd/CPD.java
index 8d193f30b64..31c3f37061a 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/cpd/CPD.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/cpd/CPD.java
@@ -29,7 +29,10 @@ import net.sourceforge.pmd.util.FileFinder;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
public class CPD {
@@ -39,8 +42,6 @@ public class CPD {
private int minimumTileSize;
private MatchAlgorithm matchAlgorithm;
private Language language;
- private boolean skipDuplicates;
- public static boolean debugEnable = false;
private boolean loadSourceCodeSlices = true;
private String encoding = System.getProperty("file.encoding");
@@ -50,10 +51,6 @@ public class CPD {
this.language = language;
}
- public void skipDuplicates() {
- this.skipDuplicates = true;
- }
-
public void setCpdListener(CPDListener cpdListener) {
this.listener = cpdListener;
}
@@ -96,7 +93,7 @@ public class CPD {
}
private void addDirectory(String dir, boolean recurse) throws IOException {
- if ( !(new File(dir)).exists()) {
+ if (!(new File(dir)).exists()) {
throw new FileNotFoundException("Couldn't find directory " + dir);
}
FileFinder finder = new FileFinder();
@@ -104,23 +101,9 @@ public class CPD {
add(finder.findFilesFrom(dir, language.getFileFilter(), recurse));
}
- private Set<String> current = new HashSet<String>();
-
private void add(int fileCount, File file) throws IOException {
-
- if (skipDuplicates) {
- // TODO refactor this thing into a separate class
- String signature = file.getName() + '_' + file.length();
- if (current.contains(signature)) {
- System.err.println("Skipping " + file.getAbsolutePath()
- + " since it appears to be a duplicate file and --skip-duplicate-files is set");
- return;
- }
- current.add(signature);
- }
-
- if ( !file.getCanonicalPath().equals(new File(file.getAbsolutePath()).getCanonicalPath())) {
- System.err.println("Skipping " + file + " since it appears to be a symlink");
+ if (!file.getCanonicalPath().equals(new File(file.getAbsolutePath()).getCanonicalPath())) {
+ System.out.println("Skipping " + file + " since it appears to be a symlink");
return;
}
diff --git a/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java b/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java
index c69a2708e62..7d24b3adee7 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java
@@ -19,6 +19,8 @@
*/
package org.sonar.graph;
+import org.apache.commons.lang.ArrayUtils;
+
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.Reader;
@@ -56,17 +58,15 @@ public final class DsmScanner {
private void readRow(int i) throws IOException {
String[] tokens = splitLine(reader.readLine());
- if (tokens != null) {
- for (int j = 1; j < tokens.length - 1; j++) {
- int toVertexIndex = j - 1;
- int weight = extractWeight(tokens[j]);
- if (i != toVertexIndex) {
- StringEdge edge = new StringEdge(vertices[toVertexIndex], vertices[i], weight);
- if (isFeedbackEdge(tokens[j])) {
- feedbackEdges.add(edge);
- }
- graph.addEdge(edge);
+ for (int j = 1; j < tokens.length - 1; j++) {
+ int toVertexIndex = j - 1;
+ int weight = extractWeight(tokens[j]);
+ if (i != toVertexIndex) {
+ StringEdge edge = new StringEdge(vertices[toVertexIndex], vertices[i], weight);
+ if (isFeedbackEdge(tokens[j])) {
+ feedbackEdges.add(edge);
}
+ graph.addEdge(edge);
}
}
}
@@ -93,6 +93,9 @@ public final class DsmScanner {
}
private String[] splitLine(String line) {
+ if (line == null) {
+ return ArrayUtils.EMPTY_STRING_ARRAY;
+ }
String[] tokens = line.split("\\" + CELL_SEPARATOR);
String[] result = new String[tokens.length];
for (int i = 0; i < tokens.length; i++) {
diff --git a/sonar-server/src/main/java/org/sonar/server/charts/deprecated/SparkLinesChart.java b/sonar-server/src/main/java/org/sonar/server/charts/deprecated/SparkLinesChart.java
index d46790c0244..bfe1e5b7b43 100644
--- a/sonar-server/src/main/java/org/sonar/server/charts/deprecated/SparkLinesChart.java
+++ b/sonar-server/src/main/java/org/sonar/server/charts/deprecated/SparkLinesChart.java
@@ -124,15 +124,15 @@ public class SparkLinesChart extends BaseChartWeb implements DeprecatedChart {
if (values != null && values.length() > 0) {
StringTokenizer st = new StringTokenizer(values, ",");
while (st.hasMoreTokens()) {
- double v_x = convertParamToDouble(st.nextToken());
- double v_y = 0.0;
+ double vX = convertParamToDouble(st.nextToken());
+ double vY = 0.0;
if (st.hasMoreTokens()) {
- v_y = convertParamToDouble(st.nextToken());
+ vY = convertParamToDouble(st.nextToken());
}
- series1.add(v_x, v_y);
+ series1.add(vX, vY);
- min = (v_y < min ? v_y : min);
- max = (v_y > max ? v_y : max);
+ min = (vY < min ? vY : min);
+ max = (vY > max ? vY : max);
}
dataset.addSeries(series1);
y.setRange(min-1, max+1);
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/BatchResourcesServlet.java b/sonar-server/src/main/java/org/sonar/server/plugins/BatchResourcesServlet.java
index bf83fa6961b..856d14c98c7 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/BatchResourcesServlet.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/BatchResourcesServlet.java
@@ -96,7 +96,7 @@ public class BatchResourcesServlet extends HttpServlet {
return libs;
}
- private static String[] IGNORE = { "derby", "jtds", "mysql", "postgresql", "jruby", "jfreechart", "eastwood", "jetty" };
+ private static final String[] IGNORE = { "derby", "jtds", "mysql", "postgresql", "jruby", "jfreechart", "eastwood", "jetty" };
/**
* Dirty hack to disable downloading for certain files.
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java
index 6afab73fb9d..05aba34a4d1 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java
@@ -29,14 +29,14 @@ import java.util.Set;
*/
public abstract class WSUtils {
- private static WSUtils INSTANCE = null;
+ private static WSUtils instance = null;
public static void setInstance(WSUtils utils) {
- INSTANCE = utils;
+ instance = utils;
}
public static WSUtils getINSTANCE() {
- return INSTANCE;
+ return instance;
}
public abstract String format(Date date, String format);