public copyPasteDetection ( Iterator | array $files, integer $minLines = 5, integer $minTokens = 70, boolean $fuzzy = false ) : |
||
$files | Iterator | array | List of files to process |
$minLines | integer | Minimum number of identical lines |
$minTokens | integer | Minimum number of identical tokens |
$fuzzy | boolean | |
return | Map of exact clones found in the list of files |
public function copyPasteDetection($files, $minLines = 5, $minTokens = 70, $fuzzy = false)
{
$result = new CodeCloneMap();
foreach ($files as $file) {
$this->strategy->processFile($file, $minLines, $minTokens, $result, $fuzzy);
if ($this->progressBar !== null) {
$this->progressBar->advance();
}
}
return $result;
}
/** * Run the task. * * @param array &$options Additional options. * * @return integer Number of errors. */ public function run(&$options) { $finder = new FinderFacade(array(realpath($this->_config->getPath() . '/lib'))); $files = $finder->findFiles(); $detector = new PHPCPD\Detector\Detector(new PHPCPD\Detector\Strategy\DefaultStrategy()); $clones = $detector->copyPasteDetection($files, 5, 70); $this->_printResult($clones); return count($clones); }