Git Product home page Git Product logo

coke's Introduction

Coke - Enjoy sniffing your code

Coke is a Shell/Bash command using PHP Code Sniffer allowing rules management per project.

Configuration file

Create a .coke file at your project root :

# Command used to launch PHP CodeSniffer (optional - default: phpcs)
command=phpcs
 
# Path used to load Standards (optional)
standard-path=path/to/PHPCS/Standards/

# Standard used by PHP CodeSniffer (required)
standard=Symfony2
 
# Verbose mode (optional - default: false)
verbose=true
 
# Only Git changed mode (optional - default: false)
only-git-changed=true
 
# White list of files and directories (optional)
src/
test.php
 
# Black list of files and directories (optional)
!Tests
!src/OldFile.php

and just launch the command :

$ coke

Run the command with arguments

You can override .coke settings by passing directly configuration as arguments to the command :

$ coke src test.php --standard=Symfony2 --ignore=Tests,src/OldFile.php -v

The order of arguments is not important

src test.php Files/Directories to include in the check
--standard=Symfony2 Standard to use for check
--ignore=Tests,src/OldFile.php URL patterns to ignore in the check
--only-git-changed Check only changed files
-v Use verbose mode

Additional arguments

You can use any phpcs arguments (documentation)

For example if you want to generate a report with your favorite CI tools you can run

$ coke --report-checkstyle=checkstyle.xml

Installation via composer

Add coke in the require-dev section of your composer.json :

"require-dev": {
    "m6web/coke" : "~2.0"
}

By default composer will add a symlink to coke in vendor/bin/coke.

If you want to change it, add this in your composer.json (more information about this in the composer documentation) :

"config": {
    "bin-dir": "bin"
}

Then you can call coke via :

./bin/coke

Git pre-commit hook

You can use a dedicated pre-commit hook :

$ wget --output-document=.git/hooks/pre-commit https://gist.githubusercontent.com/JJK801/5867810/raw/f26ec4778273b3f7140428252ab31951de2faba4/pre-commit.sh

Or

$ curl -L https://gist.githubusercontent.com/JJK801/5867810/raw/f26ec4778273b3f7140428252ab31951de2faba4/pre-commit.sh > .git/hooks/pre-commit

Then

$ chmod +x .git/hooks/pre-commit

Credits

Developped by the Cytron Team of M6 Web.

License

Coke is licensed under the MIT license.

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.