Fix some violations

This commit is contained in:
simonbrandhof 2011-04-01 23:56:50 +02:00
parent 181e104170
commit 9380e275b3
8 changed files with 34 additions and 48 deletions

View File

@ -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);

View File

@ -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], ";");

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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++) {

View File

@ -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);

View File

@ -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.

View File

@ -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);