Code Quality checker wrapper for GrumPHP
This package is auto-updated.
Last update: 2021-09-30 12:42:19 UTC
This composer package will provide some basic code quality checks before committing code by using https://github.com/phpro/grumphp.
It checks only modified files or new files on git commit, but check on all configured
paths can be executed running
This repository currently has following checks:
- Shell script exec bits - check_file_permissions
- PHP Drupal CS and PHP Code security - phpcs
- PHP 7.3 Compatibility - php_compatibility
- PHP syntax - php_check_syntax
- Cognitive complexity and other ecs sniffs - ecs
- Yaml syntax - yaml_lint
- Json syntax - json_lint
- Deprecation testing - php_stan
- PHP >= 7.1
This needs to be done only once either while creating a project or enabling code checks in existing project.
composer require wunderio/code-quality --dev cp vendor/wunderio/code-quality/config/grumphp.yml ./grumphp.yml cp vendor/wunderio/code-quality/config/phpstan.neon ./phpstan.neon
The commit hook for GrumPHP is automatically installed on composer require.
Details of the configuration are broken down into the following sections.
- Parameters – Configuration settings for GrumPHP itself.
- Tasks – External tasks performing code validation and their respective configurations.
- Conventions checker
If you need to customize the rules for PHP CodeSniffer then drop in phpcs.xml in the same folder as composer.json and configure grumphp.yml:
parameters: tasks: phpcs: standard: - phpcs.xml
Same applies to any task that uses other configuration file (easy-coding-standards).
Each code quality tool allows you to define at least 3 things:
run_on- Multiple paths that will be checked and files staged must be from same path
ignore_patterns- path parts that will exclude files from check
extensions- file extensions of files that should be checked
Please see individual task documentation for more information on what are other configurable options.
Since GrumPHP is just a CLI tool, these commands can be triggered:
The pre-commit hook will be automatically run upon executing
The code scanning can be avoided by
git commit --no-verify or
git commit -n.
You can run the checks manually with:
You can easily use the code quality checkers on your CI (CircleCi/Jenkins/GitLab CI) by adding this line:
./vendor/bin/grumphp run --no-ansi --no-interaction