diff --git a/cli/Application/Command/Test/Copypaste.php b/cli/Application/Command/Test/Copypaste.php new file mode 100644 index 000000000..d2c188fea --- /dev/null +++ b/cli/Application/Command/Test/Copypaste.php @@ -0,0 +1,68 @@ +getApplication()->outputTitle('Run Copy/Paste Detector'); + + $application = new \SebastianBergmann\PHPCPD\CLI\Application; + + $application->setAutoExit(false); + + $cloneCount = $application->run( + new ArrayInput( + ['values' => [ + JPATH_ROOT . '/cli', + JPATH_ROOT . '/src' + ]] + ) + ); + + $this->out( + $cloneCount + ? sprintf(' %d clones found. ', $cloneCount) + : 'No CP errors' + ); + + if ($this->exit) + { + exit($cloneCount ? 1 : 0); + } + + return $cloneCount; + } +} diff --git a/cli/Application/Command/Test/Run.php b/cli/Application/Command/Test/Run.php index d2ecc43d5..a49de20d3 100644 --- a/cli/Application/Command/Test/Run.php +++ b/cli/Application/Command/Test/Run.php @@ -49,6 +49,15 @@ public function execute() ->setExit(false) ->execute(); + /* + * @todo enable when https://github.com/sebastianbergmann/phpcpd/pull/93 is merged + $statusCPD = (new Copypaste) + ->setContainer($this->getContainer()) + ->setExit(false) + ->execute(); + + */ + $status = ($statusCS || $statusUT) ? 1 : 0; $this diff --git a/composer.json b/composer.json index 67c048beb..c0631a8f0 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ "filp/whoops": "1.0.*@stable", "mustache/mustache": "2.1.*@stable", "phpunit/phpunit" : "3.7.*@stable", - "squizlabs/php_codesniffer": "1.*@stable" + "squizlabs/php_codesniffer": "1.*@stable", + "sebastian/phpcpd": "*" }, "autoload": { "psr-4": {