rwx/sh/lint/lint.sh
2025-02-01 01:29:47 +01:00

79 lines
1.1 KiB
Bash

# lint code
rwx_lint() {
local path="${1}"
[ -n "${path}" ] || exit 1
rwx_lint_clean
set \
"python" \
"shell"
local code
for code in "${@}"; do
rwx_log "${code}"
"rwx_lint_${code}" "${path}"
done
rwx_lint_clean
}
# clean
rwx_lint_clean() {
local path="${1}"
[ -n "${path}" ] || exit 1
rwx_log "py3clean"
py3clean \
--verbose \
"${path}"
set \
"mypy" \
"ruff"
local tool
for tool in "${@}"; do
rwx_log "${tool}"
rwx_remove "${path}/.${tool}_cache"
done
}
# lint python code
rwx_lint_python() {
local path="${1}"
local action
set \
"pylint" \
"pydoclint" \
"mypy" \
"ruff"
for action in "${@}"; do
rwx_log "${action}"
"rwx_${action}" "${path}"
done
}
# 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
}
# 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 \
" ${type}" \
"${path}"
done
}