Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code quality: added PHPMD, updated workflow #4303

Draft
wants to merge 58 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
5ac5440
added phpmd to workflow
sreichel Oct 20, 2024
fc0d658
replaced variabvĺe $_item
sreichel Oct 20, 2024
000728a
replaced variabvĺe $_rss_url
sreichel Oct 20, 2024
a771a71
replaced variabvĺe $_storeIds
sreichel Oct 20, 2024
e83e1c1
replaced variabvĺe $_buyRequest
sreichel Oct 20, 2024
cd824bd
replaced variabvĺe $_typeId
sreichel Oct 20, 2024
e143853
replaced variabvĺe $_serviceCode
sreichel Oct 20, 2024
770cd93
replaced variabvĺe $access_key
sreichel Oct 20, 2024
03f7ac0
replaced variabvĺe $method_arr
sreichel Oct 20, 2024
450fe16
replaced variabvĺe $font_size
sreichel Oct 20, 2024
2362d4b
phpcs
sreichel Oct 20, 2024
580df70
phpstan
sreichel Oct 20, 2024
339f5ac
fix phpunit workflow
sreichel Oct 20, 2024
dc1ac16
phpstan baseline
sreichel Oct 20, 2024
10cef65
tmp - disabled ShortVariable phpmd rule
sreichel Oct 20, 2024
56d33c7
phpmd - ignore long class/variable names
sreichel Oct 20, 2024
8954a68
phpmd - ignore BooleanGetMethodName
sreichel Oct 20, 2024
1fc9753
replaced variabvĺe $increment_id
sreichel Oct 20, 2024
0b6d938
replaced variabvĺe $_profilerKey
sreichel Oct 20, 2024
b29e132
replaced variabvĺe $_option
sreichel Oct 20, 2024
b9a9a66
replaced variabvĺe $drawing_text
sreichel Oct 20, 2024
1d2a7bf
replaced variabvĺe $read_adapter
sreichel Oct 20, 2024
2e121ad
replaced variabvĺe $rules_set
sreichel Oct 20, 2024
8764ff2
replaced variabvĺe $select_id
sreichel Oct 20, 2024
8b5365b
replaced variabvĺe $currency_code
sreichel Oct 20, 2024
aaeba5f
replaced variabvĺe $_selection
sreichel Oct 20, 2024
444e7b5
replaced variabvĺe $_checkedPaths
sreichel Oct 20, 2024
0bc8539
replaced variabvĺe $_optionId
sreichel Oct 20, 2024
bca910f
replaced variabvĺe $url_prefix
sreichel Oct 20, 2024
d155cd5
replaced variabvĺe $logo_src
sreichel Oct 20, 2024
d53cf72
replaced variabvĺe $_printValue
sreichel Oct 20, 2024
f0cc586
replaced variabvĺe $entity_id
sreichel Oct 20, 2024
21528cd
replaced variabvĺe $_key
sreichel Oct 20, 2024
35c69e3
replaced variabvĺe $_value
sreichel Oct 20, 2024
4388ee4
replaced variabvĺe $item_id
sreichel Oct 20, 2024
a5a4270
replaced variable $tax_amount
sreichel Oct 20, 2024
865398e
replaced variable $tax_info
sreichel Oct 20, 2024
2c02f7c
replaced variable ...
sreichel Oct 20, 2024
261df7e
replaced variable $total_reviews
sreichel Oct 20, 2024
489a9a0
replaced variable $_truncatedValue
sreichel Oct 20, 2024
e94f07e
replaced variable ...
sreichel Oct 20, 2024
ca2bf73
replaced variable ...
sreichel Oct 20, 2024
eea26d0
replaced variable ...
sreichel Oct 21, 2024
d96173e
replaced variable ...
sreichel Oct 21, 2024
67436e5
update
sreichel Oct 22, 2024
c5d8829
copyright dates
sreichel Oct 22, 2024
1a1b17d
Merge remote-tracking branch 'origin/phpmd-workflow' into phpmd-workflow
sreichel Oct 22, 2024
b61b3c5
fix
sreichel Oct 22, 2024
d8f0071
rector
sreichel Oct 22, 2024
027d63c
Merge branch 'main' into phpmd-workflow
sreichel Oct 23, 2024
a7046a7
updated commands
sreichel Oct 23, 2024
2a28f39
updated commands
sreichel Oct 23, 2024
f3d99b5
removed some phpcs comments
sreichel Oct 23, 2024
8affb0e
added phpcs default config (for phpstorm)
sreichel Oct 23, 2024
b26e111
added github label
sreichel Oct 23, 2024
1ca6c02
phpcs
sreichel Oct 23, 2024
ab4cc2f
Merge branch 'main' into phpmd-workflow
sreichel Oct 23, 2024
1350ad0
Merge branch 'main' into phpmd-workflow
sreichel Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .ddev/commands/web/phpcs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
## Usage: phpcs
## Example: ddev phpcs <path-to-files>

