From 8429043ffb00cc860843430890353a71ab89e1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20L=C3=B3pez?= Date: Fri, 16 Feb 2024 14:25:22 +0100 Subject: [PATCH] Remove phpcpd dependency --- .phpqa.yml | 8 +----- README.md | 25 +++------------- app/report/phpqa.html.twig | 5 ---- composer.json | 1 - src/CodeAnalysisTasks.php | 3 +- src/Tools/Analyzer/Phpcpd.php | 46 ------------------------------ tests/.appveyor/.phpqa.yml | 2 +- tests/.ci/.phpqa.yml | 1 - tests/Config/.phpqa.yml | 3 -- tests/Config/ConfigTest.php | 5 ---- tests/Config/sub-config/.phpqa.yml | 4 --- tests/OptionsTest.php | 2 +- 12 files changed, 8 insertions(+), 97 deletions(-) delete mode 100644 src/Tools/Analyzer/Phpcpd.php diff --git a/.phpqa.yml b/.phpqa.yml index 1e1d9625..1dfbf0ed 100644 --- a/.phpqa.yml +++ b/.phpqa.yml @@ -8,7 +8,7 @@ phpqa: report: false execution: parallel output: file - tools: phpmetrics,phploc,phpcs,php-cs-fixer,phpmd,pdepend,phpcpd,phpstan,phpunit,psalm,security-checker,parallel-lint,deptrac + tools: phpmetrics,phploc,phpcs,php-cs-fixer,phpmd,pdepend,phpstan,phpunit,psalm,security-checker,parallel-lint,deptrac # array definition and allowed errors count is supported too # tools: [phploc, phpcs:0] verbose: false @@ -50,10 +50,6 @@ phpmd: pdepend: # coverageReport: build/coverage-clover.xml -phpcpd: - minLines: 5 - minTokens: 70 - phpmetrics: # v1 config: null @@ -97,7 +93,6 @@ security-checker: # paths are relative to .phpqa.yml, so don't copy-paste this section if you don't have custom templates report: phploc: app/report/phploc.xsl - phpcpd: app/report/phpcpd.xsl phpcs: app/report/phpcs.xsl pdepend: app/report/pdepend.xsl phpmd: app/report/phpmd.xsl @@ -131,7 +126,6 @@ tool: php-cs-fixer: Edge\QA\Tools\Analyzer\PhpCsFixer phpmd: Edge\QA\Tools\Analyzer\Phpmd pdepend: Edge\QA\Tools\Analyzer\Pdepend - phpcpd: Edge\QA\Tools\Analyzer\Phpcpd parallel-lint: Edge\QA\Tools\Analyzer\ParallelLint phpstan: Edge\QA\Tools\Analyzer\Phpstan phpunit: Edge\QA\Tools\Analyzer\Phpunit diff --git a/README.md b/README.md index a00e22c1..efc6dd91 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,6 @@ Will you create e.g. Jenkins project/task for each bundle? Tool| Description ----------------------------------------------------------------------- | ----------------------------- | [phploc](https://github.com/sebastianbergmann/phploc) | Measure the size of a PHP project | -[phpcpd](https://github.com/sebastianbergmann/phpcpd) | Copy/Paste Detector (CPD) for PHP code | [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) | Detect violations of a coding standard | [pdepend](https://github.com/pdepend/pdepend) | PHP adaptation of JDepend | [phpmd](https://github.com/phpmd/phpmd) | Scan PHP project for messy code | @@ -91,20 +90,6 @@ But I wouldn't recommend it. In my experience *one* QA tool which analyzes *N* projects is better than *N* projects with *N* analyzers. It's up to you how many repositories you want to update when new version is released. -##### Symfony3 components - -Symfony3 is supported since [version 1.7](/CHANGELOG.md#v170). -Install at least version `~3.0` of `sebastian/phpcpd`, otherwise you'll get error [`The helper "progress" is not defined.`](https://github.com/EdgedesignCZ/phpqa/issues/19) - -```json -{ - "require-dev": { - "edgedesign/phpqa": ">=1.7", - "sebastian/phpcpd": "~3.0" - } -} -``` - ##### Fake global installation in local project Do you have problems with dependencies and you can't install phpqa globally? @@ -168,7 +153,7 @@ docker run --rm -u $UID -v $PWD:/app eko3alpha/docker-phpqa --report --ignoredDi | `phpqa --ignoredDirs build,vendor` | Ignore directories | | `phpqa --ignoredFiles RoboFile.php` | Ignore files | | `phpqa --tools phploc,phpcs` | Run only selected tools | -| `phpqa --tools phpmd:1,phpcs:0,phpcpd:0` | Check number of errors and [exit code](#exit-code). **New in v1.6** | +| `phpqa --tools phpmd:1,phpcs:0` | Check number of errors and [exit code](#exit-code). **New in v1.6** | | `phpqa --verbose` | Show output from executed tools | | `phpqa --quiet` | Show no output at all | | `phpqa --output cli` | [CLI output](#output-modes) instead of creating files in `--buildDir` | @@ -185,7 +170,6 @@ _Tip:_ CLI options can be defined in [.phpqa.yml](#advanced-configuration---phpq Tool | `--output file` (default) - generated files | `--output cli` | ---- | ------------------------- | -------------- | phploc | [phploc.xml](https://edgedesigncz.github.io/phpqa/report/phploc.xml) | [✓](https://github.com/sebastianbergmann/phploc#analyse-a-directory-and-print-the-result) | -phpcpd | [phpcpd.xml](https://edgedesigncz.github.io/phpqa/report/phpcpd.xml) | [✓](https://github.com/sebastianbergmann/phpcpd#usage-example) | phpcs | [checkstyle.xml](https://edgedesigncz.github.io/phpqa/report/checkstyle.xml) | [full report](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Reporting#printing-full-and-summary-reports) | pdepend | [pdepend-jdepend.xml](https://edgedesigncz.github.io/phpqa/report/pdepend-jdepend.xml), [pdepend-summary.xml](https://edgedesigncz.github.io/phpqa/report/pdepend-summary.xml), [pdepend-dependencies.xml](https://edgedesigncz.github.io/phpqa/report/pdepend-dependencies.xml), [pdepend-jdepend.svg](https://edgedesigncz.github.io/phpqa/report/pdepend-jdepend.svg), [pdepend-pyramid.svg](https://edgedesigncz.github.io/phpqa/report/pdepend-pyramid.svg) | ✗ | phpmd | [phpmd.xml](https://edgedesigncz.github.io/phpqa/report/phpmd.xml) | [✓](https://github.com/phpmd/phpmd/blob/master/src/main/php/PHPMD/Renderer/TextRenderer.php#L47) | @@ -199,7 +183,7 @@ deptrac | [deptrac.html](https://edgedesigncz.github.io/phpqa/report/deptrac.htm ## Exit code `phpqa` can return non-zero exit code **since version 1.6**. It's optional feature that is by default turned off. -You have to define number of allowed errors for *phpcpd, phpcs, phpmd* in `--tools`. +You have to define number of allowed errors for *phpcs, phpmd* in `--tools`. [mode](#output-modes) | Supported version | What is analyzed? | --------------------- | ----------------- | ----------------- | @@ -211,7 +195,7 @@ or [Circle CI](https://circleci.com/docs/manually/#overview) build should fail w Define number of allowed errors for each tools and watch the build: ```bash -phpqa --report --tools phpcs:0,phpmd:0,phpcpd:0,parallel-lint:0,phpstan:0,phpmetrics,phploc,pdepend +phpqa --report --tools phpcs:0,phpmd:0,parallel-lint:0,phpstan:0,phpmetrics,phploc,pdepend ``` Number of allowed errors can be also defined in [.phpqa.yml](#advanced-configuration---phpqayml). @@ -331,7 +315,6 @@ Tool | Settings | Default Value | Your value [pdepend.coverageReport](https://github.com/EdgedesignCZ/phpqa/pull/124) | Load Clover style CodeCoverage report | `null` | Path to report produced by PHPUnit's `--coverage-clover` option [phpmd.standard](http://phpmd.org/documentation/creating-a-ruleset.html) | Ruleset | [Edgedesign's standard](/app/phpmd.xml) | Path to ruleset. To specify [multiple rule sets](https://phpmd.org/documentation/index.html#using-multiple-rule-sets), you can use an array [phpmd.ignoreParsingErrors](https://github.com/EdgedesignCZ/phpqa/issues/230) | If parsing errors affect exit code, or just violations | `true` | Boolean value -[phpcpd](https://github.com/sebastianbergmann/phpcpd/blob/de9056615da6c1230f3294384055fa7d722c38fa/src/CLI/Command.php#L136) | Minimum number of lines/tokens for copy-paste detection | 5 lines, 70 tokens | [phpstan](https://github.com/phpstan/phpstan#configuration) | Level, config file, memory limit | Level 0, `%currentWorkingDirectory%/phpstan.neon`, memoryLimit: null | Take a look at [phpqa config in tests/.ci](/tests/.ci/) | [phpunit.binary](https://github.com/EdgedesignCZ/phpqa/blob/4947416/.phpqa.yml#L40) | Phpunit binary | phpqa's phpunit | Path to phpunit executable in your project, typically [`vendor/bin/phpunit`](https://gitlab.com/costlocker/integrations/blob/master/basecamp/backend/.phpqa.yml#L2) | [phpunit.config](https://phpunit.de/manual/current/en/organizing-tests.html#organizing-tests.xml-configuration) | PHPUnit configuration, `analyzedDirs` and `ignoredDirs` are not used, you have to specify test suites in XML file | `null` | Path to `phpunit.xml` file @@ -477,7 +460,7 @@ dependencies: test: override: - vendor/bin/phpunit --testdox-html ./var/tests/testdox.html --testdox-text ./var/tests/testdox.txt --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit.xml - - qa/phpqa --report --verbose --buildDir var/QA --ignoredDirs vendor --tools=phpcs:0,phpmd:0,phpcpd:0,phploc,pdepend,phpmetrics + - qa/phpqa --report --verbose --buildDir var/QA --ignoredDirs vendor --tools=phpcs:0,phpmd:0,phploc,pdepend,phpmetrics post: - cp -r ./var/QA $CIRCLE_ARTIFACTS - cp -r ./var/tests $CIRCLE_ARTIFACTS diff --git a/app/report/phpqa.html.twig b/app/report/phpqa.html.twig index a4322be0..26d9ea7c 100644 --- a/app/report/phpqa.html.twig +++ b/app/report/phpqa.html.twig @@ -41,10 +41,6 @@ set tabs = { 'errors': 'Errors', 'parsing': 'Parsing Errors', }, - 'phpcpd': { - 'overview': 'Overview', - 'errors': 'Errors', - }, 'phploc': { 'overview': 'Overview', 'ccn': 'Cyclomatic Complexity', @@ -271,7 +267,6 @@ set tabs = { '#pdepend': openBootstrap, '#phpcs': openBootstrap, '#phpmd': openBootstrap, - '#phpcpd': openBootstrap, '#phploc': openBootstrap, '#phpmetrics': function(window, tab, iframe) { {% if phpmetricsVersion == 1 %} diff --git a/composer.json b/composer.json index fad1be0f..2cf428e8 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,6 @@ "symfony/yaml": ">=2.8", "twig/twig": "~1.38|~2.7|~3", "pdepend/pdepend": "*", - "sebastian/phpcpd": "*", "squizlabs/php_codesniffer": "*", "phpmetrics/phpmetrics": "*" }, diff --git a/src/CodeAnalysisTasks.php b/src/CodeAnalysisTasks.php index f3cc4e96..0d0a792c 100644 --- a/src/CodeAnalysisTasks.php +++ b/src/CodeAnalysisTasks.php @@ -32,7 +32,7 @@ public function tools( * @option $buildDir path to output directory @default build/ * @option $ignoredDirs csv @default vendor @example CI,bin,vendor * @option $ignoredFiles csv @example RoboFile.php - * @option $tools csv with optional definition of allowed errors count @default phpmetrics,phploc,phpcs,php-cs-fixer,phpmd,pdepend,phpcpd,phpstan,phpunit,psalm,security-checker,parallel-lint @example phploc,phpmd:1,phpcs:0 + * @option $tools csv with optional definition of allowed errors count @default phpmetrics,phploc,phpcs,php-cs-fixer,phpmd,pdepend,phpstan,phpunit,psalm,security-checker,parallel-lint @example phploc,phpmd:1,phpcs:0 * @option $output output format @default file @example cli * @option $execution output format @default parallel @example no-parallel * @option $config path directory with .phpqa.yml, @default current working directory @@ -95,7 +95,6 @@ private function loadConfig(array $cliOptions) 'php-cs-fixer', 'phpmd', 'pdepend', - 'phpcpd', 'phpstan', 'phpunit', 'psalm', diff --git a/src/Tools/Analyzer/Phpcpd.php b/src/Tools/Analyzer/Phpcpd.php deleted file mode 100644 index 9c136b25..00000000 --- a/src/Tools/Analyzer/Phpcpd.php +++ /dev/null @@ -1,46 +0,0 @@ - ' ', - 'xml' => ['phpcpd.xml'], - 'errorsXPath' => '//pmd-cpd/duplication', - 'composer' => 'sebastian/phpcpd', - ); - - public function __invoke() - { - $args = array( - $this->options->ignore->bergmann(), - $this->options->getAnalyzedDirs(' '), - 'min-lines' => $this->config->value('phpcpd.minLines'), - 'min-tokens' => $this->config->value('phpcpd.minTokens'), - ); - $isOlderVersion = $this->toolVersionIs('<', '6'); - $phpcpdNames = array_map( - function ($extension) use ($isOlderVersion) { - return $isOlderVersion ? "*.{$extension}" : ".{$extension}"; - }, - array_filter(explode(',', $this->config->csv('phpqa.extensions'))) - ); - if ($isOlderVersion) { - $args['progress'] = ''; - } - if ($phpcpdNames) { - if ($isOlderVersion) { - $args['names'] = \Edge\QA\escapePath(implode(',', $phpcpdNames)); - } else { - foreach ($phpcpdNames as $name) { - $args[] = sprintf('--suffix %s', \Edge\QA\escapePath($name)); - } - } - } - if ($this->options->isSavedToFiles) { - $args['log-pmd'] = $this->tool->getEscapedXmlFile(); - } - return $args; - } -} diff --git a/tests/.appveyor/.phpqa.yml b/tests/.appveyor/.phpqa.yml index 410f893c..f3c75966 100644 --- a/tests/.appveyor/.phpqa.yml +++ b/tests/.appveyor/.phpqa.yml @@ -1,5 +1,5 @@ phpqa: - tools: phpmetrics,phploc,phpcs:0,php-cs-fixer,phpmd:0,pdepend,phpcpd:0,phpstan,phpunit:0,psalm,security-checker,parallel-lint + tools: phpmetrics,phploc,phpcs:0,php-cs-fixer,phpmd:0,pdepend,phpstan,phpunit:0,psalm,security-checker,parallel-lint ignoredFiles: tests/.phpunit/fix-psalm-testcase.php phpmd: diff --git a/tests/.ci/.phpqa.yml b/tests/.ci/.phpqa.yml index ce34c827..2fc0d2fd 100644 --- a/tests/.ci/.phpqa.yml +++ b/tests/.ci/.phpqa.yml @@ -18,7 +18,6 @@ phpqa: - php-cs-fixer - phpmd:0 - pdepend - - phpcpd - phpstan - phpunit:0 - psalm diff --git a/tests/Config/.phpqa.yml b/tests/Config/.phpqa.yml index 4ac8c83a..9cbda493 100644 --- a/tests/Config/.phpqa.yml +++ b/tests/Config/.phpqa.yml @@ -10,9 +10,6 @@ phpcs: phpmd: standard: my-standard.xml -# should ignore empty values -phpcpd: - # invalid binary phpunit: binary: non-existent-binary diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php index c6264358..85450129 100644 --- a/tests/Config/ConfigTest.php +++ b/tests/Config/ConfigTest.php @@ -10,8 +10,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testLoadDefaultConfig() { $config = new Config(); - assertThat($config->value('phpcpd.minLines'), is(greaterThan(0))); - assertThat($config->value('phpcpd.minTokens'), is(greaterThan(0))); assertThat($config->value('phpcs.standard'), is(nonEmptyString())); assertThat($config->value('phpcs.ignoreWarnings'), identicalTo(false)); assertThat($config->value('phpcs.reports.cli'), is(nonEmptyArray())); @@ -51,8 +49,6 @@ public function testOverrideDefaultConfig() { $config = new Config(); $config->loadUserConfig(__DIR__); - assertThat($config->value('phpcpd.minLines'), is(5)); - assertThat($config->value('phpcpd.minTokens'), is(70)); assertThat($config->value('phpcs.standard'), is('Zend')); assertThat($config->path('phpmd.standard'), is(__DIR__ . DIRECTORY_SEPARATOR . 'my-standard.xml')); } @@ -125,7 +121,6 @@ public function testMultipleConfig() assertThat($config->value('phpcs.standard'), is('PSR2')); assertThat($config->value('phpmd.standard'), is('my-standard.xml')); - assertThat($config->value('phpcpd.lines'), is(53)); assertThat($config->csv('phpqa.extensions'), is('php,inc')); } diff --git a/tests/Config/sub-config/.phpqa.yml b/tests/Config/sub-config/.phpqa.yml index be029eb2..4821c771 100644 --- a/tests/Config/sub-config/.phpqa.yml +++ b/tests/Config/sub-config/.phpqa.yml @@ -2,10 +2,6 @@ phpcs: standard: PSR2 -# should override default standard -phpcpd: - lines: 53 - # Php file extensions to parse. extensions: - php diff --git a/tests/OptionsTest.php b/tests/OptionsTest.php index a8a8ea9d..c92707e5 100644 --- a/tests/OptionsTest.php +++ b/tests/OptionsTest.php @@ -11,7 +11,7 @@ class OptionsTest extends \PHPUnit_Framework_TestCase 'buildDir' => 'build/', 'ignoredDirs' => 'vendor', 'ignoredFiles' => '', - 'tools' => 'phploc,phpcpd,phpcs,pdepend,phpmd,phpmetrics', + 'tools' => 'phploc,phpcs,pdepend,phpmd,phpmetrics', 'output' => 'file', 'config' => '', 'verbose' => true,