Skip to content
Snippets Groups Projects
Commit 09f3c9d2 authored by Olga Kopylova's avatar Olga Kopylova
Browse files

MAGETWO-58693: Refactor Module_Integration, Module_MarketPlace

- improved Copy-Paste static test to allow file names in the blacklist
parent 8272e97e
Branches
No related merge requests found
......@@ -56,8 +56,7 @@ class CopyPasteDetector implements ToolInterface, BlacklistInterface
*/
public function canRun()
{
$vendorDir = require BP . '/app/etc/vendor_path.php';
exec('php ' . BP . '/' . $vendorDir . '/bin/phpcpd --version', $output, $exitCode);
exec($this->getCommand() . ' --version', $output, $exitCode);
return $exitCode === 0;
}
......@@ -71,22 +70,37 @@ class CopyPasteDetector implements ToolInterface, BlacklistInterface
*/
public function run(array $whiteList)
{
$blackListStr = ' ';
$blacklistedDirs = [];
$blacklistedFileNames = [];
foreach ($this->blacklist as $file) {
$file = escapeshellarg(trim($file));
if (!$file) {
continue;
}
$blackListStr .= '--exclude ' . $file . ' ';
$ext = pathinfo($file, PATHINFO_EXTENSION);
if ($ext != '') {
$blacklistedFileNames[] = $file;
} else {
$blacklistedDirs[] = '--exclude ' . $file . ' ';
}
}
$vendorDir = require BP . '/app/etc/vendor_path.php';
$command = 'php ' . BP . '/' . $vendorDir . '/bin/phpcpd' . ' --log-pmd ' . escapeshellarg(
$this->reportFile
) . ' --names-exclude "*Test.php" --min-lines 13' . $blackListStr . ' ' . implode(' ', $whiteList);
$command = $this->getCommand() . ' --log-pmd ' . escapeshellarg($this->reportFile)
. ' --names-exclude ' . join(',', $blacklistedFileNames) . ' --min-lines 13 ' . join(' ', $blacklistedDirs)
. ' ' . implode(' ', $whiteList);
exec($command, $output, $exitCode);
return !(bool)$exitCode;
}
/**
* Get PHPCPD command
*
* @return string
*/
private function getCommand()
{
$vendorDir = require BP . '/app/etc/vendor_path.php';
return 'php ' . BP . '/' . $vendorDir . '/bin/phpcpd';
}
}
......@@ -197,5 +197,5 @@ Magento/Framework/View/File/Collector/Override
Magento/Framework/MessageQueue/Consumer/Config/ConsumerConfigItem
Magento/Framework/MessageQueue/Publisher/Config/PublisherConfigItem
Magento/Framework/MessageQueue/Topology/Config/ExchangeConfigItem
Magento/Integration/Model/Config
Magento/Integration/Model/IntegrationConfig
IntegrationConfig.php
*Test.php
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment