forked from Just-Some-Bots/MusicBot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
code_checks.sh
executable file
·112 lines (95 loc) · 2.03 KB
/
code_checks.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
HELP_ME=0
DO_FORMAT=0
DO_SPELLING=0
DO_OPTIONAL=0
ONLY_BASE_CHECKS=0
while [[ $# -gt 0 ]] ; do
case $1 in
"format"|"--format")
DO_FORMAT=1
shift
;;
"spell"|"spelling"|"--spelling")
DO_SPELLING=1
shift
;;
"base")
# only check with black
ONLY_BASE_CHECKS=1
shift
;;
"opt"|"optional")
DO_OPTIONAL=1
shift
;;
"help"|"--help"|"-h")
HELP_ME=1
shift
;;
*)
shift
;;
esac
done
if [ "$HELP_ME" == "1" ]; then
echo "$0"
echo "Code checks helper script."
echo ""
echo "Available Options:"
echo " -h or help Show this message and exit"
echo " format Run code format via isort and black automatically."
echo " spell Run spelling check, if pylint is configured for it."
echo " base Only run basic black check. Option format will still apply if set."
echo " optional Adds extra checks. Currently only bandit."
echo ""
exit 0
fi
echo "Black on py38:"
if [ "$DO_FORMAT" == "0" ]; then
python -m black . --diff --color --check -t py38
else
python -m black . -t py38
fi
echo "----"
echo ""
if [ "$ONLY_BASE_CHECKS" == "1" ] ; then
echo "Skipping all other checks."
exit 0
fi
echo "isort imports:"
if [ "$DO_FORMAT" == "0" ]; then
isort . --check --diff --color --profile black
else
isort . --profile black
fi
echo "----"
echo ""
echo "Flake8:"
python -m flake8
echo "----"
echo ""
echo "MyPy:"
mypy --python-version 3.8 --warn-unused-ignores ./*.py
echo "----"
echo ""
echo "pylint:"
if [ "$DO_SPELLING" == "1" ]; then
pylint --recursive=y --spelling-dict=en_US --spelling-private-dict-file=./tests/repo-dictionary.txt .
else
pylint --recursive=y .
fi
echo "----"
echo ""
echo "Shellcheck:"
shellcheck -a --color ./*.sh
echo "----"
echo ""
if [ "$DO_OPTIONAL" == "1" ]; then
echo "Bandit:"
bandit -r .
echo "----"
#echo "Checking for i18n data missing from source base..."
#python ./tests/test_missing_i18n.py
#echo "----"
fi