78 lines
1.2 kB
1
# lint code
2
rwx_lint() {
3
local path="${1}"
4
[ -n "${path}" ] || return 1
5
rwx_lint_clean "${path}"
6
rwx_lint_tasks "${path}"
7
set \
8
"python" \
9
"shell"
10
local code
11
for code in "${@}"; do
12
rwx_log "" "${code}"
13
"rwx_lint_${code}" "${path}"
14
done
15
rwx_lint_clean "${path}"
16
}
17
18
# clean
19
rwx_lint_clean() {
20
local path="${1}"
21
[ -n "${path}" ] || return 1
22
rwx_log "" "clean" ""
23
py3clean "${path}"
24
set \
25
"mypy" \
26
"ruff"
27
local tool
28
for tool in "${@}"; do
29
rwx_remove "${path}/.${tool}_cache"
30
done
31
}
32
33
# lint python code
34
rwx_lint_python() {
35
local path="${1}"
36
local action
37
set \
38
"pylint" \
39
"pydoclint" \
40
"mypy" \
41
"ruff"
42
for action in "${@}"; do
43
rwx_log "" "${action}"
44
"rwx_${action}" "${path}"
45
done
46
}
47
48
# lint shell code
49
rwx_lint_shell() {
50
local path="${1}"
51
local action
52
set \
53
"shellcheck" \
54
"shfmt"
55
for action in "${@}"; do
56
rwx_log "" "${action}"
57
"rwx_${action}" "${path}"
58
done
59
}
60
61
# lint code tasks
62
rwx_lint_tasks() {
63
local path="${1}"
64
local type
65
set \
66
"LATER" \
67
"TODO" \
68
"FIXME"
69
for type in "${@}"; do
70
rwx_log "" "${type}"
71
grep \
72
--after "1" \
73
--directories "recurse" \
74
--line-number \
75
" ${type}" \
76
"${path}"
77
done
78
}
79