mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 20:07:04 +01:00
"Pre-commit checks" has failed on every push since b83ce5d removed
shellcheck's --severity filter. The findings never appeared locally: CI
installs an older shellcheck than this machine, and 0.11.0 no longer emits
SC2002/SC2015/SC2119 at all. Reproduced by fetching shellcheck 0.9.0, which
matches CI's output exactly, and verified against both versions.
SC2015 x6 -- rewrote `A && B || C` as an explicit if. Each keeps its trailing
`|| true`, so a failing side effect still cannot abort the caller under set -e.
The first draft dropped it in run_phone.sh; a review pass caught that and it
was restored, since that call is the last statement of a function.
SC2119 x3 -- require_imagemagick and adb_select_device take an OPTIONAL first
argument, so the bare calls were already correct. Following shellcheck's
literal advice and passing "$@" would forward the script's own arguments as a
tool preference, which would be a real defect. Passing an explicit "" states
the same intent without changing behaviour, confirmed by running both forms.
SC2002 x2 -- `cat FILE | tr ...` becomes `tr ... < FILE`, keeping 2>/dev/null
so a missing file still yields an empty string.
No suppressions, no --severity filter, no exclusions added. Verified: 0
findings under both shellcheck versions, `pre-commit run shellcheck
--all-files` passes, test_adb_common 13/13, test_boot_repair 31/31, 1193
Python tests at 100% coverage.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ReVsw7qovYkkGbqcU9tn7
73 lines
5.0 KiB
JSON
73 lines
5.0 KiB
JSON
{
|
|
"intent": "Turn the 'Pre-commit checks' CI workflow green again. It has failed on every push since b83ce5d (2026-08-03), the commit that removed shellcheck's --severity filter, because CI runs an older shellcheck than the developer machine and reports 11 findings that shellcheck 0.11.0 no longer emits.",
|
|
"scope": [
|
|
"linux_configuration/scripts/boot_recovery/boot-repair",
|
|
"linux_configuration/scripts/diagnostics/line-speed-probe.sh",
|
|
"linux_configuration/scripts/single_use/features/keepass_sync.sh",
|
|
"linux_configuration/scripts/single_use/utils/{gif_to_square,txt_to_image}.sh",
|
|
"phone_focus_mode/{curfew_enforcer,hosts_enforcer,run_phone}.sh",
|
|
"phone_focus_mode/lib/tests/test_adb_common.sh",
|
|
"Non-goal: changing any script's behaviour -- every fix is semantics-preserving",
|
|
"Non-goal: suppressing findings via directives or a --severity filter",
|
|
"Non-goal: third_party/, which the shellcheck hook already excludes as vendored code"
|
|
],
|
|
"changes": [
|
|
"SC2015 x6: rewrote 'A && B || C' as an explicit if-statement in boot-repair, line-speed-probe.sh, keepass_sync.sh, curfew_enforcer.sh (x2) and run_phone.sh. Each retains its trailing '|| true' so a failing side effect still cannot abort the caller under set -e.",
|
|
"SC2119 x3: require_imagemagick and adb_select_device both take an OPTIONAL first argument, so the bare calls were correct. Passing \"$@\" as shellcheck suggests would forward the script's own arguments as a tool preference, which would be a defect; passing an explicit \"\" states the same intent without changing behaviour.",
|
|
"SC2002 x2: replaced 'cat FILE | tr ...' with 'tr ... < FILE' in hosts_enforcer.sh, keeping 2>/dev/null so a missing file still yields an empty string.",
|
|
"Kept '|| true' on the _info call in run_phone.sh: it is the last statement of a function under set -e, so dropping it (as the first draft of this change did) would let a failed write to stderr abort the caller."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "shellcheck-v0.9.0 -- <each of the 9 files> # version-matched to CI",
|
|
"result": "pass",
|
|
"evidence": "All 9 report OK. Before the change the same binary reproduced CI exactly: 6x SC2015, 3x SC2119, 2x SC2002. A full-repo scan under 0.9.0 leaves findings only in third_party/agent-skills/, which the hook excludes via '^third_party/'."
|
|
},
|
|
{
|
|
"command": "pre-commit run shellcheck --all-files",
|
|
"result": "pass",
|
|
"evidence": "shellcheck...Passed over the whole repository."
|
|
},
|
|
{
|
|
"command": "bash phone_focus_mode/lib/tests/test_adb_common.sh",
|
|
"result": "pass",
|
|
"evidence": "Results: 13 passed, 0 failed."
|
|
},
|
|
{
|
|
"command": "bash linux_configuration/scripts/boot_recovery/tests/test_boot_repair.sh",
|
|
"result": "pass",
|
|
"evidence": "31 passed, 0 failed."
|
|
},
|
|
{
|
|
"command": "behavioural equivalence check for require_imagemagick",
|
|
"result": "pass",
|
|
"evidence": "Sourcing lib/common.sh and calling both forms: require_imagemagick \"\" -> OK, MAGICK_CMD=magick; bare require_imagemagick -> OK, MAGICK_CMD=magick. Identical result."
|
|
},
|
|
{
|
|
"command": "behavioural equivalence check for the useless-cat rewrite",
|
|
"result": "pass",
|
|
"evidence": "Against a file containing ' 1 ': old 'cat F | tr -d [:space:]' -> [1]; new 'tr -d [:space:] < F' -> [1]. Against a nonexistent path the new form still yields [] with the error suppressed."
|
|
},
|
|
{
|
|
"command": "bash -n on all 8 edited executable scripts",
|
|
"result": "pass",
|
|
"evidence": "All report syntax OK."
|
|
},
|
|
{
|
|
"command": "bash ~/.claude/scripts/finish.sh gate ~/testsAndMisc <9 files>",
|
|
"result": "pass",
|
|
"evidence": "FINISH_GATE {\"risk\":\"review\",\"changed_files\":9,\"phase\":\"ok\"} with 1193 Python tests passing at 100% coverage. The review pass flagged the dropped '|| true' in run_phone.sh, which was then restored."
|
|
}
|
|
],
|
|
"risks": [
|
|
"The underlying local/CI divergence remains: CI installs a different shellcheck version than the developer machine, so a future finding can again pass locally and fail in CI. Pinning the version in the workflow would remove the class of problem; that was considered and deferred as a separate change.",
|
|
"These files were not otherwise exercised end-to-end. curfew_enforcer.sh and hosts_enforcer.sh run on the phone under Magisk and were verified by static analysis, syntax check and unit tests rather than a device run.",
|
|
"keepass_sync.sh's case arm is now a single-line if-then-fi, which is denser to read than the original; behaviour is unchanged."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; each change is confined to one or two lines per file and no interfaces changed.",
|
|
"After reverting, expect 'Pre-commit checks' CI to go red again on the same 11 findings while local shellcheck 0.11.0 continues to report none.",
|
|
"Re-run pre-commit run shellcheck --all-files plus the phone_focus_mode and boot_recovery test suites to confirm the revert left both in their prior state."
|
|
]
|
|
}
|