use of net.sourceforge.pmd.cpd.CPD in project pmd-eclipse-plugin by pmd.
the class DetectCutAndPasteCmd method newCPD.
private CPD newCPD() {
CPDConfiguration config = new CPDConfiguration();
config.setMinimumTileSize(minTileSize);
config.setLanguage(language);
config.setEncoding(System.getProperty("file.encoding"));
return new CPD(config);
}
use of net.sourceforge.pmd.cpd.CPD in project pmd-eclipse-plugin by pmd.
the class DetectCutAndPasteCmd method detectCutAndPaste.
/**
* Run the cut and paste detector. At first all files have to be added to
* the cpd. Then the CPD can be executed.
*
* @param files
* List of files to be checked.
* @return the CPD itself for retrieving the matches.
* @throws CoreException
*/
private CPD detectCutAndPaste(final List<File> files) {
LOG.debug("Searching for project files");
final CPD cpd = newCPD();
subTask("Collecting files for CPD");
final Iterator<File> fileIterator = files.iterator();
while (fileIterator.hasNext() && !isCanceled()) {
final File file = fileIterator.next();
try {
cpd.add(file);
worked(1);
} catch (IOException e) {
LOG.warn("IOException when adding file " + file.getName() + " to CPD. Continuing.", e);
}
}
if (!isCanceled()) {
subTask("Performing CPD");
LOG.debug("Performing CPD");
cpd.go();
worked(getStepCount());
}
return cpd;
}
Aggregations