Skip to content

Commit

Permalink
Remove phpcpd dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjol committed Feb 16, 2024
1 parent a3038f1 commit 8429043
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 97 deletions.
8 changes: 1 addition & 7 deletions .phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,10 +50,6 @@ phpmd:
pdepend:
# coverageReport: build/coverage-clover.xml

phpcpd:
minLines: 5
minTokens: 70

phpmetrics:
# v1
config: null
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
25 changes: 4 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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` |
Expand All @@ -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) |
Expand All @@ -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? |
--------------------- | ----------------- | ----------------- |
Expand All @@ -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).
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions app/report/phpqa.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ set tabs = {
'errors': 'Errors',
'parsing': 'Parsing Errors',
},
'phpcpd': {
'overview': 'Overview',
'errors': 'Errors',
},
'phploc': {
'overview': 'Overview',
'ccn': 'Cyclomatic Complexity',
Expand Down Expand Up @@ -271,7 +267,6 @@ set tabs = {
'#pdepend': openBootstrap,
'#phpcs': openBootstrap,
'#phpmd': openBootstrap,
'#phpcpd': openBootstrap,
'#phploc': openBootstrap,
'#phpmetrics': function(window, tab, iframe) {
{% if phpmetricsVersion == 1 %}
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"symfony/yaml": ">=2.8",
"twig/twig": "~1.38|~2.7|~3",
"pdepend/pdepend": "*",
"sebastian/phpcpd": "*",
"squizlabs/php_codesniffer": "*",
"phpmetrics/phpmetrics": "*"
},
Expand Down
3 changes: 1 addition & 2 deletions src/CodeAnalysisTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function tools(
* @option $buildDir path to output directory <comment>@default</comment> <info>build/</info>
* @option $ignoredDirs csv <comment>@default</comment> <info>vendor</info> <comment>@example</comment> CI,bin,vendor
* @option $ignoredFiles csv <comment>@example</comment> RoboFile.php
* @option $tools csv with optional definition of allowed errors count <comment>@default</comment> <info>phpmetrics,phploc,phpcs,php-cs-fixer,phpmd,pdepend,phpcpd,phpstan,phpunit,psalm,security-checker,parallel-lint</info> <comment>@example</comment> phploc,phpmd:1,phpcs:0
* @option $tools csv with optional definition of allowed errors count <comment>@default</comment> <info>phpmetrics,phploc,phpcs,php-cs-fixer,phpmd,pdepend,phpstan,phpunit,psalm,security-checker,parallel-lint</info> <comment>@example</comment> phploc,phpmd:1,phpcs:0
* @option $output output format <comment>@default</comment> <info>file</info> <comment>@example</comment> cli
* @option $execution output format <comment>@default</comment> <info>parallel</info> <comment>@example</comment> no-parallel
* @option $config path directory with .phpqa.yml, <comment>@default</comment> <info>current working directory</info>
Expand Down Expand Up @@ -95,7 +95,6 @@ private function loadConfig(array $cliOptions)
'php-cs-fixer',
'phpmd',
'pdepend',
'phpcpd',
'phpstan',
'phpunit',
'psalm',
Expand Down
46 changes: 0 additions & 46 deletions src/Tools/Analyzer/Phpcpd.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/.appveyor/.phpqa.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 0 additions & 1 deletion tests/.ci/.phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ phpqa:
- php-cs-fixer
- phpmd:0
- pdepend
- phpcpd
- phpstan
- phpunit:0
- psalm
Expand Down
3 changes: 0 additions & 3 deletions tests/Config/.phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ phpcs:
phpmd:
standard: my-standard.xml

# should ignore empty values
phpcpd:

# invalid binary
phpunit:
binary: non-existent-binary
Expand Down
5 changes: 0 additions & 5 deletions tests/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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'));
}
Expand Down Expand Up @@ -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'));
}

Expand Down
4 changes: 0 additions & 4 deletions tests/Config/sub-config/.phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
phpcs:
standard: PSR2

# should override default standard
phpcpd:
lines: 53

# Php file extensions to parse.
extensions:
- php
Expand Down
2 changes: 1 addition & 1 deletion tests/OptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8429043

Please sign in to comment.