repo: refactor using LATE, Ollama, and Qwen 3.6 #30
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "pr-refactor-using-late-and-qwen"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Tested refactoring for best practices, code quality, etc using
all local (no cloud) tools: L.A.T.E., Ollama, and Qwen 3.6
A.I. Generated Summary:
Fixed pipeline subshell return bug
( tests/hyperstickler/check_formalities.sh )
The git rev-list ... | { while ... done; return "$FAIL"; }
pipeline was broken because the { ... } block runs in a
subshell — changes to FAIL were lost.
Fixed: Replaced the pipeline with while ... done
< <(git rev-list ...) using process substitution so everything
runs in the same shell.
Fixed check_duplicate_sob fragile sed pattern
( tests/git-hooks/commit-msg )
Original grep | sort | uniq -c | sed -e '/^[ \t]*1[ \t]/d'
was fragile and depended on exact sed regex syntax.
Fixed: Replaced with grep -c '^Signed-off-by:' "$1" and
grep '^Signed-off-by:' "$1" | sort -u | wc -l for reliable
comparison.
Removed clear from CI/dev wrapper scripts (
tests/ci/ci-wrapper.sh , tests/scripts/dev-wrapper.sh )
clear produces ANSI escape sequences that corrupt TAP output
in CI environments.
Removed erroneous unstash_after_hook_check call
( tests/git-hooks/commit-msg )
The commit-msg hook never called stash_before_hook_check , so
calling unstash_after_hook_check was a no-op and a code smell.
Changed GITLEAKS_BASELINE="error" to GITLEAKS_BASELINE=""
( tests/git-hooks/commit-msg )
The "pre-commit" comment was misleading (this is commit-msg,
not pre-commit). The gitleaks baseline was being set to "error"
which could cause unexpected warnings.
Removed --no-git flag from check_gitleak
( tests/scripts/check-worktree.sh )
--no-git tells gitleaks to ignore git entirely and scan all
files — wrong for a pre-commit hook which should only scan
staged/changed files.
Fixed echo → printf '%s\n' in helper functions
( tests/common.sh )
echo can interpret -n , -e , and backslash sequences as
arguments or escape sequences. Fixed in 6 output functions
( output_pass , output_warn , output_fail , output_skip ,
output_raw , and check_files_fail ).
Fixed stash_before_hook_check and unstash_after_hook_check
( tests/common.sh )
Added || true to stash_before_hook_check to prevent set -e
abort on stash failure. Made unstash_after_hook_check use a safe
pattern with || true .
Fixed dependency iteration in check-depends.sh
Changed for dep in $(<"$1") to while IFS= read -r dep;
do ... done <"$1" to handle dependencies with spaces.
Added resolve_script_dir helper ( tests/common.sh ) and simplified
ALL path resolution across all scripts:
Before: Nested realpath -m "$(realpath -m "$(dirname
"$(realpath -m "$0")")")/" chains that were unreadable and fragile.
After: Single _SOURCE_DIR="$(realpath -m -- "$0")"
\n _SOURCE_DIR="${_SOURCE_DIR%/*}" pattern, then
$(_SOURCE_DIR)/../common.sh etc.
Added resolve_script_dir helper ( tests/common.sh ) and simplified
ALL path resolution across all scripts:
Before: Nested realpath -m "$(realpath -m "$(dirname
"$(realpath -m "$0")")")/" chains that were unreadable and fragile.
After: Single _SOURCE_DIR="$(realpath -m -- "$0")" \n
_SOURCE_DIR="${_SOURCE_DIR%/*}" pattern, then
$(_SOURCE_DIR)/../common.sh etc.
Standardized set -o pipefail → set -e ordering across all
scripts (pipefail BEFORE errexit is best practice).
Removed redundant bash version check from check_formalities.sh
(already present in common.sh which is sourced first).
Removed misleading comment from commit-msg hook about
"pre-commit" gitleaks.
Fixed output_header to use printf instead of heredoc with
variable interpolation.
Non-ASCII filename check
Whitespace error check
Sorted file check
Shellcheck check
shfmt check
JSON validity check
JSON prettification check
Spelling check
Markdown formatting check
YAML formatting check
Commit subject prefix check
Commit subject case check
Commit subject length checks (soft/warning + hard/fail)
Commit subject no-trailing-period check
Commit message exists check
Commit message line length check
Signed-off-by match check
Branch check
Cherry-pick check
Merge commit check
Author/committer name format check
Author/committer email format check
Gitlint check
Duplicate SoB check
Subject-body separator check
Secrets detection (gitleaks)
Daniel: The results were not perfect and required some hand editing,
but appears to have generated mostly useful results.
Signed-off-by: Daniel F. Dickinson dfdpublic@wildtechgarden.ca
Tested refactoring for best practices, code quality, etc using all local (no cloud) tools: L.A.T.E., Ollama, and Qwen 3.6 A.I. Generated Summary: 1. Fixed pipeline subshell return bug ( tests/hyperstickler/check_formalities.sh ) The git rev-list ... | { while ... done; return "$FAIL"; } pipeline was broken because the { ... } block runs in a subshell — changes to FAIL were lost. Fixed: Replaced the pipeline with while ... done < <(git rev-list ...) using process substitution so everything runs in the same shell. 2. Fixed check_duplicate_sob fragile sed pattern ( tests/git-hooks/commit-msg ) Original grep | sort | uniq -c | sed -e '/^[ \t]*1[ \t]/d' was fragile and depended on exact sed regex syntax. Fixed: Replaced with grep -c '^Signed-off-by:' "$1" and grep '^Signed-off-by:' "$1" | sort -u | wc -l for reliable comparison. 3. Removed clear from CI/dev wrapper scripts ( tests/ci/ci-wrapper.sh , tests/scripts/dev-wrapper.sh ) clear produces ANSI escape sequences that corrupt TAP output in CI environments. 4. Removed erroneous unstash_after_hook_check call ( tests/git-hooks/commit-msg ) The commit-msg hook never called stash_before_hook_check , so calling unstash_after_hook_check was a no-op and a code smell. 5. Changed GITLEAKS_BASELINE="error" to GITLEAKS_BASELINE="" ( tests/git-hooks/commit-msg ) The "pre-commit" comment was misleading (this is commit-msg, not pre-commit). The gitleaks baseline was being set to "error" which could cause unexpected warnings. 6. Removed --no-git flag from check_gitleak ( tests/scripts/check-worktree.sh ) --no-git tells gitleaks to ignore git entirely and scan all files — wrong for a pre-commit hook which should only scan staged/changed files. 7. Fixed echo → printf '%s\n' in helper functions ( tests/common.sh ) echo can interpret -n , -e , and backslash sequences as arguments or escape sequences. Fixed in 6 output functions ( output_pass , output_warn , output_fail , output_skip , output_raw , and check_files_fail ). 8. Fixed stash_before_hook_check and unstash_after_hook_check ( tests/common.sh ) Added || true to stash_before_hook_check to prevent set -e abort on stash failure. Made unstash_after_hook_check use a safe pattern with || true . 9. Fixed dependency iteration in check-depends.sh Changed for dep in $(<"$1") to while IFS= read -r dep; do ... done <"$1" to handle dependencies with spaces. Added resolve_script_dir helper ( tests/common.sh ) and simplified ALL path resolution across all scripts: Before: Nested realpath -m "$(realpath -m "$(dirname "$(realpath -m "$0")")")/" chains that were unreadable and fragile. After: Single _SOURCE_DIR="$(realpath -m -- "$0")" \n _SOURCE_DIR="${_SOURCE_DIR%/*}" pattern, then $(_SOURCE_DIR)/../common.sh etc. Added resolve_script_dir helper ( tests/common.sh ) and simplified ALL path resolution across all scripts: Before: Nested realpath -m "$(realpath -m "$(dirname "$(realpath -m "$0")")")/" chains that were unreadable and fragile. After: Single _SOURCE_DIR="$(realpath -m -- "$0")" \n _SOURCE_DIR="${_SOURCE_DIR%/*}" pattern, then $(_SOURCE_DIR)/../common.sh etc. 10. Standardized set -o pipefail → set -e ordering across all scripts (pipefail BEFORE errexit is best practice). 11. Removed redundant bash version check from check_formalities.sh (already present in common.sh which is sourced first). 12. Removed misleading comment from commit-msg hook about "pre-commit" gitleaks. 13. Fixed output_header to use printf instead of heredoc with variable interpolation. Non-ASCII filename check Whitespace error check Sorted file check Shellcheck check shfmt check JSON validity check JSON prettification check Spelling check Markdown formatting check YAML formatting check Commit subject prefix check Commit subject case check Commit subject length checks (soft/warning + hard/fail) Commit subject no-trailing-period check Commit message exists check Commit message line length check Signed-off-by match check Branch check Cherry-pick check Merge commit check Author/committer name format check Author/committer email format check Gitlint check Duplicate SoB check Subject-body separator check Secrets detection (gitleaks) Daniel: The results were not perfect and required some hand editing, but appears to have generated mostly useful results. Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>