Skip to content

Commit

Permalink
Add pylinter.sh and setup.cfg files.
Browse files Browse the repository at this point in the history
The pylinter.sh and setup.cfg added to the project which automatically
checks for linting issues so contributors can fix them.

Fixes: the-ethan-hunt#129
  • Loading branch information
Man-Jain committed Jul 17, 2018
1 parent 5581bdf commit 545a3ec
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
55 changes: 55 additions & 0 deletions pylinter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

directories="linux"
pass=0
fail=0

function prepare_venv() {
VIRTUALENV=$(which venv)
if [ $? -eq 1 ]; then

VIRTUALENV=$(which venv-3)
fi

${VIRTUALENV} python3 -m venv mybenjienv && source myenv/bin/activate && python3 "$(which pip3)" install pycodestyle
}


echo "----------------------------------------------------"
echo "Running Python Linter against following directories:"
echo "$directories"
echo "----------------------------------------------------"
echo

[ "$NOVENV" == "1" ] || prepare_venv || exit 1

# checks for the whole directories
for directory in $directories
do
files=$(find "$directory" -path "$directory/venv" -prune -o -name '*.py' -print)

for source in $files
do
echo "$source"
pycodestyle "$source"
if [ $? -eq 0 ]
then
echo " Pass"
let "pass++"
else
echo " Fail"
let "fail++"
fi
done
done

$(deactivate && rm -rf mybenjienv/)

if [ $fail -eq 0 ]
then
echo "All checks passed for $pass source files"
else
let total=$pass+$fail
echo "Linter fail, $fail source files out of $total source files need to be fixed"
exit 1
fi
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pycodestyle]
ignore = W504
max-line-length = 80


0 comments on commit 545a3ec

Please sign in to comment.