Skip to content

Latest commit

History

32 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

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:

fromfabpolishimportpolishfromfabpolish.contribimportfind_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:

fromfabpolishimportpolish, sniff, local, info@sniff(severity='critical', timing='fast')defcheck_var_dump():
info("Checking var_dump statements...")
returnlocal("! 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:

@sniffdefyour_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:

fromfabpolishimportupdate_snifffromfabpolish.contribimportfind_pep8_violationsupdate_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

About

Run various checks against source code using Fabric

Resources

Stars

4 stars

Watchers

33 watching

Forks

Releases

Packages

Used by

Contributors

Languages