diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-04-01 23:56:50 +0200 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-04-01 23:56:50 +0200 |
commit | 9380e275b3c6267ef3b958e5a0127dd924cab493 (patch) | |
tree | d716d7a0ee7c98bff298261a8573585636537fe1 /sonar-duplications/src | |
parent | 181e104170afc8019cac4fb906bc292320df0da0 (diff) | |
download | sonarqube-9380e275b3c6267ef3b958e5a0127dd924cab493.tar.gz sonarqube-9380e275b3c6267ef3b958e5a0127dd924cab493.zip |
Fix some violations
Diffstat (limited to 'sonar-duplications/src')
-rw-r--r-- | sonar-duplications/src/main/java/org/sonar/duplications/cpd/CPD.java | 31 |
1 files changed, 7 insertions, 24 deletions
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; } |