This project is not covered by Drupal’s security advisory policy.

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

  1. Enable the module:
    drush en clean_code

Usage

Drush Commands

  1. Generate GrumPHP Configuration and Install Packages:
    • Command: drush clean_code:generate-install
    • Alias: drush ccgi
    • Example:
      drush clean_code:generate-install
  2. 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
  3. Generate GrumPHP Configuration Without Installing Packages (Override):
    • Command: drush clean_code:generate-no-install
    • Alias: drush ccgni
    • Example:
      drush clean_code:generate-no-install

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 ccgi

To edit the GrumPHP configuration file and customize tasks or options, use:

drush ccgni

Project information

Releases