php vendor/bin/phpcs -s -p --report=full,summary "$@"
php vendor/bin/phpcs -s -p --standard=.phpcs.dist.xml --cache=.phpcs.result.cache --report=full,summary "$@"
2 changes: 1 addition & 1 deletion .ddev/commands/web/phpmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
## Usage: phpmd
## Example: ddev phpmd <path-to-files>

php vendor/bin/phpmd "$@" text .phpmd.dist.xml
php vendor/bin/phpmd "$@" text .phpmd.dist.xml --color --cache --baseline-file .phpmd.dist.baseline.xml
7 changes: 7 additions & 0 deletions .ddev/commands/web/phpmd-no-baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

## Description: run PHPMD
## Usage: phpmd-no-baseline
## Example: ddev phpmd-no-baseline <path-to-files>

php vendor/bin/phpmd "$@" text .phpmd.dist.xml
2 changes: 1 addition & 1 deletion .ddev/commands/web/phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
## Usage: phpunit
## Example: ddev phpunit

php vendor/bin/phpunit --no-coverage "$@" --testdox
php vendor/bin/phpunit --configuration .phpunit.dist.xml --no-coverage "$@" --testdox
2 changes: 1 addition & 1 deletion .ddev/commands/web/phpunit-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
## Example: ddev phpunit-coverage

enable_xdebug
XDEBUG_MODE=coverage php vendor/bin/phpunit --testdox
XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration .phpunit.dist.xml --testdox "$@"
disable_xdebug
2 changes: 1 addition & 1 deletion .ddev/commands/web/phpunit-coverage-local
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
## Example: ddev phpunit-coverage-local

enable_xdebug
XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html build/coverage --testdox
XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration .phpunit.dist.xml --coverage-html build/coverage --testdox "$@"
disable_xdebug
2 changes: 1 addition & 1 deletion .ddev/commands/web/rector
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
## Usage: rector
## Example: ddev rector <path-to-files>

php vendor/bin/rector process "$@"
php vendor/bin/rector process --config .rector.php "$@"
5 changes: 3 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
/.phpcs.ecg.xml.dist export-ignore
/.phpcs.php.xml.dist export-ignore
/.phpcs.xml.dist export-ignore
/.phpmd.dist.baseline.xml export-ignore
/.phpmd.dist.xml export-ignore
/.phpstan.dist.baseline.neon export-ignore
/.phpstan.dist.neon export-ignore
/rector.php export-ignore
/.rector.php export-ignore

/README.md export-ignore

Expand All @@ -35,4 +36,4 @@
*.sql text eol=lf
*.svg text eol=lf
*.txt text eol=lf
*.phtml text eol=lf
*.phtml text eol=lf
12 changes: 9 additions & 3 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -884,18 +884,24 @@
.github/workflows/php-cs-fixer.yml
]

'phpmd':
- changed-files:
- any-glob-to-any-file: [
.phpmd*,
.github/workflows/phpmd.yml
]

'phpstan':
- changed-files:
- any-glob-to-any-file: [
.phpstan*,
phpstan*,
.github/workflows/phpstan.yml
]

