Problem with plugin: sends the wrong command to ignore the files. When we ignore
the directory, we use --exclude path/dir_1 --exclude path/dir_2 --exclude path/dir_3 everything works correctly but when we want to exclude file - PhpCpd.php sends command like --names-exclude path/file_1 --names-exclude path/file_2 --names-exlcude path/file_3 and files will be scanned for copy/past, to ignore all three file we have to use command like --names-exclude file_1,file_2,file_3 without paths.
This commit is contained in:
parent
d8fbbd739b
commit
5fdba72430
|
@ -85,26 +85,27 @@ class PhpCpd extends Plugin implements ZeroConfigPluginInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Runs PHP Copy/Paste Detector in a specified directory.
|
||||
*/
|
||||
* Runs PHP Copy/Paste Detector in a specified directory.
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$ignore = '';
|
||||
if (count($this->ignore)) {
|
||||
$map = function ($item) {
|
||||
// remove the trailing slash
|
||||
$item = rtrim($item, DIRECTORY_SEPARATOR);
|
||||
$namesExclude = ' --names-exclude ';
|
||||
foreach ($this->ignore as $item) {
|
||||
// remove the trailing slash
|
||||
$item = rtrim($item, DIRECTORY_SEPARATOR);
|
||||
|
||||
if (is_file(rtrim($this->path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $item)) {
|
||||
return ' --names-exclude ' . $item;
|
||||
} else {
|
||||
return ' --exclude ' . $item;
|
||||
}
|
||||
if (is_file(rtrim($this->path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $item)) {
|
||||
$ignoredFile = explode('/', $item);
|
||||
$filesToIgnore[] = array_pop($ignoredFile);
|
||||
} else {
|
||||
$ignore .= ' --exclude ' . $item;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
$ignore = array_map($map, $this->ignore);
|
||||
|
||||
$ignore = implode('', $ignore);
|
||||
if (isset($filesToIgnore)) {
|
||||
$filesToIgnore = $namesExclude . implode(',', $filesToIgnore);
|
||||
$ignore = $ignore . $filesToIgnore;
|
||||
}
|
||||
|
||||
$phpcpd = $this->builder->findBinary('phpcpd');
|
||||
|
|
Loading…
Reference in a new issue