From 8212e4f5c23a91f558707916f957f09fbf0ac8f9 Mon Sep 17 00:00:00 2001 From: amankrbl Date: Tue, 3 May 2016 12:49:20 +0000 Subject: [PATCH] new sniffs --- fabpolish/contrib.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/fabpolish/contrib.py b/fabpolish/contrib.py index 90f25a4..291f630 100644 --- a/fabpolish/contrib.py +++ b/fabpolish/contrib.py @@ -22,7 +22,7 @@ def find_php_syntax_errors(): @sniff(severity='major', timing='fast') -def code_analyzer(): +def python_code_analyzer(): """Running static code analyzer""" info('Running static code analyzer') return local( @@ -99,7 +99,7 @@ def check_migration_branch(): @sniff(severity='major', timing='fast') -def remove_debug_info(): +def check_python_debug_info(): """Check and remove debugging print statements""" info('Checking for debug print statements') return local( @@ -111,6 +111,15 @@ def remove_debug_info(): ) +@sniff(severity='major', timing='fast') +def check_php_debug_info(): + info('Checking for var_dump, echo or die statements...') + return local( + "! find ./src -name '*.php' -print0 | " + "xargs -0 egrep -n 'var_dump|echo|die' | grep -v 'NOCHECK'" + ) + + @sniff(severity='major', timing='fast') def check_image_edited(): # Check if image files have been edited @@ -129,3 +138,12 @@ def check_image_edited(): def composer_validate(): info('Running composer validate...') return local('composer validate') + + +@sniff(severity='major', timing='fast') +def check_preg_replace(): + info('Checking use of preg_replace...') + return local( + "! find src -name '*.php' -print0 | " + "xargs -0 grep -n 'preg_replace('" + )