Skip to content

Commit eaf63c1

Browse files
authored
Code quality: added PHPMD, updated workflow (#4303)
* added phpmd to workflow * replaced variabvĺe $_item * replaced variabvĺe $_rss_url * replaced variabvĺe $_storeIds * replaced variabvĺe $_buyRequest * replaced variabvĺe $_typeId * replaced variabvĺe $_serviceCode * replaced variabvĺe $access_key * replaced variabvĺe $method_arr * replaced variabvĺe $font_size * phpcs * phpstan * fix phpunit workflow * phpstan baseline * tmp - disabled ShortVariable phpmd rule * phpmd - ignore long class/variable names * phpmd - ignore BooleanGetMethodName * replaced variabvĺe $increment_id * replaced variabvĺe $_profilerKey * replaced variabvĺe $_option * replaced variabvĺe $drawing_text * replaced variabvĺe $read_adapter * replaced variabvĺe $rules_set * replaced variabvĺe $select_id * replaced variabvĺe $currency_code * replaced variabvĺe $_selection * replaced variabvĺe $_checkedPaths * replaced variabvĺe $_optionId * replaced variabvĺe $url_prefix * replaced variabvĺe $logo_src * replaced variabvĺe $_printValue * replaced variabvĺe $entity_id * replaced variabvĺe $_key * replaced variabvĺe $_value * replaced variabvĺe $item_id * replaced variable $tax_amount * replaced variable $tax_info * replaced variable ... * replaced variable $total_reviews * replaced variable $_truncatedValue * replaced variable ... * replaced variable ... * replaced variable ... * replaced variable ... * update * copyright dates * fix * rector * updated commands * updated commands * removed some phpcs comments * added phpcs default config (for phpstorm) * added github label * phpcs * update baseline
1 parent b3b4617 commit eaf63c1

File tree

269 files changed

+1599
-1593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

269 files changed

+1599
-1593
lines changed

.ddev/commands/web/phpcs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
## Usage: phpcs
55
## Example: ddev phpcs <path-to-files>
66

7-
php vendor/bin/phpcs -s -p --report=full,summary "$@"
7+
php vendor/bin/phpcs -s -p --standard=.phpcs.dist.xml --cache=.phpcs.result.cache --report=full,summary "$@"

.ddev/commands/web/phpmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
## Usage: phpmd
55
## Example: ddev phpmd <path-to-files>
66

7-
php vendor/bin/phpmd "$@" text .phpmd.dist.xml
7+
php vendor/bin/phpmd "$@" text .phpmd.dist.xml --color --cache --baseline-file .phpmd.dist.baseline.xml
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
## Description: run PHPMD
4+
## Usage: phpmd-no-baseline
5+
## Example: ddev phpmd-no-baseline <path-to-files>
6+
7+
php vendor/bin/phpmd "$@" text .phpmd.dist.xml

.ddev/commands/web/phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
## Usage: phpunit
55
## Example: ddev phpunit
66

7-
php vendor/bin/phpunit --no-coverage "$@" --testdox
7+
php vendor/bin/phpunit --configuration .phpunit.dist.xml --no-coverage "$@" --testdox

.ddev/commands/web/phpunit-coverage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
## Example: ddev phpunit-coverage
66

77
enable_xdebug
8-
XDEBUG_MODE=coverage php vendor/bin/phpunit "$@" --testdox
8+
XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration .phpunit.dist.xml --testdox "$@"
99
disable_xdebug

.ddev/commands/web/phpunit-coverage-local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
## Example: ddev phpunit-coverage-local
66

77
enable_xdebug
8-
XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html build/coverage "$@" --testdox
8+
XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration .phpunit.dist.xml --coverage-html build/coverage --testdox "$@"
99
disable_xdebug

.ddev/commands/web/rector

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
## Usage: rector
55
## Example: ddev rector <path-to-files>
66

7-
php vendor/bin/rector process "$@"
7+
php vendor/bin/rector process --config .rector.php "$@"

.gitattributes

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
/.phpcs.ecg.xml.dist export-ignore
1515
/.phpcs.php.xml.dist export-ignore
1616
/.phpcs.xml.dist export-ignore
17+
/.phpmd.dist.baseline.xml export-ignore
1718
/.phpmd.dist.xml export-ignore
1819
/.phpstan.dist.baseline.neon export-ignore
1920
/.phpstan.dist.neon export-ignore
20-
/rector.php export-ignore
21+
/.rector.php export-ignore
2122

2223
/README.md export-ignore
2324

@@ -35,4 +36,4 @@
3536
*.sql text eol=lf
3637
*.svg text eol=lf
3738
*.txt text eol=lf
38-
*.phtml text eol=lf
39+
*.phtml text eol=lf

.github/labeler.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,18 +884,24 @@
884884
.github/workflows/php-cs-fixer.yml
885885
]
886886

