This repository was archived by the owner on Jun 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfabfile.py
More file actions
49 lines (40 loc) · 1.33 KB
/
fabfile.py
File metadata and controls
49 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from fabpolish import polish, sniff, local, info
from fabpolish.contrib import (
find_merge_conflict_leftovers,
find_pep8_violations
)
import os
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
@sniff(severity='major', timing='fast')
def remove_compiled_classes():
# Remove compiled python classes
info('Removing compiled python classes...')
return local("find ./ -name '*.py[co]' -print0 | xargs -0 rm -f")
@sniff(severity='major', timing='fast')
def code_analyzer():
"""Running static code analyzer"""
info('Running static code analyzer...')
return local(
"git ls-files -z | "
"grep -vz '^\.' | "
"grep -Pvz '\.(md|yml|log|txt|lock)$' |"
"grep -Pzv '(fabfile.py|Makefile)' |"
"grep -Pzv '(sample|cron)' |"
"xargs -0 pyflakes"
)
@sniff(severity='major', timing='fast')
def remove_debug_info():
"""Check and remove debugging print statements"""
# Have to remove scripts and test file
info('Checking for debug print statements...')
return local(
"! git ls-files -z | "
"grep -PZvz '^scripts/' | "
"grep -PZvz 'tests/run_tests.py' | "
"grep -PZvz 'fabfile.py' | "
"grep -PZz \.py$ | "
"xargs -0 grep -Pn \'(?<![Bb]lue|>>> )print\' | "
"grep -v NOCHECK"
)
if __name__ == "__main__":
polish()