jover_be/drupal-pre-commit

This package is abandoned and no longer maintained. The author suggests using the jover_be/drupal-code-check package instead.

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

v0.0.13 2017-04-18 14:59 UTC

This package is not auto-updated.

Last update: 2022-02-01 13:03:17 UTC


README

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.