mirror of
https://github.com/simon987/nyaa.git
synced 2025-12-16 08:19:05 +00:00
Fix lint check + update lint script (#224)
* Fix PEP8 E301 on nyaa/models.py * Add utils/ to lint checker * Run of lint.sh + manual fixes As suggested https://github.com/nyaadevs/nyaa/pull/157#issuecomment-305051428 * Fix backwards tick in README * Updated script * Update Travis config
This commit is contained in:
57
lint.sh
57
lint.sh
@@ -1,6 +1,51 @@
|
||||
autopep8 nyaa/ \
|
||||
--recursive \
|
||||
--in-place \
|
||||
--pep8-passes 2000 \
|
||||
--max-line-length 100 \
|
||||
--verbose
|
||||
# Lint checker/fixer
|
||||
|
||||
check_paths="nyaa/ utils/"
|
||||
max_line_length=100
|
||||
|
||||
function auto_pep8() {
|
||||
autopep8 ${check_paths} \
|
||||
--recursive \
|
||||
--in-place \
|
||||
--pep8-passes 2000 \
|
||||
--max-line-length ${max_line_length} \
|
||||
--verbose
|
||||
}
|
||||
|
||||
function check_lint() {
|
||||
pycodestyle ${check_paths} \
|
||||
--show-source \
|
||||
--max-line-length=${max_line_length} \
|
||||
--format '%(path)s [%(row)s:%(col)s] %(code)s: %(text)s'
|
||||
}
|
||||
|
||||
# MAIN
|
||||
action=auto_pep8 # default action
|
||||
for arg in "$@"
|
||||
do
|
||||
case "$arg" in
|
||||
"-h" | "--help")
|
||||
echo "Lint checker/fixer"
|
||||
echo ""
|
||||
echo "Usage: $0 [-c|--check] [-h|--help]"
|
||||
echo " No arguments : Check and auto-fix some warnings/errors"
|
||||
echo " -c | --check : only check lint (don't auto-fix)"
|
||||
echo " -h | --help : show this help and exit"
|
||||
exit 0;
|
||||
;;
|
||||
"-c" | "--check")
|
||||
action=check_lint
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
${action} # run selected action
|
||||
result=$?
|
||||
|
||||
if [[ ${action} == check_lint ]]; then
|
||||
if [[ ${result} == 0 ]]; then
|
||||
echo "Looks good!"
|
||||
else
|
||||
echo "The code requires some changes."
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user