887+
'phpmd':
888+
- changed-files:
889+
- any-glob-to-any-file: [
890+
.phpmd*,
891+
.github/workflows/phpmd.yml
892+
]
893+
887894
'phpstan':
888895
- changed-files:
889896
- any-glob-to-any-file: [
890897
.phpstan*,
891-
phpstan*,
892898
.github/workflows/phpstan.yml
893899
]
894900

895901
'phpunit':
896902
- changed-files:
897903
- any-glob-to-any-file: [
898-
phpunit*,
904+
.phpunit*,
899905
tests/*,
900906
.github/workflows/phpunit.yml
901907
]
@@ -910,6 +916,6 @@
910916
'rector':
911917
- changed-files:
912918
- any-glob-to-any-file: [
913-
rector.php,
919+
.rector.php,
914920
.github/workflows/rector.yml
915921
]

.github/workflows/check-files.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ on:
2727
php-cs-fixer:
2828
description: "Count changed PHP-CS-Fixer files"
2929
value: ${{ jobs.check.outputs.php-cs-fixer }}
30+
phpmd:
31+
description: "Count changed PHPMD files"
32+
value: ${{ jobs.check.outputs.phpmd }}
3033
phpstan:
3134
description: "Count changed PHPStan files"
3235
value: ${{ jobs.check.outputs.phpstan }}
@@ -52,6 +55,7 @@ jobs:
5255
workflow: ${{ steps.changes-workflow.outputs.workflow }}
5356
phpcs: ${{ steps.changes-phpcs.outputs.phpcs }}
5457
php-cs-fixer: ${{ steps.changes-php-cs-fixer.outputs.php-cs-fixer }}
58+
phpmd: ${{ steps.changes-phpstan.outputs.phpmd }}
5559
phpstan: ${{ steps.changes-phpstan.outputs.phpstan }}
5660
phpunit-test: ${{ steps.changes-phpunit-test.outputs.phpunit-test }}
5761
phpunit: ${{ steps.changes-phpunit.outputs.phpunit }}
@@ -87,8 +91,9 @@ jobs:
8791
.github/workflows/**
8892
**phpcs**
8993
**php-cs-fixer**
94+
**phpmd**
9095
**phpstan**
91-
rector.php
96+
.rector.php
9297
tests/
9398
phpunit*
9499
@@ -158,6 +163,14 @@ jobs:
158163
echo "$count PHP-CS-Fixer file(s) changed"
159164
echo "php-cs-fixer=$count" >> $GITHUB_OUTPUT
160165
166+
- name: Check if PHPMD files changed
167+
id: changes-phpmd
168+
if: steps.changed-files-specific.outputs.any_modified == 'true'
169+
run: |
170+
count="$(grep -oE "**phpmd**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
171+
echo "$count PHPMD file(s) changed"
172+
echo "phpmd=$count" >> $GITHUB_OUTPUT
173+
161174
- name: Check if PHPStan files changed
162175
id: changes-phpstan
163176
if: steps.changed-files-specific.outputs.any_modified == 'true'
@@ -178,6 +191,6 @@ jobs:
178191
id: changes-phpunit
179192
if: steps.changed-files-specific.outputs.any_modified == 'true'
180193
run: |
181-
count="$(grep -oE "phpunit*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
194+
count="$(grep -oE "**phpunit**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
182195
echo "$count PHPUnit file(s) changed"
183196
echo "phpunit=$count" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)