eonx-com / easy-quality
使EonX的PHP项目使用代码质量工具变得更加容易
Requires
- php: ~8.2
- jangregor/phpstan-prophecy: 1.0.2
- phpmd/phpmd: 2.15.0
- phpmetrics/phpmetrics: ^2.8
- phpstan/phpdoc-parser: 1.29.1
- phpstan/phpstan: 1.11.5
- rector/rector: 1.1.1
- slevomat/coding-standard: 8.15.0
- symplify/easy-coding-standard: 12.1.6
- symplify/phpstan-extensions: 11.4.3
- symplify/phpstan-rules: 13.0.0
Requires (Dev)
- phpunit/phpunit: ^10.5
- dev-main
- 4.1.0
- 4.0.1
- 4.0.0
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.0
- 3.5.0
- 3.4.0
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.2.1
- 1.2.0
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.2
- 0.1.1
- 0.1.0
- dev-feature/MTCE-203-allow-to-configure-parallel-processing
- dev-feature/update-packages-30-06-24
- dev-feature/ecs-fix-inheritdoc-to-lowercase
- dev-feature/improve-phpstan-config
- dev-feature/update-all-packages
- dev-feature/ecs-Psr4Sniff-support-multiple-directories-in-namespace
- dev-feature/ecs-Fix-GrantsForCreateTableMigrationSniff-when-custom-method-for-grant
- dev-feature/ecs-add-option-to-configure-grant-method-in-GrantsForCreateTableMigrationSniff
- dev-feature/PBA-3528-Add-a-new-check-for-grants-query-in-the-create-table-migration
- dev-feature/Update-AddSeeAnnotationRector-to-support-attributes
- dev-feature/ecs-set-default-value-if-missed-for-nullable-promoted-property
- dev-feature/use-phpmetrics
- dev-feature/ecs-allow-abstract-methods-in-ArrangeActAssertSniff
- dev-feature/fix-OrderedClassElementsFixer-configuration
- dev-feature/update-packages-03-07-2023
- dev-feature/update-all-packages-02-06-23
- dev-feature/ecs-udescore-at-bottom-AlphabeticallySortedArraySniff
- dev-feature/ecs-update-OrderedClassElementsFixer-configs
- dev-feature/refactor-quality-tools-configs
- dev-feature/ecs-ignore-special-chars-in-AlphabeticallySortedArraySniff
- dev-feature/add-DisallowMixedTypeHintSniff-to-shared-config
- dev-feature/ecs-update-PropertyTypeHintSniff-settings
- dev-feature/ecs-create-AlphabeticallySortedArraySniff
- dev-feature/ecs-refactor-sniffs
- dev-feature/ecs-use-value-when-key-is-null-in-AlphabeticallySortedArrayKeysSniff
- dev-feature/upgrade-all-packages-15-05-2023
- dev-feature/Add-DisallowBusinessConstantUsageInAssertBlock-sniff
- dev-feature/INF-254-update-deprecated-actions-php-ci
- dev-feature/update-github-actions
- dev-feature/add-return-type-rectors-to-shared-config
- dev-feature/update-packages-16-12-22
- dev-feature/ecs-add-SortAttributesAlphabeticallySniff
- dev-feature/setup-phpstan
- dev-feature/setup-rector-checks
- dev-feature/setup-quality-checks
- dev-feature/add-gitattributes-config
- dev-feature/output-add-output-module-tests-to-CI
- dev-feature/update-all-packages-17-11-22
- dev-feature/fix-main-packages-version
- dev-feature/ecs-allow-default-value-for-promoted-properties
- dev-feature/deprecate-AvoidPrivatePropertiesSniff
- dev-feature/update-linebreak-after-equals-sign-sniff
- dev-hotfix/change-order-for-sorted-api-resource-operation-keys-sniff
- dev-feature/phpstan-add-eonx-config
- dev-feature/deprecate-ThrowExceptionMessageSniff
- dev-feature/ecs-improve-DisallowNonNullDefaultValueSniff
- dev-feature/rector-deprecate-RestoreDefaultNullToNullableTypeParameterRector
- dev-feature/ecs_add_applyTo_option_to_AvoidPrivatePropertiesSniff
- dev-feature/upgrade-packages-07-09-2022
- dev-hotfix/add-export-operation-to-sorted-api-resource-sniff
- dev-feature/add-SingleQuoteFixer-to-eonx-set
- dev-hoftix/remove-deleted-sniff
- dev-feature/update-ecs-and-rector-sets-configs
- dev-feature/update-slevomat-coding-standard-and-rector
- dev-hotfix/sort-api-resource-operations-ecs-missed-docs
- dev-feature/PLU-4180-sort-api-resource-operations-ecs
- dev-feature/PLU-4180-sort-api-resource-operations
- dev-hotfix/throw-exception-message-rule-static-call
- dev-feature/PLU-4059-ecs-datetime-properties-declaration-check
- dev-update-slevomat-dependencie
- dev-update-slevomat-coding-standard
- dev-hotfix/update-composer-packages
- dev-feature/PLU-4403-Update-DisallowNonNullDefaultValueSniff-to-work-with-promoted-readonly-properties
- dev-feature/update-packages
- dev-feature/PLU-4390-Move-sort-rectors-to-EasyQuality-set
- dev-feature/PLU-4059-datetime-properties-declaration-check
- dev-feature/update-dependencies-for-the-second-version
- dev-feature/PLU-3385-mask-in-sniffer
- dev-feature/try-phpinsights-package
This package is auto-updated.
Last update: 2024-08-25 07:56:36 UTC
README
---eonx_docs--- 标题:介绍 重量:0 ---eonx_docs---
此包是一种将用于编码标准和质量工具的可重用类集中化的方式。它包含
安装(从项目的composer.json文件中单独安装)
-
在项目根目录下创建一个
quality
目录。 -
进入
quality
目录并运行composer require eonx-com/easy-quality
。 -
设置环境变量以加快本地执行速度
EONX_EASY_QUALITY_JOB_SIZE
- 并行处理的文件数量(默认:2)EONX_EASY_QUALITY_MAX_NUMBER_OF_PROCESS
- 最大并行进程数(默认:4)EONX_EASY_QUALITY_TIMEOUT_SECONDS
- 每个进程的超时时间(秒)(默认:120)
-
将
quality/vendor
添加到Git忽略列表中(可以在quality
目录中的.gitignore
文件中,或者在你的项目根目录的.gitignore
文件中)。 -
通过添加安装脚本更新你的项目的
composer.json
文件(这将自动化在所有本地机器上安装eonx-com/easy-quality
){ "post-install-cmd": [ "cd quality && composer install --no-dev" ] }
-
通过添加以下脚本更新你的项目的
composer.json
文件。这里我们使用veewee/composer-run-parallel
(将其作为dev
依赖项安装)在check-all
脚本中并行运行多个命令。你可以自由修改这些命令。{ "scripts": { "check-all": "@parallel check-security check-ecs check-rector check-phpmd-app check-phpmd-tests check-phpstan", "check-ecs": "php -d memory_limit=1024M quality/vendor/bin/ecs check --clear-cache", "check-phpmd-app": "quality/vendor/bin/phpmd src ansi phpmd.app.xml", "check-phpmd-tests": "quality/vendor/bin/phpmd tests ansi phpmd.tests.xml", "check-phpstan": "quality/vendor/bin/phpstan analyse --ansi --memory-limit=1000M", "check-rector": "quality/vendor/bin/rector process --dry-run" } }
-
确保在项目源代码根目录中配置了ECS、Rector、PHP Mess Detector和PHPStan的配置文件。
-
从项目源代码根目录运行
composer check-all
以确保一切正常,并修复找到的问题。 -
如果你想在CI中使用质量工具,以下是一个GitHub操作配置示例
coding-standards: needs: composer runs-on: ubuntu-latest timeout-minutes: 60 strategy: fail-fast: false matrix: php: ['8.2'] actions: - {name: phpstan, run: composer check-phpstan} - {name: phpmd-app, run: composer check-phpmd-app} - {name: phpmd-tests, run: composer check-phpmd-tests} - {name: rector, run: composer check-rector} - {name: security, run: composer check-security} - {name: yaml-linter, run: './bin/console lint:yaml config src translations --parse-tags'} - {name: ecs, run: composer check-ecs} env: EONX_EASY_QUALITY_JOB_SIZE: 20 EONX_EASY_QUALITY_MAX_NUMBER_OF_PROCESS: 32 EONX_EASY_QUALITY_TIMEOUT_SECONDS: 120 name: ${{ matrix.actions.name}} (${{ matrix.php }}) steps: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} coverage: none - name: Get the cached Composer dependencies uses: actions/cache@v4 with: path: src/vendor key: composer-${{ hashFiles('src/composer.lock') }} - name: Get the cached quality tools installation id: cache-quality-tools uses: actions/cache@v4 with: path: quality/vendor key: quality-tools-composer-${{ hashFiles('quality/composer.lock') }} - name: Install quality tools if: steps.cache-quality-tools.outputs.cache-hit == false run: composer --working-dir=../quality install --prefer-dist --no-scripts --no-progress --no-interaction --no-dev - name: Check ${{ matrix.actions.name }} run: ${{ matrix.actions.run }} shell: bash
为ECS(Easy Coding Standard)嗅探器准备配置文件
在项目的quality
目录中创建ECS的配置文件。
例如,请参阅quality/ecs.php。
运行ECS检查
转到项目的根目录并运行
composer check-ecs
或
quality/vendor/bin/ecs check
预期输出
[OK] No errors found. Great job - your code is shiny in style!
为Rector准备配置文件
在项目的quality
目录中创建Rector的配置文件。
例如,请参阅quality/rector.php。
运行Rector检查
转到项目的根目录并运行
composer check-rector
或
quality/vendor/bin/rector process --dry-run
预期输出
[OK] Rector is done!