Skip to content

perf(shellcheck): batch pre-commit script checks - #247

Merged
dpc merged 1 commit into
masterfrom
dpc/jj-swkkprputqom
Jul 24, 2026
Merged

perf(shellcheck): batch pre-commit script checks#247
dpc merged 1 commit into
masterfrom
dpc/jj-swkkprputqom

Conversation

@dpc

@dpc dpc commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Posted by Tau

Summary

Batch generated pre-commit ShellCheck work into one process while preserving the existing tracked-text script selection, severity, output, and failure behavior.

Details

The generated check reads the existing newline-delimited FLAKEBOX_GIT_LS_TEXT into a quoted Bash array, selects .sh suffixes, and invokes shellcheck --severity=warning once with all matching paths. Zero matching scripts remains a successful no-op. Spaces and glob characters remain literal within the current file-list representation.

Generated-hook tests use a fake ShellCheck to prove zero invocations for zero scripts, exactly one invocation and exact argv for multiple scripts, and hook failure when ShellCheck fails. A matching untracked pathname makes the glob-safety assertion structural rather than timing-based.

### Summary

Run ShellCheck once for all matching tracked text scripts instead of starting one process per file. Preserve the existing severity, file-list membership, output, and failure behavior while making the empty-script case an explicit no-op. Add structural generated-hook coverage for invocation count and argument safety.

### Details

Build a Bash array by reading the existing newline-delimited `FLAKEBOX_GIT_LS_TEXT` representation and selecting `.sh` suffixes. Quoted array expansion preserves spaces and glob characters, then passes `--severity=warning` and all paths to one ShellCheck process. This intentionally does not redesign the generic file-list representation, add NUL transport, or add ARG_MAX chunking.

Use a fake ShellCheck in the generated-hook integration check to prove zero scripts causes no invocation, two scripts cause exactly one invocation with exact argv, and a failing ShellCheck still fails the generated hook. An untracked path matching a tracked literal bracket expression makes unsafe pathname expansion fail the test. Regenerate the checked-in pre-commit artifact and Flakebox root identity.

### Reviews

An independent review found that the initial bracketed-path fixture had no matching directory entry and therefore could not detect unsafe pathname expansion. The strengthened fixture adds an untracked matching path while tracking the bracketed name with literal Git pathspec semantics. Follow-up review passed with no findings.

### Validation

- `nix develop -c treefmt`
- focused `gitHooks` Nix check
- `nix develop -c selfci check`
- `nix develop -c selfci check --candidate swkkprpu`
@dpc
dpc marked this pull request as ready for review July 24, 2026 23:21
@dpc
dpc merged commit 3f214f8 into master Jul 24, 2026
4 checks passed
@dpc
dpc deleted the dpc/jj-swkkprputqom branch July 24, 2026 23:22
dpc added a commit that referenced this pull request Jul 30, 2026
perf(shellcheck): batch pre-commit script checks
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