Example #1
0
def fix_white_space():
    info('Fixing whitespace errors...')
    return local("git ls-files -z | "
                 "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\\+$//' ")
Example #2
0
def python_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")
Example #3
0
def find_php_syntax_errors():
    """Find syntax error in php files
    """
    info('Finding syntax error in php files...')
    return local("git ls-files -z | "
                 "grep -PZz '\.(php|phtml)$' | "
                 "xargs -0 -n 1 php -l >/tmp/debug")
Example #4
0
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|xlxs)$' | "
                 "xargs -0 grep -PlZn '(\\s+$)|(\\t)' | "
                 "tee /dev/stderr | "
                 "xargs -0 -r sed -i -e 's/\\t/    /g' ")
Example #5
0
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"')
Example #6
0
def check_python_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 \'(?<![Bb]lue|>>> )print\' | "
                 "grep -v NOCHECK")
Example #7
0
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")
Example #8
0
def run_pyflakes():
    """
    Run pyflakes
    """
    info('Running static code analysis...')
    return local("git ls-files | "
                 "awk '/^healthscoop\/.*\.py$/ {print $1}' | "
                 "awk '!/^healthscoop\/manage/' | "
                 "xargs pyflakes")
Example #9
0
def check_pep8_styles():
    """
    Run pep8 python coding standard check
    """
    info('Running style check...')
    return local("git ls-files | "
                 "awk '/^healthscoop\/.*\.py$/ {print $1}' | "
                 "awk '!/^healthscoop\/manage/' | "
                 "xargs pycodestyle --config=conf/pycodestyle")
Example #10
0
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")
Example #11
0
def remove_compiled_classes():
    # Remove compiled python classes
    info('Removing compiled python classes...')
    return local("find ./ -name '*.py[co]' -print0 | xargs -0 rm -f")
Example #12
0
def find_merge_conflict_leftovers():
    """
    Avoid merge conflicts
    """
    info('Finding merge conflict leftovers...')
    return local("! git grep -P '^(<|=|>){7}(?![<=>])'")
Example #13
0
def run_test():
    info('Running tests...')
    return local('nose2 --config conf/nose2.cfg')
Example #14
0
def check_preg_replace():
    info('Checking use of preg_replace...')
    return local("! find src -name '*.php' -print0 | "
                 "xargs -0 grep -n 'preg_replace('")
Example #15
0
def check_migration_branch():
    """Checking migration branches"""
    info('Checking migration branches...')
    return local("! alembic branches | grep branchpoint")
Example #16
0
def composer_validate():
    info('Running composer validate...')
    return local('composer validate')
Example #17
0
def run_eslint():
    info('Running ESLint...')
    return local("git ls-files | "
                 "grep '\.js$' | "
                 "xargs ./node_modules/eslint/bin/eslint.js")
Example #18
0
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")
Example #19
0
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")
Example #20
0
def find_pep8_violations():
    """Run pep8 python coding standard check
    """
    info('Running coding standards check for python files...')
    return local("git ls-files -z | " "grep -PZz '\.py$' | " "xargs -0 pep8")
Example #21
0
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'")
Example #22
0
def composer_security_check_npm():
    """Requires nsp in package"""
    info('Running security check for python dependencies...')
    return local("safety check -r requirements.txt")
Example #23
0
def check_python_code_complexity():
    info('Checking code complexity...')
    return local("xenon fabpolish -bB -mA -aA")