Skip to content

Commit 09f3c9d

Browse files
committed
MAGETWO-58693: Refactor Module_Integration, Module_MarketPlace
- improved Copy-Paste static test to allow file names in the blacklist
1 parent 8272e97 commit 09f3c9d

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CopyPasteDetector.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public function setBlackList(array $blackList)
5656
*/
5757
public function canRun()
5858
{
59-
$vendorDir = require BP . '/app/etc/vendor_path.php';
60-
exec('php ' . BP . '/' . $vendorDir . '/bin/phpcpd --version', $output, $exitCode);
59+
exec($this->getCommand() . ' --version', $output, $exitCode);
6160
return $exitCode === 0;
6261
}
6362

@@ -71,22 +70,37 @@ public function canRun()
7170
*/
7271
public function run(array $whiteList)
7372
{
74-
$blackListStr = ' ';
73+
$blacklistedDirs = [];
74+
$blacklistedFileNames = [];
7575
foreach ($this->blacklist as $file) {
7676
$file = escapeshellarg(trim($file));
7777
if (!$file) {
7878
continue;
7979
}
80-
$blackListStr .= '--exclude ' . $file . ' ';
80+
$ext = pathinfo($file, PATHINFO_EXTENSION);
81+
if ($ext != '') {
82+
$blacklistedFileNames[] = $file;
83+
} else {
84+
$blacklistedDirs[] = '--exclude ' . $file . ' ';
85+
}
8186
}
8287

83-
$vendorDir = require BP . '/app/etc/vendor_path.php';
84-
$command = 'php ' . BP . '/' . $vendorDir . '/bin/phpcpd' . ' --log-pmd ' . escapeshellarg(
85-
$this->reportFile
86-
) . ' --names-exclude "*Test.php" --min-lines 13' . $blackListStr . ' ' . implode(' ', $whiteList);
87-
88+
$command = $this->getCommand() . ' --log-pmd ' . escapeshellarg($this->reportFile)
89+
. ' --names-exclude ' . join(',', $blacklistedFileNames) . ' --min-lines 13 ' . join(' ', $blacklistedDirs)
90+
. ' ' . implode(' ', $whiteList);
8891
exec($command, $output, $exitCode);
8992

9093
return !(bool)$exitCode;
9194
}
95+
96+
/**
97+
* Get PHPCPD command
98+
*
99+
* @return string
100+
*/
101+
private function getCommand()
102+
{
103+
$vendorDir = require BP . '/app/etc/vendor_path.php';
104+
return 'php ' . BP . '/' . $vendorDir . '/bin/phpcpd';
105+
}
92106
}

dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,5 @@ Magento/Framework/View/File/Collector/Override
197197
Magento/Framework/MessageQueue/Consumer/Config/ConsumerConfigItem
198198
Magento/Framework/MessageQueue/Publisher/Config/PublisherConfigItem
199199
Magento/Framework/MessageQueue/Topology/Config/ExchangeConfigItem
200-
Magento/Integration/Model/Config
201-
Magento/Integration/Model/IntegrationConfig
200+
IntegrationConfig.php
201+
*Test.php

0 commit comments

Comments
 (0)