'phpunit':
- changed-files:
- any-glob-to-any-file: [
phpunit*,
.phpunit*,
tests/*,
.github/workflows/phpunit.yml
]
Expand All @@ -910,6 +916,6 @@
'rector':
- changed-files:
- any-glob-to-any-file: [
rector.php,
.rector.php,
.github/workflows/rector.yml
]
17 changes: 15 additions & 2 deletions .github/workflows/check-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ on:
php-cs-fixer:
description: "Count changed PHP-CS-Fixer files"
value: ${{ jobs.check.outputs.php-cs-fixer }}
phpmd:
description: "Count changed PHPMD files"
value: ${{ jobs.check.outputs.phpmd }}
phpstan:
description: "Count changed PHPStan files"
value: ${{ jobs.check.outputs.phpstan }}
Expand All @@ -48,6 +51,7 @@ jobs:
workflow: ${{ steps.changes-workflow.outputs.workflow }}
phpcs: ${{ steps.changes-phpcs.outputs.phpcs }}
php-cs-fixer: ${{ steps.changes-php-cs-fixer.outputs.php-cs-fixer }}
phpmd: ${{ steps.changes-phpstan.outputs.phpmd }}
phpstan: ${{ steps.changes-phpstan.outputs.phpstan }}
phpunit-test: ${{ steps.changes-phpunit-test.outputs.phpunit-test }}
phpunit: ${{ steps.changes-phpunit.outputs.phpunit }}
Expand Down Expand Up @@ -82,8 +86,9 @@ jobs:
.github/workflows/**
**phpcs**
**php-cs-fixer**
**phpmd**
**phpstan**
rector.php
.rector.php
tests/
phpunit*
Expand Down Expand Up @@ -145,6 +150,14 @@ jobs:
echo "$count PHP-CS-Fixer file(s) changed"
echo "php-cs-fixer=$count" >> $GITHUB_OUTPUT
- name: Check if PHPMD files changed
id: changes-phpmd
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "**phpmd**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHPMD file(s) changed"
echo "phpmd=$count" >> $GITHUB_OUTPUT
- name: Check if PHPStan files changed
id: changes-phpstan
if: steps.changed-files-specific.outputs.any_modified == 'true'
Expand All @@ -165,6 +178,6 @@ jobs:
id: changes-phpunit
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "phpunit*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
count="$(grep -oE "**phpunit**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHPUnit file(s) changed"
echo "phpunit=$count" >> $GITHUB_OUTPUT
9 changes: 4 additions & 5 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
matrix:
rules:
- label: Default
path: .phpcs.xml.dist
path: .phpcs.dist.xml
- label: Ecg
path: .phpcs.ecg.xml.dist
path: .phpcs.dist.ecg.xml
- label: PhpCompatibility
path: .phpcs.php.xml.dist
path: .phpcs.dist.php.xml

steps:
- name: Setup PHP
Expand All @@ -44,5 +44,4 @@ jobs:
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*

- name: PHPCodeSniffer
run: php vendor/bin/phpcs -s --report=full --standard=${{ matrix.rules.path }}
continue-on-error: ${{ matrix.rules.path == '.phpcs.ecg.xml.dist' }}
run: php vendor/bin/phpcs -s -p --report=full --standard=${{ matrix.rules.path }}
32 changes: 32 additions & 0 deletions .github/workflows/phpmd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: PHPMD

on:
workflow_call:
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
phpcs:
name: Mess Detector
runs-on: [ubuntu-latest]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*

- name: PHPMD
run: php vendor/bin/phpmd app/code/core/Mage/ github .phpmd.dist.xml --baseline-file .phpmd.dist.baseline.xml
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*

- name: Restore result cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: .phpstan.cache
key: "phpstan-result-cache-${{ github.run_id }}"
Expand All @@ -48,7 +48,7 @@ jobs:
run: XDEBUG_MODE=off php vendor/bin/phpstan.phar analyze

- name: Save result cache
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: always()
with:
path: .phpstan.cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
--skip_url_validation 'yes'
- name: Run phpUnit
run: php -f vendor/bin/phpunit
run: php vendor/bin/phpunit --configuration .phpunit.dist.xml

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
rector:
name: Validation
name: Rector
runs-on: [ubuntu-latest]

steps:
Expand All @@ -34,4 +34,4 @@ jobs:
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*

- name: Rector
run: php vendor/bin/rector process --dry-run
run: php vendor/bin/rector process --config .rector.php --dry-run
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
php-versions: ['7.4']
steps:
- name: Checkout repository
uses: actions/checkout@master
uses: actions/checkout@4

- name: Get composer cache directory
id: composer-cache
Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ on:
- '**.js'
- '**.xml'
- '.php-cs-fixer.dist.php'
- '.phpcs.xml.dist'
- '.phpcs.ecg.xml.dist'
- '.phpcs.php.xml.dist'
- 'phpstan.dist.neon'
- 'phpstan.dist.baseline.neon'
- '.phpcs.dist.xml'
- '.phpcs.dist.ecg.xml'
- '.phpcs.dist.php.xml'
- '.phpstan.dist.neon'
- '.phpstan.dist.baseline.neon'

pull_request:
paths:
Expand All @@ -25,11 +25,11 @@ on:
- '**.js'
- '**.xml'
- '.php-cs-fixer.dist.php'
- '.phpcs.xml.dist'
- '.phpcs.ecg.xml.dist'
- '.phpcs.php.xml.dist'
- 'phpstan.dist.neon'
- 'phpstan.dist.baseline.neon'
- '.phpcs.dist.xml'
- '.phpcs.dist.ecg.xml'
- '.phpcs.dist.php.xml'
- '.phpstan.dist.neon'
- '.phpstan.dist.baseline.neon'

jobs:
debug:
Expand Down Expand Up @@ -82,6 +82,16 @@ jobs:
needs.check.outputs.workflow > 0
uses: ./.github/workflows/php-cs-fixer.yml

phpmd:
name: PHPMD
needs: [check, composer]
if: |
needs.check.outputs.php > 0 ||
needs.check.outputs.phpmd > 0 ||
needs.check.outputs.composer > 0 ||
needs.check.outputs.workflow > 0
uses: ./.github/workflows/phpmd.yml

phpstan:
name: PHPStan
needs: [check, composer]
Expand Down
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,15 @@
.php-cs-fixer*
!.php-cs-fixer.dist.*

# PHPCS cache
.phpcs.result.cache
.phpcs*.xml
!.phpcs*.xml.dist
!.phpcs.dist*.xml
!.phpcs.xml
phpcs.xml

# PHPMD cache
.phpmd.result-cache.php

# PhpStan
.phpstan.cache
Expand All @@ -75,7 +82,7 @@ tests/coverage
tests/logging
.phpunit.result.cache
phpunit.xml
!phpunit.xml.dist
!.phpunit.dist.xml

# build
/build
Expand Down
Loading
Loading