Coder Social home page Coder Social logo

fabpolish's Introduction

Fab Polish

Run various checks against source code using Fabric

Installation

pip install fab-polish

Usage

Minimal Usage

Create a fabfile.py in your source code with the following minimal code:

from fabpolish import polish
from fabpolish.contrib import find_merge_conflict_leftovers

Now run fab polish. The above example runs a sniff that finds bad merge commits by checking if symbols like '<<<<<<<' are present in the versioned files.

Writing Sniffs

You can create your own sniff by using the sniff decorator:

from fabpolish import polish, sniff, local, info

@sniff(severity='critical', timing='fast')
def check_var_dump():
    info("Checking var_dump statements...")
    return local("! git grep 'var_dump'")

Severity can be 'critical', 'major', 'minor', 'info'. Default is 'critical'. Timing can be 'slow', 'fast'. Default is 'fast'.

When using default values, the sniff decorator can be used without the function call like so:

@sniff
def your_sniff():
    # code

Check https://github.com/practo/FabPolish/blob/master/fabpolish/contrib.py for more examples.

Modifying Imported Sniffs

The severity, timing values can be altered for any sniff imported from contrib using update_sniff function like follows:

from fabpolish import update_sniff
from fabpolish.contrib import find_pep8_violations

update_sniff(find_pep8_violations, severity='major', timing='fast')

Running All Sniffs

By default fab polish runs only fast-critical and fast-major sniffs. In a CI environment, to run all the sniffs including slow, minor ones, run fab polish:ci

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.