From 534147ff09e717bbd582ef013ffc21a2241c1cb2 Mon Sep 17 00:00:00 2001 From: Beerend Lauwers Date: Tue, 3 Dec 2019 12:46:59 +0100 Subject: [PATCH 1/2] Pass the "--names" option to PHPCPD. --- src/Tools/Analyzer/Phpcpd.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Tools/Analyzer/Phpcpd.php b/src/Tools/Analyzer/Phpcpd.php index ed4e87ce..ae5e0ae0 100644 --- a/src/Tools/Analyzer/Phpcpd.php +++ b/src/Tools/Analyzer/Phpcpd.php @@ -13,12 +13,20 @@ class Phpcpd extends \Edge\QA\Tools\Tool public function __invoke() { + $phpcpdNames = array_map( + function ($extension) { + return "*.{$extension}"; + }, + explode(',', $this->config->csv('phpqa.extensions')) + ); + $args = array( 'progress' => '', $this->options->ignore->bergmann(), $this->options->getAnalyzedDirs(' '), 'min-lines' => $this->config->value('phpcpd.minLines'), 'min-tokens' => $this->config->value('phpcpd.minTokens'), + 'names' => $phpcpdNames, ); if ($this->options->isSavedToFiles) { $args['log-pmd'] = $this->tool->getEscapedXmlFile(); From a99ecb2f61e56228951297c70cdf422024d658c1 Mon Sep 17 00:00:00 2001 From: Beerend Lauwers Date: Thu, 5 Dec 2019 10:46:13 +0100 Subject: [PATCH 2/2] Fix array to string conversion in the phpcpd tool. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Zdeněk Drahoš --- src/Tools/Analyzer/Phpcpd.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Tools/Analyzer/Phpcpd.php b/src/Tools/Analyzer/Phpcpd.php index ae5e0ae0..f2e2b55c 100644 --- a/src/Tools/Analyzer/Phpcpd.php +++ b/src/Tools/Analyzer/Phpcpd.php @@ -26,7 +26,16 @@ function ($extension) { $this->options->getAnalyzedDirs(' '), 'min-lines' => $this->config->value('phpcpd.minLines'), 'min-tokens' => $this->config->value('phpcpd.minTokens'), - 'names' => $phpcpdNames, + ); + $phpcpdNames = array_map( + function ($extension) { + return "*.{$extension}"; + }, + array_filter(explode(',', $this->config->csv('phpqa.extensions'))) + ); + if ($phpcpdNames) { + $args['names'] = \Edge\QA\escapePath(implode(',', $phpcpdNames)); + } ); if ($this->options->isSavedToFiles) { $args['log-pmd'] = $this->tool->getEscapedXmlFile();