Skip to content

setup.sh: SonarCloud's 7 S7688 ([ vs [[) and 8 S131 (case default) reliability findings #113

Closed

Description

@brettheap

Lane: openreposhape-2 (openRepoShape-2)

What is wrong. SonarCloud's reliability and maintainability gates on
main (cd57c4b) carry fifteen findings against setup.sh, all in the
argument-scanning and self-bootstrap code added for #39/#50/#63:

  • shelldre:S7688 ("Use [[ instead of [ for conditional tests"), 7
    occurrences — two tests on one line: line 88
    ([ -n "$toplevel" ], [ -f "$toplevel/scaffold-project.py" ]), then one
    each at line 89 ([ -f "$toplevel/contracts/repository-naming.yaml" ]),
    163 ([ "${#SHAPE_REF}" -gt 255 ]), 179
    ([ "$KEEP_SHAPE_CHECKOUT" -eq 1 ]), 193 ([ -n "$SHAPE_REF" ]) and 198
    ([ -n "$SHAPE_REF" ]).
  • shelldre:S131 ("Add a default case (*) to handle unexpected values"),
    8 occurrences, one per case that has no *) arm: lines 51 (uname -s
    dispatch for $MAC_TOOLS), 125 ($SHAPE_REPO bad-value guard), 142, 143
    and 144 (the three one-line cases scanning $@ for --,
    --shape-ref's value and --keep-shape-checkout), 166 ($SHAPE_REF
    control-character guard), 169 ($SHAPE_REF charset guard) and 192
    ($SHAPE_REPO scheme check that decides whether --depth 1 is added).

These are the repository's only RELIABILITY findings; everything else on the
gate today is on other files. setup.sh's own shebang is #!/usr/bin/env bash, every entry point that runs it does so with bash explicitly
(bash -s -- in the one-liner, ["bash", str(SETUP), ...] in
tests/test_setup_sh.py, /bin/bash -n setup.sh in
.github/workflows/tests.yml), and the file already uses bash-only syntax
(arrays: CLONE_SHAPE_CMD=(git clone --quiet) / += / [@], and
BASH_SOURCE) — so [[ is available everywhere this script runs. The
"POSIX shell script" phrasing in tests/test_setup_sh.py and
tests/conftest.py is contrasting a Unix shell/shebang execution model
against Windows' CreateProcess (which cannot run a shebang at all), not
claiming /bin/sh(dash) compatibility — README.md's "What setup.sh does"
and the macOS CI step both say the constraint is bash 3.2 syntax, not POSIX
sh.

What would fix it. Convert each flagged [ … ] to [[ … ]] with
identical semantics (all seven are unary -n/-f/-eq/-gttests — no=/==/!=string comparison and no-a/-oin any of them, so nothing needs quoting-as-a-glob-pattern care or operator translation). For eachcaselacking), add ) ;;— every one of the eight is a guard or a scan where "no match" is the common, already-correct outcome (an unenumerateduname -s, an argument that is not the flag being scanned for, a $SHAPE_REPO/$SHAPE_REFvalue that is already well-formed) rather than a programming error, so a silent no-op with a short comment is the honest default, not adie`. No existing branch's behavior changes.

Activity

  1. brettheap commented on Sep 11, 2026

    @brettheap
    ContributorAuthor

    (lane openreposhape-2 (openRepoShape-2), 2026-09-11T20:13Z) CLAIMED — session 3b1ab8cf, on Brett Heap's word 'go, fan out on all of it'. Branch fix/setup-sh-double-bracket-and-case-defaults, worktree ~/projects/openRepoShape--setup-sh-hygiene on Eagle, from origin/main cd57c4b. Scope: convert setup.sh's 7 S7688 [ tests to [[ and add *) ;; defaults to its 8 S131 case statements, semantics unchanged.

  2. brettheap commented on Sep 11, 2026

    @brettheap
    ContributorAuthor

    (lane openreposhape-2 (openRepoShape-2), 2026-09-11T20:24Z) PULL REQUEST OPEN: #117 (head 11e1e3f).

  3. brettheap commented on Sep 11, 2026

    @brettheap
    ContributorAuthor

    (lane openreposhape-2 (openRepoShape-2), 2026-09-11T20:39:55Z) MERGED — #117 → 9923fea (squash), on Brett Heap's word 'go, fan out on all of it, hold the doctor refactor'. setup.sh: the seven SonarCloud S7688 '[' tests become '[[' (all unary -n/-f/-eq/-gt, quoting untouched; the file is bash-only by shebang, one-liner and CI, nothing claims sh) and the eight S131 bare case statements gain a '*) ;;' default with a one-line reason, no branch behaviour changed; only setup.sh touched; bash -n clean, shellcheck identical before/after, test_setup_sh.py 38 passed; Copilot 'Approval recommended' with 0 findings; suite 984 passed / 1 known machine-dependent flake / 1 skipped. Object complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions