rwx/sh/lint/lint.sh
Marc Beninca 020aaa0b9a
All checks were successful
/ job (push) Successful in 1m12s
refactor(history): commit development branch
new development branch from root commit
2025-02-10 21:54:51 +01:00

78 lines
1.2 KiB
Bash

# lint code
rwx_lint() {
local path="${1}"
[ -n "${path}" ] || return 1
rwx_lint_clean "${path}"
rwx_lint_tasks "${path}"
set \
"python" \
"shell"
local code
for code in "${@}"; do
rwx_log "" "${code}"
"rwx_lint_${code}" "${path}"
done
rwx_lint_clean "${path}"
}
# clean
rwx_lint_clean() {
local path="${1}"
[ -n "${path}" ] || return 1
rwx_log "" "clean" ""
py3clean "${path}"
set \
"mypy" \
"ruff"
local tool
for tool in "${@}"; do
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 \
--after "1" \
--directories "recurse" \
--line-number \
" ${type}" \
"${path}"
done
}