/drupal-code-check

A Git pre-commit hook to check Drupal Coding Standards and more.

Primary LanguagePHPMIT LicenseMIT

Drupal Code Check

A Git pre-commit hook to check Drupal Coding Standards and more.

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock

Description

This Git pre-commit hook will be active on your Composer based Drupal project.

Things which will be checked in the pre-commit hook:

  • Syntax checking using PHP Linter
  • Automatically try to match code style via PHP Code Sniffer Beautifier and Fixer
  • Coding standards checking using PHP Code Sniffer
  • Blacklisted strings checking/validation

Note that files of the following origins are not checked:

  • Drupal Core
  • Contributed Modules
  • Contributed Libraries
  • Contributed Themes
  • Contributed Profiles

Getting started

Prerequisites

  • Composer
  • Composer based Drupal project
  • PHP 5.4 or higher

Installation

Add this project as a composer dependency on your Composer based Drupal project.

composer require jover_be/drupal-code-check

And don't forget to update...

composer update jover_be/drupal-code-check

In order to activate the Git Hooks, update your composer.json file like following:

{
    "scripts": {
        "post-install-cmd": [
            "jover_be\\drupal_code_check\\GitHooks::create"
        ],
        "post-update-cmd": [
        	"jover_be\\drupal_code_check\\GitHooks::create",
        ]
    }
}

Development requirement

In case you want to install it as a development requirement (require-dev), make use of the project neronmoon/scriptsdev in order to execute the scripts only in case your project was installed in development mode.

composer require --dev neronmoon/scriptsdev
composer require --dev jover_be/drupal-code-check

And instead, you should be using the scripts-dev part as described by

{
    "extra": {
        "scripts-dev": {
            "post-install-cmd": [
                "jover_be\\drupal_code_check\\GitHooks::create"
            ],
            "post-update-cmd": [
                "jover_be\\drupal_code_check\\GitHooks::create",
            ]
        }
    }
}

Author

jover.be

License

This project is licensed under the MIT License - see the LICENSE file for details.