2016-02-14 00:56:32 +00:00
|
|
|
#!/bin/sh
|
2017-01-02 21:04:09 +00:00
|
|
|
# Execute lint to spot code mistakes.
|
2015-09-17 07:35:26 +00:00
|
|
|
|
2017-01-05 08:45:14 +00:00
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
|
2018-03-11 20:15:09 +00:00
|
|
|
export files="$(git diff $(git merge-base upstream/dev HEAD) --diff-filter=d --name-only | grep -e '\.py$')"
|
|
|
|
echo '================================================='
|
|
|
|
echo '= FILES CHANGED ='
|
|
|
|
echo '================================================='
|
2018-03-09 20:27:39 +00:00
|
|
|
if [ -z "$files" ] ; then
|
2018-05-10 10:47:04 +00:00
|
|
|
echo "No python file changed. Rather use: tox -e lint\n"
|
2018-03-09 20:27:39 +00:00
|
|
|
exit
|
2016-08-23 03:52:31 +00:00
|
|
|
fi
|
2018-03-09 20:27:39 +00:00
|
|
|
printf "%s\n" $files
|
|
|
|
echo "================"
|
|
|
|
echo "LINT with flake8"
|
|
|
|
echo "================"
|
2019-11-06 19:38:00 +00:00
|
|
|
pre-commit run flake8 --files $files
|
2018-03-09 20:27:39 +00:00
|
|
|
echo "================"
|
|
|
|
echo "LINT with pylint"
|
|
|
|
echo "================"
|
2018-05-10 10:47:04 +00:00
|
|
|
pylint_files=$(echo "$files" | grep -v '^tests.*')
|
|
|
|
if [ -z "$pylint_files" ] ; then
|
|
|
|
echo "Only test files changed. Skipping\n"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
pylint $pylint_files
|
2018-03-09 20:27:39 +00:00
|
|
|
echo
|