Clean Code
Overview
The Clean Code module integrates GrumPHP into your Drupal project to enforce coding standards and perform code quality checks. It provides Drush commands to generate and manage GrumPHP configurations, ensuring that your codebase remains clean and adheres to best practices. it runs automatically during Git operations to catch issues before they are committed, ensuring a high-quality codebase.
Features
- Automated code quality checks during Git operations.
- Manual code quality checks via Drush commands.
- Saves GrumPHP results to a log file for review.
- Drush commands for generating and managing GrumPHP configurations.
- Composer package management for GrumPHP tasks.
- Integration with Git pre-commit hooks.
- Saves GrumPHP results to a log file for review.
Installation
- Enable the module:
drush en clean_code
Usage
Drush Commands
- Generate GrumPHP Configuration and Install Packages:
- Command:
drush clean_code:generate-install - Alias:
drush ccgi - Example:
drush clean_code:generate-install
- Command:
- Run GrumPHP Checks:
- Command:
drush clean_code:check - Aliases:
drush clc:check,drush code:check - Examples:
drush clean_code:check drush clean_code:check --tasks=phpcs,phplint
- Command:
- Generate GrumPHP Configuration Without Installing Packages (Override):
- Command:
drush clean_code:generate-no-install - Alias:
drush ccgni - Example:
drush clean_code:generate-no-install
- Command:
Available Tasks
GrumPHP tasks available for code checks include:
- git_blacklist: Ensures no blacklisted files are committed.
- git_branch_name: Validates Git branch names.
- git_commit_message: Validates Git commit message formats.
- phpcs: Enforces PHP coding standards with PHP CodeSniffer.
- phplint: Performs PHP lint checks for syntax errors.
- phpmd: Detects code smells with PHP Mess Detector.
- phpstan: Analyzes PHP code with PHPStan.
- phpunit: Runs PHPUnit tests.
- twigcs: Checks Twig templates for coding standards.
- yamllint: Lints YAML files for syntax and style issues.
- jsonlint: Lints JSON files for syntax correctness.
- security-checker: Checks project dependencies for security vulnerabilities.
Configuration
To install necessary packages and set up the GrumPHP configuration file, use the following command:
drush ccgiTo edit the GrumPHP configuration file and customize tasks or options, use:
drush ccgni
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 1.0.0-alpha5 | Pre-release | improvements, minor cleanup and bugfixes . | Oct 27, 2024 | ||
| 1.0.0-alpha4 | Pre-release | improvements, minor cleanup. | Oct 17, 2024 | ||
| 1.0.0-alpha3 | Pre-release | improvements, minor cleanup. | Oct 16, 2024 | ||
| 1.0.0-alpha2 | Pre-release | improvements, minor cleanup and bugfixes. | Oct 16, 2024 | ||
| 1.0.0-alpha1 | Pre-release | First alpha release | Oct 12, 2024 |