mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-18 08:16:07 +00:00
add code-check.sh to improve code quality
This commit is contained in:
54
code-check.sh
Executable file
54
code-check.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
function usage() {
|
||||
echo
|
||||
echo " Seahub project code checker."
|
||||
echo
|
||||
echo " It runs pylint on the code and prints the result."
|
||||
echo
|
||||
echo " To check a file:"
|
||||
echo
|
||||
echo " ./code-check.sh seahub.views.file"
|
||||
echo
|
||||
echo " To check a module:"
|
||||
echo
|
||||
echo " ./code-check.sh seahub.views"
|
||||
echo
|
||||
}
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
usage;
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $# == 1 ]]; then
|
||||
if [[ $1 == "-h" || $1 == "--help" ]]; then
|
||||
usage;
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
PROJECT_DIR=$(dirname "${SCRIPT}")
|
||||
|
||||
cd ${PROJECT_DIR}
|
||||
|
||||
if which pylint 2>/dev/null 1>&2; then
|
||||
echo
|
||||
echo "Pylint not found. Please install it first by:"
|
||||
echo
|
||||
echo " sudo pip install pylint"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pylintrc=${PROJECT_DIR}/pylintrc
|
||||
if ! [[ -f ${pylintrc} ]]; then
|
||||
echo "${pylintrc} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pylint --rcfile=${pylintrc} $@
|
Reference in New Issue
Block a user