Download the PHP package wunderio/code-quality without Composer
On this page you can find all versions of the php package wunderio/code-quality. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wunderio/code-quality
More information about wunderio/code-quality
Files in wunderio/code-quality
Package code-quality
Short Description Code Quality checker wrapper for GrumPHP
License MIT
Homepage https://github.com/wunderio/code-quality
Informations about the package code-quality
Code Quality
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 vendor/bin/grumphp run
This tool only extends GrumPHP. Please read its documentation on how to configure tool itself.
Checks performed
This repository currently has the following checks:
- Shell script exec bits - check_file_permissions
- PHP Drupal CS and PHP Code security - phpcs
- PHP 8.1 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
Pre-requisites
- Composer
- PHP >= 8.1
Installation
This needs to be done only once either while creating a project or enabling code checks in existing project.
The commit hook for GrumPHP is automatically installed on composer require.
Customization
Configuration
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.
- TestSuites
- Extensions
- Events
- Conventions checker
Task parameters
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: `
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 pathignore_patterns
- path parts that will exclude files from checkextensions
- file extensions of files that should be checked
Please see individual task documentation for more information on what are other configurable options.
Commands
Since GrumPHP is just a CLI tool, these commands can be triggered:
Usage
The pre-commit hook will be automatically run upon executing git commit
.
The code scanning can be avoided by git commit --no-verify
or git commit -n
but is only meant for rare occasions.
You can run the checks manually with: ./vendor/bin/grumphp run
To run specific task from the defined tasks in grumphp.yml, you can define it with --tasks
parameter. Example:
./vendor/bin/grumphp run --tasks=phpcs
Usage in Continuous Integration
You can easily use the code quality checkers on your CI (CircleCi/Jenkins/GitLab CI) by adding this line:
All versions of code-quality with dependencies
phpro/grumphp Version ^2.5
drupal/coder Version ^8
phpcompatibility/php-compatibility Version ^9.3
pheromone/phpcs-security-audit Version ^2.0
squizlabs/php_codesniffer Version ^3.4
dealerdirect/phpcodesniffer-composer-installer Version *
mglaman/phpstan-drupal Version ^1.1
phpstan/extension-installer Version ^1.1
phpstan/phpstan-deprecation-rules Version ^1.0
webflo/drupal-finder Version ^1.3