forked from pwndbg/pwndbg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lint.sh
executable file
·67 lines (53 loc) · 1.33 KB
/
lint.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
#!/bin/bash
set -o errexit
help_and_exit() {
echo "Usage: ./lint.sh [-f|--filter]"
echo " -f, --filter format code instead of just checking the format"
exit 1
}
if [[ $# -gt 1 ]]; then
help_and_exit
fi
FORMAT=0
while [[ $# -gt 0 ]]; do
case $1 in
-f | --format)
FORMAT=1
shift
;;
*)
help_and_exit
;;
esac
done
set -o xtrace
LINT_FILES="pwndbg tests *.py"
LINT_TOOLS="isort black flake8 vermin"
if ! type ${LINT_TOOLS} &> /dev/null; then
PIP_CMD="pip install -Ur dev-requirements.txt"
echo "Missing one of the following tools: ${LINT_TOOLS}"
echo "Running '${PIP_CMD}'"
$PIP_CMD
fi
if [[ $FORMAT == 1 ]]; then
isort ${LINT_FILES}
black ${LINT_FILES}
else
isort --check-only --diff ${LINT_FILES}
black --check --diff ${LINT_FILES}
fi
if [ -x "$(command -v shfmt)" ]; then
# Indents are four spaces, binary ops can start a line, indent switch cases,
# and allow spaces following a redirect
shfmt -i 4 -bn -ci -sr -d .
else
echo "shfmt not installed, skipping"
fi
# Checking minimum python version
vermin -vvv --no-tips -q -t=3.6 --violations ./pwndbg/
flake8 --show-source ${LINT_FILES}
if [ -x "$(command -v mypy)" ]; then
mypy pwndbg
else
echo "mypy not installed, skipping"
fi