Giter VIP home page Giter VIP logo

civicrm-coder's Introduction

Coder

Build Status

Coder is a library for automated Drupal code reviews and coding standard fixes. It defines rules for PHP_CodeSniffer

Built-in support for:

Online documentation: https://www.drupal.org/node/1419980

Installation

First, make sure Composer is installed correctly:

which composer

Until CiviCRM Coder is listed in Packagist, you may need to manually add it to your ~/.composer/composer.json with something like this:

{
    "require": {
        "civicrm/civicrm-coder": "2015-01-19"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "https://github.com/xurizaemon/civicrm-coder.git"
        }
    ]
}

To make the phpcs and phpcbf commands available globally, add the composer bin path to your $PATH variable in ~/.profile, ~/.bashrc or ~/.zshrc:

export PATH="$PATH:$HOME/.composer/vendor/bin"

Register the CiviCRM Coder Standard with PHPCS:

phpcs --config-set installed_paths ~/.composer/vendor/civicrm/civicrm-coder/coder_sniffer

Or if you want both Drupal and CiviCRM standards, you might need to expand the tildes when providing both, eg:

phpcs --config-set installed_paths /home/chris/.composer/vendor/drupal/coder/coder_sniffer,/home/chris/.composer/vendor/civicrm/civicrm-coder/coder_sniffer

Usage

Check Drupal coding standards

phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme /file/to/drupal/example_module

Check Drupal best practices

phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme /file/to/drupal/example_module

Automatically fix coding standards

phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme /file/to/drupal/example_module

Working with Editors

Drupal Code Sniffer can be used with various editors.

Editors:

Automated Testing (PHPUnit)

Coder Sniffer comes with a PHPUnit test suite to make sure the sniffs work correctly. Use Composer to install the dependencies:

composer install

Then execute the tests:

./vendor/bin/phpunit

Maintainers

Klaus Purer, https://www.drupal.org/u/klausi

Credits

Greg Sherwood and Squiz Pty Ltd, many sniffs are modified copies of their original work on PHPCS.

civicrm-coder's People

Contributors

agh1 avatar das-peter avatar davereid avatar douggreen avatar dww avatar ericduran avatar klausi avatar snpower avatar solotandem avatar sun avatar totten avatar xurizaemon avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.