Skip to content

style(scripts): format shell scripts and fix shellcheck findings - #452

Merged
DevSecNinja merged 1 commit into
mainfrom
steward/shell-lint
Nov 16, 2026
Merged

DevSecNinja merged 1 commit into
mainfrom
steward/shell-lint

Conversation

@DevSecNinja

@DevSecNinja DevSecNinja commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

The config-sync PR #450 brings in the central .shellcheckrc (all optional checks, style severity) and an .editorconfig with [*.sh] indent_size = 4. Under them, lint / shellcheck and lint / shfmt fail on the scripts already on main. This PR makes the scripts pass, with no change in behaviour.

What changed:

  • shfmt 3.14.1: all 21 *.sh files reformatted from tabs to 4 spaces under the new .editorconfig. Whitespace only.
  • shellcheck 0.11.0 autofixes: SC2250 ($VAR to ${VAR}) in 15 scripts and one SC2248 ([ $elapsed -lt ... to [ "${elapsed}" -lt ...) in wait-for-healthy.sh.
  • SC2312 (masked return values), handled so failures behave as before:
    • wait-for-healthy.sh: the docker inspect status moves into health_status=... || true, so a missing container still means "keep waiting".
    • setup.sh: python3 --version is captured with || true, then cut reads it from a here-string.
    • download-search-index.sh: the timestamp moves into generated_at=... || true ahead of the heredoc.
    • test-index-now.sh, test-integration.sh: timeout is expected to stop index-now with a non-zero exit and only grep's result matters, so these two get a # shellcheck disable=SC2312 with that reason.
  • .editorconfig and .shellcheckrc: byte-identical to chore: sync config files from central repo #450, so this PR's own lint run enforces the result. chore: sync config files from central repo #450 then no longer changes them.

Checked locally on downloaded copies (no clone): shellcheck 0.11.0 and shfmt -d 3.14.1 report nothing, bash -n passes for every script, and a diff that ignores indentation and ${} braces shows only the SC2312 edits above. File modes (755) are unchanged.

Closes #451

Summary by CodeRabbit

  • Bug Fixes
    • Improved resilience in setup and container-health checks when version or health-check commands fail.
    • Search-index fallback generation can continue if the system date command is unavailable.
  • Chores
    • Standardized shell-script formatting and validation settings across development and release workflows.

Reformat every shell script with shfmt 3.14.1 under the central
.editorconfig (4-space indent for *.sh) and apply shellcheck 0.11.0's
autofixes for SC2250/SC2248 under the central .shellcheckrc.

The five SC2312 notes are resolved without changing failure behaviour:
command substitutions whose failure was already masked are split out
with `|| true`, and the two `docker exec ... | grep -q` probes, where
`timeout` is expected to stop index-now, get a justified directive.

Ships the central .editorconfig and .shellcheckrc (identical to the
config-sync PR #450) so this PR's lint run enforces the result.

Closes #451
Copilot AI balanced review requested due to automatic review settings November 16, 2026 10:35
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Shell lint configuration and formatting changed across development, CI, container, and test scripts. Variable expansions are quoted or braced in multiple scripts. Selected commands now tolerate failures while capturing timestamps, health status, or Python version output.

Changes: Shell script updates

Layer / File(s) Summary
Development and application scripts
.editorconfig, .shellcheckrc, .devcontainer/*, backend/entrypoint.sh, setup.sh, start.sh, stop.sh
EditorConfig now defines global and Markdown settings and a shell-specific section. ShellCheck settings were added. Development and application scripts received formatting and variable-expansion updates. setup.sh tolerates a failed Python version command during capture.
Release and version scripts
.github/scripts/check-if-prerelease.sh, .github/scripts/cleanup-containers.sh, .github/scripts/create-github-release.sh, .github/scripts/download-search-index.sh, .github/scripts/extract-version.sh, .github/scripts/publish-db-release.sh, .github/scripts/validate-version.sh
Release and version scripts received formatting or quoting updates. If the search-index download fails, the fallback index is written even if date fails; in that case, generated_at is empty.
Container startup and health checks
.github/scripts/cleanup-containers.sh, .github/scripts/start-backend-container.sh, .github/scripts/start-container.sh, .github/scripts/start-integration-containers.sh, .github/scripts/wait-for-healthy.sh
Container scripts received formatting and quoting updates. If docker inspect fails during health polling, the loop continues to the next poll.
API and integration test scripts
.github/scripts/test-backend-api.sh, .github/scripts/test-frontend.sh, .github/scripts/test-index-now.sh, .github/scripts/test-integration.sh
Test scripts received variable-expansion updates. Comments and ShellCheck suppressions describe the timeout and pipeline checks; endpoint conditions and failure outcomes remain unchanged.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Other · Severity of issue fixed: Low

Suggested reviewers: copilot

Merge Risk: Minimal · up to 43008

This change reformats shell scripts and applies lint fixes without altering intended behavior. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "style(scripts): format shell scripts and fix shellcheck findings" matches the main change. The PR reformats the shell scripts with shfmt (4-space indentation) and applies the shellcheck fix…
Linked Issues check Passed Directly linked issue [#451] has only coding requirements: (1) reformat every *.sh with shfmt 3.14.1 under the central .editorconfig (4-space indent); (2) apply SC2250 and SC2248 autofixes; (3) re…
Out of Scope Changes check Passed All changed files fall within the scope of #451. They are the 21 *.sh files (including .devcontainer/*.sh and backend/entrypoint.sh, which the issue's 'every *.sh' covers), plus `.editorconfig…
Full details: Title check

Explanation

The title "style(scripts): format shell scripts and fix shellcheck findings" matches the main change. The PR reformats the shell scripts with shfmt (4-space indentation) and applies the shellcheck fixes (SC2250, SC2248, SC2312), as the objectives and file summaries describe. The title names the primary change and does not describe unrelated work.

Full details: Linked Issues check

Explanation

Directly linked issue [#451] has only coding requirements: (1) reformat every *.sh with shfmt 3.14.1 under the central .editorconfig (4-space indent); (2) apply SC2250 and SC2248 autofixes; (3) resolve five SC2312 notes without changing failure behavior; (4) ship the central .editorconfig and .shellcheckrc. The raw summary shows all 21 *.sh files reindented and SC2250 braces and the SC2248 quote applied. .editorconfig sets [*.sh] indent_size = 4, and .shellcheckrc at head enables check-extra-masked-returns (SC2312), quote-safe-variables (SC2248), and require-variable-braces (SC2250). Read at head, wait-for-healthy.sh moves the docker inspect call into health_status=... || true, so a missing container still leads to the polling loop. Read at head, test-integration.sh adds # shellcheck disable=SC2312 with a reason for the timeout ... | grep -q pipeline. This matches the issue's allowed resolution. The setup.sh, download-search-index.sh, and other scripts were not read individually. Their behavior is supported only by the summary and the author's local checks, which were not re-run.

Full details: Out of Scope Changes check

Explanation

All changed files fall within the scope of #451. They are the 21 *.sh files (including .devcontainer/*.sh and backend/entrypoint.sh, which the issue's 'every *.sh' covers), plus .editorconfig and .shellcheckrc. Summaries describe whitespace-only changes, quoting or brace additions, || true guards for SC2312, and one suppression comment. None adds unrelated features or alters endpoint checks, exit codes, or Docker arguments. The summary states that start-container.sh leaves ADDITIONAL_ARGS unquoted, which is pre-existing behavior and not a new change. Residual uncertainty: the per-file summaries were not checked against the full diff, so a diff-level check of behavior was not performed.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2aa3d2ee-246a-485d-ab6b-90081b7d7628
Commits

Reviewing files that changed from the base of the PR and between 9bf8f3c and 4300838.

Files selected for processing: 23

  • .devcontainer/post-create.sh
  • .devcontainer/post-start.sh
  • .editorconfig
  • .github/scripts/check-if-prerelease.sh
  • .github/scripts/cleanup-containers.sh
  • .github/scripts/create-github-release.sh
  • .github/scripts/download-search-index.sh
  • .github/scripts/extract-version.sh
  • .github/scripts/publish-db-release.sh
  • .github/scripts/start-backend-container.sh
  • .github/scripts/start-container.sh
  • .github/scripts/start-integration-containers.sh
  • .github/scripts/test-backend-api.sh
  • .github/scripts/test-frontend.sh
  • .github/scripts/test-index-now.sh
  • .github/scripts/test-integration.sh
  • .github/scripts/validate-version.sh
  • .github/scripts/wait-for-healthy.sh
  • .shellcheckrc
  • backend/entrypoint.sh
  • setup.sh
  • start.sh
  • stop.sh

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the shell-script formatting and lint-configuration updates.

No open issues 🎉

What changed in this PR

Aligns hadiscover’s development and CI shell scripts with the central lint configuration from #450, addressing #451 while preserving existing failure-handling behavior.

Changes:

  • Reformats all 21 shell scripts to four-space indentation and standardizes variable braces and quoting.
  • Resolves masked-return warnings through explicit failure handling or documented ShellCheck suppressions.
  • Adds the central ShellCheck configuration and updates EditorConfig to enforce consistent formatting.
File Description
stop.sh Standardizes indentation and variable braces.
start.sh Formats conditionals and braces PID references.
setup.sh Formats setup steps and separates Python version capture.
backend/​entrypoint.sh Reformats startup branches.
.shellcheckrc Enables style-level reporting and optional checks.
.github/​scripts/​wait-for-healthy.sh Quotes the counter and preserves waiting after inspect failures.
.github/​scripts/​validate-version.sh Formats validation and braces variable references.
.github/​scripts/​test-integration.sh Formats checks and documents the timeout-pipeline suppression.
.github/​scripts/​test-index-now.sh Formats checks and documents the timeout-pipeline suppression.
.github/​scripts/​test-frontend.sh Standardizes formatting and response-variable references.
.github/​scripts/​test-backend-api.sh Standardizes formatting and response-variable references.
.github/​scripts/​start-integration-containers.sh Formats argument validation and container startup.
.github/​scripts/​start-container.sh Standardizes indentation and variable braces.
.github/​scripts/​start-backend-container.sh Formats validation and Docker arguments.
.github/​scripts/​publish-db-release.sh Reformats release checks and publishing commands.
.github/​scripts/​extract-version.sh Formats version-selection branches and variable references.
.github/​scripts/​download-search-index.sh Extracts timestamp capture while preserving failure tolerance.
.github/​scripts/​create-github-release.sh Reformats release commands and argument arrays.
.github/​scripts/​cleanup-containers.sh Reformats validation and cleanup loop.
.github/​scripts/​check-if-prerelease.sh Formats prerelease detection and variable references.
.editorconfig Sets global formatting defaults and four-space shell indentation.
.devcontainer/​post-start.sh Reformats frontend startup-status branches.
.devcontainer/​post-create.sh Formats environment setup and braces the Codespace variable.

Review effort: Balanced

@DevSecNinja
DevSecNinja merged commit 5b92ab2 into main Nov 16, 2026
27 checks passed
@DevSecNinja
DevSecNinja deleted the steward/shell-lint branch November 16, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: shell scripts fail shellcheck and shfmt under the central lint config

2 participants