Run various checks against source code using Fabric
pip install fab-polish
Create a fabfile.py in your source code with the following minimal code:
fromfabpolishimportpolishfromfabpolish.contribimportfind_merge_conflict_leftoversNow 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.
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():
# codeCheck https://github.com/practo/FabPolish/blob/master/fabpolish/contrib.py for more examples.
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')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