rwx/sh/lint/lint.sh

80 lines
1.1 KiB
Bash
Raw Normal View History

2025-01-31 22:37:33 +00:00
# lint code
rwx_lint() {
local path="${1}"
2025-02-01 00:30:54 +00:00
[ -n "${path}" ] || return 1
2025-02-01 00:29:47 +00:00
rwx_lint_clean
2025-01-31 22:37:33 +00:00
set \
"python" \
"shell"
2025-02-01 00:29:47 +00:00
local code
2025-01-31 22:37:33 +00:00
for code in "${@}"; do
rwx_log "${code}"
"rwx_lint_${code}" "${path}"
done
2025-02-01 00:29:47 +00:00
rwx_lint_clean
2025-01-31 22:37:33 +00:00
}
2025-02-01 00:18:13 +00:00
# clean
rwx_lint_clean() {
local path="${1}"
2025-02-01 00:30:54 +00:00
[ -n "${path}" ] || return 1
2025-02-01 00:27:04 +00:00
rwx_log "py3clean"
py3clean \
--verbose \
"${path}"
2025-02-01 00:18:13 +00:00
set \
"mypy" \
"ruff"
2025-02-01 00:27:04 +00:00
local tool
2025-02-01 00:18:13 +00:00
for tool in "${@}"; do
rwx_log "${tool}"
rwx_remove "${path}/.${tool}_cache"
done
}
2025-01-31 17:31:24 +00:00
# lint python code
2025-01-31 22:34:44 +00:00
rwx_lint_python() {
2025-01-31 17:31:24 +00:00
local path="${1}"
2025-01-31 22:31:44 +00:00
local action
set \
"pylint" \
"pydoclint" \
"mypy" \
"ruff"
for action in "${@}"; do
rwx_log "${action}"
"rwx_${action}" "${path}"
done
2025-01-31 17:31:24 +00:00
}
2025-01-31 22:34:44 +00:00
# lint shell code
rwx_lint_shell() {
local path="${1}"
local action
set \
"shellcheck" \
"shfmt"
for action in "${@}"; do
rwx_log "${action}"
"rwx_${action}" "${path}"
done
}
2025-01-31 23:58:14 +00:00
# lint code tasks
rwx_lint_tasks() {
local path="${1}"
local type
set \
"LATER" \
"TODO" \
"FIXME"
for type in "${@}"; do
rwx_log "${type}"
grep \
--directories "recurse" \
--line-number \
2025-02-01 00:02:10 +00:00
" ${type}" \
"${path}"
2025-01-31 23:58:14 +00:00
done
}