mirror of
https://github.com/kuhyx/scripts.git
synced 2026-11-10 20:07:12 +01:00
refactor: remove all skip-fmt flags and enforce all checks always
This commit is contained in:
parent
f9884270e4
commit
53bd0fd60a
@ -33,11 +33,11 @@ if [[ ${#staged_files[@]} -gt 0 ]]; then
|
|||||||
printf ' ✓ Auto-fixes applied and staged\n'
|
printf ' ✓ Auto-fixes applied and staged\n'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf 'Running shell_check validation (shellcheck only, skip formatting check)...\n'
|
printf 'Running shell_check validation...\n'
|
||||||
|
|
||||||
# Run shell_check but only check for actual errors (shellcheck, syntax), not formatting
|
# Run shell_check to validate all checks
|
||||||
if ! scripts/meta/shell_check.sh --skip-install --skip-fmt 2>&1; then
|
if ! scripts/meta/shell_check.sh --skip-install 2>&1; then
|
||||||
printf '\nCommit aborted: shell_check reported issues that cannot be auto-fixed.\n' >&2
|
printf '\nCommit aborted: shell_check reported issues.\n' >&2
|
||||||
printf 'Fix the remaining problems and retry the commit.\n' >&2
|
printf 'Fix the remaining problems and retry the commit.\n' >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -23,7 +23,6 @@ ROOT_DIR="$DEFAULT_ROOT"
|
|||||||
SKIP_INSTALL="false"
|
SKIP_INSTALL="false"
|
||||||
INSTALL_ONLY="false"
|
INSTALL_ONLY="false"
|
||||||
LIST_ONLY="false"
|
LIST_ONLY="false"
|
||||||
SKIP_FMT="false"
|
|
||||||
VERBOSE="false"
|
VERBOSE="false"
|
||||||
|
|
||||||
log_info() {
|
log_info() {
|
||||||
@ -43,15 +42,12 @@ usage() {
|
|||||||
Usage: $(basename "$0") [options]
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--path DIR Root directory to scan (default: repo root at $DEFAULT_ROOT)
|
--path DIR Root directory to scan (default: repo root at $DEFAULT_ROOT)
|
||||||
--skip-install Skip installing linters
|
--skip-install Skip installing linters
|
||||||
--install-only Only install linters, do not scan
|
--install-only Only install linters, do not scan
|
||||||
--list-only Only list discovered shell files, do not run linters
|
--list-only Only list discovered shell files, do not run linters
|
||||||
--skip-fmt Skip shfmt formatting checks (useful after auto-fixing)
|
--verbose Print additional details while running
|
||||||
--verbose Print additional details while running
|
-h, --help Show this helpLinters used:
|
||||||
-h, --help Show this help
|
|
||||||
|
|
||||||
Linters used:
|
|
||||||
Required: shellcheck, shfmt
|
Required: shellcheck, shfmt
|
||||||
Optional (if available): checkbashisms, bashate
|
Optional (if available): checkbashisms, bashate
|
||||||
Syntax checks: bash -n, zsh -n (if installed), sh/dash -n
|
Syntax checks: bash -n, zsh -n (if installed), sh/dash -n
|
||||||
@ -76,10 +72,6 @@ while [[ $# -gt 0 ]]; do
|
|||||||
LIST_ONLY="true"
|
LIST_ONLY="true"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--skip-fmt)
|
|
||||||
SKIP_FMT="true"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--verbose)
|
--verbose)
|
||||||
VERBOSE="true"
|
VERBOSE="true"
|
||||||
shift
|
shift
|
||||||
@ -278,9 +270,7 @@ run_linters() {
|
|||||||
|
|
||||||
log_info "Running shfmt (diff mode)..."
|
log_info "Running shfmt (diff mode)..."
|
||||||
local shfmt_out="$TMPDIR/shfmt.diff"
|
local shfmt_out="$TMPDIR/shfmt.diff"
|
||||||
if [[ $SKIP_FMT == "true" ]]; then
|
if is_cmd shfmt; then
|
||||||
log_info "Skipping shfmt (--skip-fmt flag)"
|
|
||||||
elif is_cmd shfmt; then
|
|
||||||
if ! shfmt -d -i 2 -ci -sr -s "${FILES[@]}" >"$shfmt_out" 2>&1; then
|
if ! shfmt -d -i 2 -ci -sr -s "${FILES[@]}" >"$shfmt_out" 2>&1; then
|
||||||
# shfmt returns non-zero when diff exists
|
# shfmt returns non-zero when diff exists
|
||||||
issues=$((issues + 1))
|
issues=$((issues + 1))
|
||||||
@ -376,9 +366,7 @@ run_linters() {
|
|||||||
printf '\n\033[1;32m-- shellcheck: PASS (no issues) --\033[0m\n'
|
printf '\n\033[1;32m-- shellcheck: PASS (no issues) --\033[0m\n'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $SKIP_FMT == "true" ]]; then
|
if [[ -s $shfmt_out ]]; then
|
||||||
printf '\n\033[1;32m-- shfmt: SKIPPED (--skip-fmt) --\033[0m\n'
|
|
||||||
elif [[ -s $shfmt_out ]]; then
|
|
||||||
printf '\n\033[1m-- shfmt (diffs found) --\033[0m\n'
|
printf '\n\033[1m-- shfmt (diffs found) --\033[0m\n'
|
||||||
cat "$shfmt_out"
|
cat "$shfmt_out"
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user