From 6e0ca7bd2ff475e834ef67c303e573fae0acb4a7 Mon Sep 17 00:00:00 2001 From: abhineet08 Date: Thu, 20 Aug 2015 12:23:55 +0000 Subject: [PATCH 1/5] adding new sniffs --- fabpolish/contrib.py | 79 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/fabpolish/contrib.py b/fabpolish/contrib.py index 65a645a..7c7007c 100644 --- a/fabpolish/contrib.py +++ b/fabpolish/contrib.py @@ -31,3 +31,82 @@ def find_pep8_violations(): "grep -PZz '\.py$' | " "xargs -0 pep8" ) + + +@sniff(severity='major', timing='fast') +def fix_file_permission(): + """Fixing permissions for files""" + info('Fixing permissions for files') + return local( + "git ls-files -z | " + "grep -PvZz '\.sh$' | " + "xargs -0 chmod -c 0664 > /dev/null 2>&1" + ) + + +@sniff(severity='major', timing='fast') +def fix_script_permission(): + # Fix script permissions + info('Fixing script permissions...') + return local( + "git ls-files -z | " + "grep -PZz '\.sh$' | " + "xargs -0 -r chmod 0775 >/dev/null 2>&1" + ) + + +@sniff(severity='major', timing='fast') +def fix_white_space(): + info('Fixing whitespace errors...') + return local( + "git ls-files -z | " + "grep -PZvz '\.(ico|jpg|png|gif|eot|ttf|woff|wav)$' | " + "xargs -0 grep -PlZn '(\\s+$)|(\\t)' | " + "tee /dev/stderr | " + "xargs -0 -r sed -i -e 's/\\s\\+$//' " + ) + + +@sniff(severity='major', timing='fast') +def convert_tab_spaces(): + info('Converting tab to spaces...') + return local( + "git ls-files -z | " + "grep -PZvz '\.(ico|jpg|png|gif|eot|ttf|woff|wav)$' | " + "xargs -0 grep -PlZn '(\\s+$)|(\\t)' | " + "tee /dev/stderr | " + "xargs -0 -r sed -i -e 's/\\t/ /g' " + ) + + +@sniff(severity='critical', timing='fast') +def check_migration_branch(): + """Checking migration branches""" + info('Checking migration branches...') + return local("! alembic branches | grep branchpoint") + + +@sniff(severity='major', timing='fast') +def remove_debug_info(): + """Check and remove debugging print statements""" + info('Checking for debug print statements') + return local( + "! git ls-files -z | " + "grep -PZvz 'fabfile.py' | " + "grep -PZz \.py$ | " + "xargs -0 grep -Pn \'(?>> )print\' | " + "grep -v NOCHECK" + ) + + +@sniff(severity='major', timing='fast') +def check_image_edited(): + # Check if image files have been edited + info('Checking if image files have been edited...') + info('Explanation: A new image should be created when editing images to avoid browser caching') + branch = local('git rev-parse --abbrev-ref HEAD') + return local( + '! git diff master...' + branch + + ' --name-only --diff-filter=M | ' + + 'grep ".gif\|.png\|.jpg"' + ) From c2ee1c147abb81327a55ba897f86f23b1d1caf7b Mon Sep 17 00:00:00 2001 From: abhineet08 Date: Thu, 20 Aug 2015 12:47:38 +0000 Subject: [PATCH 2/5] adding static code analyzer --- fabpolish/contrib.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fabpolish/contrib.py b/fabpolish/contrib.py index 7c7007c..655003d 100644 --- a/fabpolish/contrib.py +++ b/fabpolish/contrib.py @@ -21,6 +21,18 @@ def find_php_syntax_errors(): ) +@sniff(severity='major', timing='fast') +def code_analyzer(): + """Running static code analyzer""" + info('Running static code analyzer') + return local( + "git ls-files -z | " + "grep -PZz '\.py$' | " + "grep -PZvz 'fabfile.py' | " + "xargs -0 pyflakes" + ) + + @sniff(severity='minor', timing='slow') def find_pep8_violations(): """Run pep8 python coding standard check From a1c815c864e17ff49a8b1100a0db71cd50af7f57 Mon Sep 17 00:00:00 2001 From: abhineet08 Date: Fri, 21 Aug 2015 10:03:27 +0000 Subject: [PATCH 3/5] ignoring xlxs files for whitespace corrections --- fabpolish/contrib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fabpolish/contrib.py b/fabpolish/contrib.py index 655003d..5284d9a 100644 --- a/fabpolish/contrib.py +++ b/fabpolish/contrib.py @@ -72,7 +72,7 @@ def fix_white_space(): info('Fixing whitespace errors...') return local( "git ls-files -z | " - "grep -PZvz '\.(ico|jpg|png|gif|eot|ttf|woff|wav)$' | " + "grep -PZvz '\.(ico|jpg|png|gif|eot|ttf|woff|wav|xlxs)$' | " "xargs -0 grep -PlZn '(\\s+$)|(\\t)' | " "tee /dev/stderr | " "xargs -0 -r sed -i -e 's/\\s\\+$//' " @@ -84,7 +84,7 @@ def convert_tab_spaces(): info('Converting tab to spaces...') return local( "git ls-files -z | " - "grep -PZvz '\.(ico|jpg|png|gif|eot|ttf|woff|wav)$' | " + "grep -PZvz '\.(ico|jpg|png|gif|eot|ttf|woff|wav|xlxs)$' | " "xargs -0 grep -PlZn '(\\s+$)|(\\t)' | " "tee /dev/stderr | " "xargs -0 -r sed -i -e 's/\\t/ /g' " From c19cebaf36ed2943c348e9ba93dfc1fb69a3f3b9 Mon Sep 17 00:00:00 2001 From: abhineet08 Date: Fri, 21 Aug 2015 12:34:42 +0000 Subject: [PATCH 4/5] fixing indentation issues --- fabpolish/contrib.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fabpolish/contrib.py b/fabpolish/contrib.py index 5284d9a..4bdc3eb 100644 --- a/fabpolish/contrib.py +++ b/fabpolish/contrib.py @@ -44,7 +44,7 @@ def find_pep8_violations(): "xargs -0 pep8" ) - + @sniff(severity='major', timing='fast') def fix_file_permission(): """Fixing permissions for files""" @@ -55,7 +55,7 @@ def fix_file_permission(): "xargs -0 chmod -c 0664 > /dev/null 2>&1" ) - + @sniff(severity='major', timing='fast') def fix_script_permission(): # Fix script permissions @@ -66,7 +66,7 @@ def fix_script_permission(): "xargs -0 -r chmod 0775 >/dev/null 2>&1" ) - + @sniff(severity='major', timing='fast') def fix_white_space(): info('Fixing whitespace errors...') @@ -115,7 +115,8 @@ def remove_debug_info(): def check_image_edited(): # Check if image files have been edited info('Checking if image files have been edited...') - info('Explanation: A new image should be created when editing images to avoid browser caching') + info('Explanation: A new image should be created when ' + 'editing images to avoid browser caching') branch = local('git rev-parse --abbrev-ref HEAD') return local( '! git diff master...' + branch + From 4cb6b07575e914065984721f6ca8df9e89530658 Mon Sep 17 00:00:00 2001 From: amankrbl Date: Tue, 26 Apr 2016 06:31:36 +0000 Subject: [PATCH 5/5] sniff added --- fabpolish/contrib.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fabpolish/contrib.py b/fabpolish/contrib.py index 4bdc3eb..90f25a4 100644 --- a/fabpolish/contrib.py +++ b/fabpolish/contrib.py @@ -123,3 +123,9 @@ def check_image_edited(): ' --name-only --diff-filter=M | ' + 'grep ".gif\|.png\|.jpg"' ) + + +@sniff(severity='critical', timing='fast') +def composer_validate(): + info('Running composer validate...') + return local('composer validate')