Giter Club home page Giter Club logo

muhafiz's Introduction

muhafiz

Master: Build Status

Guard your codebase from bad code!

                         ...',,,,,',:
                        ,,.',okxc,,,Oc
                       .,.',;0OOx,,,;K'
                       :.',,;XoxK,,,,cK.
                      ';.',,,l00d,,,,,oO
                      c''',,,oWWo,,,,,,O:
                     ,:.',,,,;NX,,,,,,,:0
                     ,;.',,,,,K0,,,,,,,,k;
                     ;,',,,,:OMWx;,,,,,,l.
                    .odxxox0NNWNNXkooxOXW.
                     okKWNNX0NNXKkNNWWWWN.
                     'dOWNWNKNWNX0MXNWWWo
                      ,oONWX0KWN0OKNWWNo.
                    ....;c;...cl',',lo;'...
                  .......';odOKXNKc'..'',,,'.
                 ...;ldxlxWWWWWWWWXW0doc;,,,,.
                .'oKNWWWWN0kOKXXX00NWNWWN0xc,,.
               'xNWWWWWN0o'..,:c,'',kNWWWWWWKo,
              ,XWWNX0Odc,',oxxxxc.,,':xXNNNWWWK;
             .0WXOdl:,..''ldolodx;',,,,;lkKXXNWN.
            .:xxc;'.  ..,'ldddooxc',,,,,,,.',:;:
               ....  ...,,,oxxxOd,,,,,,,,,....
                 ... ..',,,'lokd,,,,,,,,,,...
                   .....,,,'oxKd,,,,,,,,,..
                     ...,,,'o0Wd,,,,;;:c:
                     :oxdxxcoNWkxkkkO0KKx
                     .';;;;,OXW0...,,,,,'
                   ...',,,'lKKW0...,,,,,,.
                   ..',,,,.dWO0k,..,,,,,,,
                  ..',,,,,.cNdOk:..,,,,,,,'
                 ..',,,,,,..Ookkc..',,,,,,,
                 '.,,,,,,'. lkdx:...,,,,,,,.
                 ..,,,,,'.. 'xox....',,,,,,.
                 ..,,,,,..   :o:'  ...,,,,,'
                 ..,,,,.      c..     .,,,,.
                 .......      ..      .......

Git

Installation

You need to copy the required git-hook to your project's .git/hooks directory And put the src directory in somewhere (eg. ~/muhafiz/src)

$ git clone git://github.com/sonsuzdongu/muhafiz.git ~/muhafiz
$ cp ~/muhafiz/git-hooks/* /your/project/.git/hooks

Configuration

You have to set your 'muhafiz.bootstrap-file' git config setting to show your muhafiz bootstrap file

$ git config muhafiz.bootstrap-file ~/muhafiz/src/bootstrap.php

Or better you set it system wide or global

$ sudo git config --global muhafiz.bootstrap-file ~/muhafiz/src/bootstrap.php
$ sudo git config --system muhafiz.bootstrap-file ~/muhafiz/src/bootstrap.php

Then you have to set the comma separated list of code checkers(aka runners) using 'muhafiz.active-runners' git config parameter

$ git config muhafiz.active-runners 'phpcs, jshint'

After this, 'all your commits are belongs to us'. All your commits will be checked by given runners and commit will be prevented if are there any errors

Subversion

Installation

You need to copy the required svn-hook to your repository's hooks directory And put the src directory in somewhere (eg. ~/muhafiz/src)

$ git clone git://github.com/sonsuzdongu/muhafiz.git ~/muhafiz
$ cp ~/muhafiz/svn-hooks/pre-commit /home/svn/your_project/hooks/
$ cp ~/muhafiz/svn-hooks/muhafiz.conf /home/svn/your_project/conf/

Configuration

You have to edit your 'muhafiz.conf' file to locate bootstrap file and configure runners:

[muhafiz]
bootstrap-file=~/muhafiz/src/bootstrap.php
active-runners='php, bom'

List of code checkers(aka runners) must be separated by commas.

After this, 'all your commits are belongs to us'. All your commits will be checked by given runners and commit will be prevented if are there any errors

Runners

  • bom Check files for byte order mark

  • php Check php files for syntax errors using 'php -l' command line tool

  • phpcs (PhpCodeSniffer)

    • config parameters :
      • 'muhafiz.runners.phpcs.standard' : set coding standard (see reference doc) | defaults to "PEAR"
      • 'muhafiz.runners.phpcs.report' : set reporting type (see reference doc) | defaults to "emacs"
  • php-cs-fixer (Php CS Fixer)

    • config parameters :
      • 'muhafiz.runners.php-cs-fixer.standard' : set coding standard (see reference doc) | defaults to "psr2"
  • jshint (JSHint Node.js Command Line Tool)

    • config parameters :
      • 'muhafiz.runners.jshint.config' : jshint config file (see reference doc) | defaults to ".jshintrc"
  • lineend Check files' line endings

    • config parameters :
      • 'muhafiz.runners.lineend.allowed' : should be 'unix' or 'windows'
  • vardump Check php/phtml files for var_dump() or print_r() statement

  • consolefoo Check js files for console.*() statements

  • pyflakes the passive checker of Python programs

  • pep8 check your Python code against some of the style conventions in PEP 8.

    • config parameters :
      • 'muhafiz.runners.pep8.repeat' : show all occurrences of the same error.
      • 'muhafiz.runners.pep8.ignore' : skip errors and warnings (e.g. E4,W)
      • 'muhafiz.runners.pep8.select' : select errors and warnings (e.g. E,W6)
      • 'muhafiz.runners.pep8.show-source' : show source code for each error
      • 'muhafiz.runners.pep8.show-pep8' : show text of PEP 8 for each error (implies --first)
      • 'muhafiz.runners.pep8.show-statistics' : display count of errors and warnings

Setting exclude patterns for runners

Exclude patterns can be set for each runner with setting a RegExp rule in 'muhafiz.runners.RUNNER_NAME.exclude-pattern' like

Git:

$ git config muhafiz.runners.lineend.exclude-pattern '/static\/images/'

Subversion:

[muhafiz]
runners.lineend.exclude-pattern='/static\/images/'

In this example, lineend rune will not be applied to files which matches that rule (like /foo/static/images/bar.xyz)

Disabling pushes to specific branches (Only on pre-receive hook)

You can disable pushes to specific branches by

Git:

$ git config muhafiz.disabled-branches "foo bar"

Subversion:

[muhafiz]
disabled-branches="foo bar"

Contributors

Osman Yüksel
Volkan Altan
chesterx
Adil İlhan
Eser Özvataf
İbrahim Gündüz

TODO

  • verbose options

muhafiz's People

Contributors

yuxel avatar volkan avatar adililhan avatar ibrahimgunduz34 avatar sercanvirlan avatar mustafaileri avatar

Watchers

James Cloos 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.