Skip to content

chore(lint): shellcheck and shfmt every tracked shell file - #25

Merged
ttncode merged 5 commits into
mainfrom
chore/shell-tooling
Sep 16, 2026
Merged

ttncode merged 5 commits into
mainfrom
chore/shell-tooling

Conversation

@ttncode

@ttncode ttncode commented Sep 16, 2026

Copy link
Copy Markdown
Owner

What this changes

First of five cleanup PRs (spec: docs/superpowers/specs/2026-09-16-clean-shell-and-comments-design.md).

  • pins shfmt = "3.14.1"; mise run lint now runs shellcheck and shfmt -i 2 -ci -d over every tracked shell file, including services/, tests/*.bats and tests/helpers/, which were never linted before
  • fixes or suppresses (each with a same-line reason) what the wider shellcheck reports; tests/.shellcheckrc disables SC2317 for bats' @test bodies
  • 7b1ef84 is the shfmt -w pass; it also carries the second line of [tasks.lint], because the whole-tree pre-commit lint could not pass with either half alone

No behaviour change.

How it was verified

  • mise run lint β€” exit 0
  • mise run test-runner β€” 265/265 (196 unit + 69 integration), exit 0
  • reviewed: heredoc bodies, strings written into generated files and splice anchors are unchanged by the shfmt pass

Checklist

  • mise run lint passes
  • mise run test-runner passes
  • New behaviour has a test that fails without the change
  • Docs that describe changed behaviour were updated in the same commit
  • No unrelated changes

iam-truongtrungnghia added 5 commits September 16, 2026 16:35
Widen mise.toml's lint task to shellcheck every tracked *.sh/*.bash/*.bats
file (was lib/scripts/common only). Fix or pragma every finding this
surfaced:

- SC2016 (34x): a same-line-preceding disable, all deliberate literal
  ${...} written into a generated compose.yaml/Dockerfile/TS file or
  matched against one, never meant to expand in this shell.
- SC2015 (5x): disabled in splice guards (`grep && grep || die`) β€”
  die firing when any grep fails is the intended behaviour.
- SC1003 (3x): disabled alongside SC2016 in a Dockerfile RUN block
  where the trailing backslashes are literal line continuations.
- SC2154 (2x): disabled in tests/helpers/setup.bash's assert_ok β€”
  status/output are bats' own run-captured variables.
- SC1090 (3x): `# shellcheck source=/dev/null` on tests/service.bats'
  dynamic driver sources, matching the convention services/*/drivers
  already use.
- SC2031/SC2167 (6x): disabled β€” tests/service.bats sources
  lib/service.sh, whose functions reuse the loop variable names
  `driver`/`service`; shellcheck's merged-scope analysis flags them
  even though they're read-only here.
- SC2034: removed an unused `row` local in tests/wizard.bats.
- SC2164: guarded `cd` in tests/install.bats' setup.
- SC2005: dropped a useless `echo $(cat ...)` in tests/publish.bats.
- SC2317 (5x): tests/.shellcheckrc disables it for tests/ only β€”
  shellcheck parses a .bats file's @test blocks as one flat script,
  so a `return` at the end of one marks every later @test unreachable.

shfmt 3.14.1 is pinned in [tools] here too (mise.lock records it) so it
is available for the next commit, which widens the lint task to run it
and reformats the tree β€” kept separate so this commit stays pure
shellcheck content, since the pre-commit hook lints the whole tree at
each commit and the two checks can't both go green until shfmt has run.

No behaviour change: mise run test-unit (196/196) passes unchanged.
git ls-files -- scaffold '*.sh' '*.bash' '*.bats' | xargs shfmt -i 2 -ci -w
across the whole tree, and widen mise.toml's lint task with the matching
shfmt -d line so this is enforced going forward. Layout only β€” git diff -w
still shows changes because shfmt moves `\`-continued && / || onto the
trailing end of the previous line and expands one-liners like
`local x; x="$(...)"` onto two lines, not because meaning changed.

mise run lint and mise run test-runner (265/265: 196 unit + 69 integration)
both pass.
@ttncode
ttncode merged commit 6c2feac into main Sep 16, 2026
21 checks passed
@ttncode
ttncode deleted the chore/shell-tooling branch September 16, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant