You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolve the 4 shelldre:S7682 findings ("Add an explicit return statement at the end of the function") by adding explicit return statements to the shell functions that currently contain none — a behavior-preserving hygiene change.
Analysis
S7682 fires on functions that contain no explicit return statement anywhere. Matching the reported counts:
scripts/apply-repo-settings.test.sh (3): pass, fail, assert_eq — none contain a return.
scripts/apply-repo-settings.sh (1): apply_security_and_analysis — the only main-script function with no return. The other three (resolve_repo, auto_trigger_status, apply_check_suite_prefs) already contain return statements and are compliant.
Implementation Checklist
scripts/apply-repo-settings.sh — add bare return at end of apply_security_and_analysis (bare return propagates the gh api exit status, preserving set -e behavior in main)
scripts/apply-repo-settings.test.sh — add explicit return at end of pass, fail, assert_eq
Tests to Write
No new tests. This is a behavior-preserving refactor (no observable behavior change), so the Phase 2 TDD exception applies. The existing unit tests in apply-repo-settings.test.sh will be run to confirm no regression.
Test Command
bash scripts/apply-repo-settings.test.sh plus bash .dev-lead/scripts/dev-lead-lint.sh
Analyzed the 4 shelldre:S7682 findings — the rule fires on functions containing no explicit return statement. Identified the exact functions: apply_security_and_analysis (main, 1) and pass/fail/assert_eq (test, 3).
Added a bare return at the end of apply_security_and_analysis in scripts/apply-repo-settings.sh.
Added an explicit return at the end of pass, fail, and assert_eq in scripts/apply-repo-settings.test.sh.
Verified unit tests, dev-lead-lint.sh, and shellcheck all pass.
Rubber-duck review of full diff — behavior preserved, only the non-compliant functions touched.
Why bare return (behavior-preserving)
A bare return returns the exit status of the last command executed in the function. For apply_security_and_analysis this propagates the gh api exit status, exactly matching the prior implicit return so set -euo pipefail in main still aborts on API failure. The three test helpers likewise keep their last-command status, so no test outcome changes.
Test Results
ok - auto_trigger_status: enabled app -> true
ok - auto_trigger_status: disabled app -> false
ok - auto_trigger_status: app absent -> missing
ok - auto_trigger_status: empty list -> missing
ok - auto_trigger_status: empty string -> missing
ok - resolve_repo: bare name -> org/name
ok - resolve_repo: owner/repo passthrough
ok - resolve_repo: GITHUB_REPOSITORY fallback
ok - resolve_repo: REPO env fallback
All tests passed.
---LINT---
[lint] shellcheck on 3 file(s)...
[lint] validating CODEOWNERS...
OK: CODEOWNERS
[lint] all checks passed
shellcheck clean
Files Changed
scripts/apply-repo-settings.sh: added return at the end of apply_security_and_analysis (1 finding).
scripts/apply-repo-settings.test.sh: added return at the end of pass, fail, assert_eq (3 findings).
Notes
TDD Phase 2 exception: This is a behavior-preserving hygiene refactor with no observable behavior change, so no new tests were written. The existing unit tests were run before and after and remain green.
The other main-script functions (resolve_repo, auto_trigger_status, apply_check_suite_prefs) already contain return statements and were left untouched — consistent with the finding count of 1 for apply-repo-settings.sh.
No NOSONAR suppressions used; all fixes are real explicit returns.
Resolve 5 SonarCloud shell findings (behavior-preserving): define a constant for the duplicated 'missing' literal in apply-repo-settings.sh (S1192) and add explicit return statements to the helper functions in apply-repo-settings.test.sh (S7682).
Implementation Checklist
scripts/apply-repo-settings.sh — add readonly STATUS_MISSING='missing' and replace all 6 code occurrences of the literal (2× printf, 1× case pattern, 3× inside jq programs threaded via --arg missing)
scripts/apply-repo-settings.test.sh — add an explicit return 0 at the end of pass(), fail(), and assert_eq()
Tests to Write
No new tests — this is a behavior-preserving refactor. The existing portable test suite (scripts/apply-repo-settings.test.sh, 15 assertions) is the regression guard and must stay green (asserts the "missing" sentinel is unchanged).
Test Command
bash scripts/apply-repo-settings.test.sh (plus bash .dev-lead/scripts/dev-lead-lint.sh for shellcheck)
scripts/apply-repo-settings.sh — S1192: added readonly STATUS_MISSING='missing' and replaced all 6 code occurrences of the literal (2× printf, 1× case pattern, 3× inside jq via --arg missing). The literal now appears exactly once (the constant definition).
scripts/apply-repo-settings.test.sh — S7682: added explicit return 0 to pass(), fail(), and assert_eq().
Test Results
$ bash scripts/apply-repo-settings.test.sh
ok - auto_trigger_status: enabled app -> true
ok - auto_trigger_status: disabled app -> false
ok - auto_trigger_status: app absent -> missing
ok - auto_trigger_status: empty list -> missing
ok - auto_trigger_status: empty string -> missing
ok - pr_quality_merge_methods_status: squash-only -> squash
ok - pr_quality_merge_methods_status: drifted -> merge,rebase,squash
ok - pr_quality_merge_methods_status: unsorted input is sorted
ok - pr_quality_merge_methods_status: no pull_request rule -> missing
ok - pr_quality_merge_methods_status: rule without methods -> missing
ok - pr_quality_merge_methods_status: empty string -> missing
ok - resolve_repo: bare name -> org/name
ok - resolve_repo: owner/repo passthrough
ok - resolve_repo: GITHUB_REPOSITORY fallback
ok - resolve_repo: REPO env fallback
All tests passed.
$ shellcheck --severity=warning -x scripts/apply-repo-settings.sh scripts/apply-repo-settings.test.sh
shellcheck: clean
$ bash .dev-lead/scripts/dev-lead-lint.sh
[lint] shellcheck on 5 file(s)...
[lint] validating CODEOWNERS...
OK: CODEOWNERS
[lint] all checks passed
Files Changed
scripts/apply-repo-settings.sh: define STATUS_MISSING constant; use it in the two printf fallbacks, the case pattern, and both jq programs (threaded via --arg missing) — resolves S1192.
scripts/apply-repo-settings.test.sh: explicit return 0 at the end of pass, fail, assert_eq — resolves S7682.
Notes
No behavior change.printf '%s' "$STATUS_MISSING" and the jq $missing arg produce identical output to the former literals; verified the sentinel-emitting paths still return missing and the variable case pattern matches literally (no glob metacharacters). All 15 existing assertions stay green — this is the regression guard.
TDD note: Phase 2 skipped per the behavior-preserving-refactor exception; the existing portable test suite already covers the sentinel behavior and validates equivalence.
S7682 count: the audit reported 4 occurrences, but the test file defines exactly 3 functions (pass, fail, assert_eq) — all three now have explicit returns. No 4th function exists (likely a stale/duplicate count); the next audit scan should confirm zero.
The main-script helper functions (apply_*, status helpers) were intentionally not given blanket return 0 — they end with gh api/jq/printf whose exit status is meaningful, and masking it would be a behavior change. Per the audit breakdown, S7682 does not fire on those.
Resolve 5 SonarCloud shell findings (4× S7682 explicit-return, 1× S1192 duplicated 'missing' literal) with behavior-preserving fixes. Ground-truth from the SonarCloud API refined the exact locations (the issue's file table was slightly off).
S1192 — scripts/apply-repo-settings.test.sh:68: literal "missing" used 6× → extract a constant.
Implementation Checklist
scripts/apply-repo-settings.test.sh: add return 0 to pass, fail, assert_eq
scripts/apply-repo-settings.test.sh: define readonly MISSING='missing' and use it for the 6 expected-value assertions
scripts/apply-repo-settings.sh: add bare return to end of apply_security_and_analysis (preserves gh api exit status under set -e)
Tests to Write
Behavior-preserving refactor: the existing suite scripts/apply-repo-settings.test.sh is the regression guard (15 assertions, currently green). No new behavior to add, so per the protocol's refactor exception no new failing test is written; the suite must stay green before and after.
Resolved all 5 SonarCloud shell findings with behavior-preserving fixes. Note: I pulled the exact finding locations from the SonarCloud issues API — the issue's "Affected files" table was slightly off (it attributed all 4 S7682 to the test file and the S1192 to the main script; in reality S1192 is in the test file at line 68, and one S7682 is in the main script at line 71).
Plan Execution
S1192 — extracted readonly MISSING='missing' in apply-repo-settings.test.sh and used it for all 6 expected-value assertions
S7682 — added return 0 to pass, fail, assert_eq in apply-repo-settings.test.sh
S7682 — added bare return to apply_security_and_analysis in apply-repo-settings.sh (preserves the gh api exit status under set -e; return 0 would have masked failures)
Test Results
$ bash scripts/apply-repo-settings.test.sh
ok - auto_trigger_status: enabled app -> true
ok - auto_trigger_status: disabled app -> false
ok - auto_trigger_status: app absent -> missing
ok - auto_trigger_status: empty list -> missing
ok - auto_trigger_status: empty string -> missing
ok - pr_quality_merge_methods_status: squash-only -> squash
ok - pr_quality_merge_methods_status: drifted -> merge,rebase,squash
ok - pr_quality_merge_methods_status: unsorted input is sorted
ok - pr_quality_merge_methods_status: no pull_request rule -> missing
ok - pr_quality_merge_methods_status: rule without methods -> missing
ok - pr_quality_merge_methods_status: empty string -> missing
ok - resolve_repo: bare name -> org/name
ok - resolve_repo: owner/repo passthrough
ok - resolve_repo: GITHUB_REPOSITORY fallback
ok - resolve_repo: REPO env fallback
All tests passed.
$ bash .dev-lead/scripts/dev-lead-lint.sh
[lint] shellcheck on 5 file(s)...
[lint] validating CODEOWNERS...
OK: CODEOWNERS
[lint] all checks passed
$ shellcheck -x scripts/apply-repo-settings.sh scripts/apply-repo-settings.test.sh
(clean)
Files Changed
scripts/apply-repo-settings.test.sh: added readonly MISSING constant + used it in 6 assertions (S1192); added explicit return 0 to pass/fail/assert_eq (S7682)
scripts/apply-repo-settings.sh: added bare return at the end of apply_security_and_analysis (S7682)
Notes
Behavior-preserving refactor — no observable behavior change. Per the protocol's refactor exception, no new failing test was written; the existing 15-assertion suite is the regression guard and stays green.
The bare return (vs return 0) in apply_security_and_analysis is intentional: it returns $? of the gh api call so a failing API call still aborts main under set -e.
Only the 4 functions SonarCloud actually flagged for S7682 were touched; the other helpers already contain explicit return statements and were not flagged, so they were left unchanged.
Activity
don-petry commentedon Jul 7, 2026
Dev-Lead Implementation Plan
Issue: #349 — SonarCloud: shell script hygiene
Scope
Resolve the 4
shelldre:S7682findings ("Add an explicit return statement at the end of the function") by adding explicitreturnstatements to the shell functions that currently contain none — a behavior-preserving hygiene change.Analysis
S7682 fires on functions that contain no explicit
returnstatement anywhere. Matching the reported counts:scripts/apply-repo-settings.test.sh(3):pass,fail,assert_eq— none contain areturn.scripts/apply-repo-settings.sh(1):apply_security_and_analysis— the only main-script function with noreturn. The other three (resolve_repo,auto_trigger_status,apply_check_suite_prefs) already containreturnstatements and are compliant.Implementation Checklist
scripts/apply-repo-settings.sh— add barereturnat end ofapply_security_and_analysis(barereturnpropagates thegh apiexit status, preservingset -ebehavior inmain)scripts/apply-repo-settings.test.sh— add explicitreturnat end ofpass,fail,assert_eqTests to Write
No new tests. This is a behavior-preserving refactor (no observable behavior change), so the Phase 2 TDD exception applies. The existing unit tests in
apply-repo-settings.test.shwill be run to confirm no regression.Test Command
bash scripts/apply-repo-settings.test.shplusbash .dev-lead/scripts/dev-lead-lint.shdon-petry commentedon Jul 7, 2026
Dev-Lead: Implementation Complete
Plan Execution
shelldre:S7682findings — the rule fires on functions containing no explicitreturnstatement. Identified the exact functions:apply_security_and_analysis(main, 1) andpass/fail/assert_eq(test, 3).returnat the end ofapply_security_and_analysisinscripts/apply-repo-settings.sh.returnat the end ofpass,fail, andassert_eqinscripts/apply-repo-settings.test.sh.dev-lead-lint.sh, andshellcheckall pass.Why bare
return(behavior-preserving)A bare
returnreturns the exit status of the last command executed in the function. Forapply_security_and_analysisthis propagates thegh apiexit status, exactly matching the prior implicit return soset -euo pipefailinmainstill aborts on API failure. The three test helpers likewise keep their last-command status, so no test outcome changes.Test Results
Files Changed
scripts/apply-repo-settings.sh: addedreturnat the end ofapply_security_and_analysis(1 finding).scripts/apply-repo-settings.test.sh: addedreturnat the end ofpass,fail,assert_eq(3 findings).Notes
resolve_repo,auto_trigger_status,apply_check_suite_prefs) already containreturnstatements and were left untouched — consistent with the finding count of 1 forapply-repo-settings.sh.NOSONARsuppressions used; all fixes are real explicit returns.don-petry commentedon Jul 14, 2026
SonarCloud Audit (2026-07-14): still open — 4 finding(s), worst severity
MAJOR.don-petry commentedon Jul 21, 2026
SonarCloud Audit (2026-07-21): still open — 5 finding(s), worst severity
MAJOR.don-petry commentedon Jul 21, 2026
Dev-Lead Implementation Plan
Issue: #349 — SonarCloud: shell script hygiene
Scope
Resolve 5 SonarCloud shell findings (behavior-preserving): define a constant for the duplicated
'missing'literal inapply-repo-settings.sh(S1192) and add explicitreturnstatements to the helper functions inapply-repo-settings.test.sh(S7682).Implementation Checklist
scripts/apply-repo-settings.sh— addreadonly STATUS_MISSING='missing'and replace all 6 code occurrences of the literal (2×printf, 1×casepattern, 3× inside jq programs threaded via--arg missing)scripts/apply-repo-settings.test.sh— add an explicitreturn 0at the end ofpass(),fail(), andassert_eq()Tests to Write
scripts/apply-repo-settings.test.sh, 15 assertions) is the regression guard and must stay green (asserts the"missing"sentinel is unchanged).Test Command
bash scripts/apply-repo-settings.test.sh(plusbash .dev-lead/scripts/dev-lead-lint.shfor shellcheck)don-petry commentedon Jul 21, 2026
Dev-Lead: Implementation Complete
Plan Execution
scripts/apply-repo-settings.sh— S1192: addedreadonly STATUS_MISSING='missing'and replaced all 6 code occurrences of the literal (2×printf, 1×casepattern, 3× inside jq via--arg missing). The literal now appears exactly once (the constant definition).scripts/apply-repo-settings.test.sh— S7682: added explicitreturn 0topass(),fail(), andassert_eq().Test Results
Files Changed
scripts/apply-repo-settings.sh: defineSTATUS_MISSINGconstant; use it in the twoprintffallbacks, thecasepattern, and both jq programs (threaded via--arg missing) — resolves S1192.scripts/apply-repo-settings.test.sh: explicitreturn 0at the end ofpass,fail,assert_eq— resolves S7682.Notes
printf '%s' "$STATUS_MISSING"and the jq$missingarg produce identical output to the former literals; verified the sentinel-emitting paths still returnmissingand the variablecasepattern matches literally (no glob metacharacters). All 15 existing assertions stay green — this is the regression guard.pass,fail,assert_eq) — all three now have explicit returns. No 4th function exists (likely a stale/duplicate count); the next audit scan should confirm zero.apply_*, status helpers) were intentionally not given blanketreturn 0— they end withgh api/jq/printfwhose exit status is meaningful, and masking it would be a behavior change. Per the audit breakdown, S7682 does not fire on those.don-petry commentedon Jul 21, 2026
Dev-Lead Implementation Plan
Issue: #349 — SonarCloud: shell script hygiene
Scope
Resolve 5 SonarCloud shell findings (4× S7682 explicit-return, 1× S1192 duplicated
'missing'literal) with behavior-preserving fixes. Ground-truth from the SonarCloud API refined the exact locations (the issue's file table was slightly off).Exact findings (SonarCloud API)
return:scripts/apply-repo-settings.test.sh:15(pass)scripts/apply-repo-settings.test.sh:19(fail)scripts/apply-repo-settings.test.sh:25(assert_eq)scripts/apply-repo-settings.sh:71(apply_security_and_analysis)scripts/apply-repo-settings.test.sh:68: literal"missing"used 6× → extract a constant.Implementation Checklist
scripts/apply-repo-settings.test.sh: addreturn 0topass,fail,assert_eqscripts/apply-repo-settings.test.sh: definereadonly MISSING='missing'and use it for the 6 expected-value assertionsscripts/apply-repo-settings.sh: add barereturnto end ofapply_security_and_analysis(preservesgh apiexit status underset -e)Tests to Write
scripts/apply-repo-settings.test.shis the regression guard (15 assertions, currently green). No new behavior to add, so per the protocol's refactor exception no new failing test is written; the suite must stay green before and after.Test Command
bash scripts/apply-repo-settings.test.sh(plus repo lint:bash .dev-lead/scripts/dev-lead-lint.sh)don-petry commentedon Jul 21, 2026
Dev-Lead: Implementation Complete
Resolved all 5 SonarCloud shell findings with behavior-preserving fixes. Note: I pulled the exact finding locations from the SonarCloud issues API — the issue's "Affected files" table was slightly off (it attributed all 4 S7682 to the test file and the S1192 to the main script; in reality S1192 is in the test file at line 68, and one S7682 is in the main script at line 71).
Plan Execution
readonly MISSING='missing'inapply-repo-settings.test.shand used it for all 6 expected-value assertionsreturn 0topass,fail,assert_eqinapply-repo-settings.test.shreturntoapply_security_and_analysisinapply-repo-settings.sh(preserves thegh apiexit status underset -e;return 0would have masked failures)Test Results
Files Changed
scripts/apply-repo-settings.test.sh: addedreadonly MISSINGconstant + used it in 6 assertions (S1192); added explicitreturn 0topass/fail/assert_eq(S7682)scripts/apply-repo-settings.sh: added barereturnat the end ofapply_security_and_analysis(S7682)Notes
return(vsreturn 0) inapply_security_and_analysisis intentional: it returns$?of thegh apicall so a failing API call still abortsmainunderset -e.returnstatements and were not flagged, so they were left unchanged.don-petry commentedon Jul 28, 2026
SonarCloud Audit (2026-07-28): still open — 5 finding(s), worst severity
MAJOR.feat: implement issue #349 — SonarCloud: shell script hygiene (#396)
feat: implement issue #349 — SonarCloud: shell script hygiene (#396)
feat: implement issue #349 — SonarCloud: shell script hygiene (#396)
feat: implement issue #349 — SonarCloud: shell script hygiene (#396)
feat: implement issue #349 — SonarCloud: shell script hygiene (#396)