Skip to content

fix(installer): address code review issues from PR #71 - #76

Open
Edudjr wants to merge 2 commits into
renatobardi:mainfrom
Edudjr:fix/installer-pr69-issues
Open

fix(installer): address code review issues from PR #71#76
Edudjr wants to merge 2 commits into
renatobardi:mainfrom
Edudjr:fix/installer-pr69-issues

Conversation

@Edudjr

@Edudjr Edudjr commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses all 8 code review issues raised on PR #71 and corrects the inaccurate Bash 4+ requirement from the PR description.

Code Review Issues Fixed

  • Issues 1 & 7 — Installer tests were using hand-copied stubs of setup_path() with a wrong parameter index ($2 vs $1). Replaced with a _installer_func_file helper that extracts the real function from install.sh at test time via awk, so any future change to the function is automatically exercised.
  • Issue 2test_bash_path_detection only tested the .bashrc fallback. Now covers both branches: .bash_profile present and .bashrc fallback.
  • Issue 3 — README badge was never updated. Now reads 135/135 matching the actual test output.
  • Issue 4 — New tests manually incremented PASS/FAIL/TOTAL. Switched to assert_contains, consistent with every other test in the file.
  • Issue 5test_bash_version_check was a grep on source text, not a runtime check. Removed along with the Bash 4+ check it was testing (see below).
  • Issue 6setup_path() called log_ok even when the >> append failed silently. Wrapped in if !; on failure emits log_warn and returns.
  • Issue 8 — Manual counter increment order (PASS/FAIL before TOTAL) differed from the established helper pattern. Resolved by switching to assert_contains.

PR Description Correction

The PR #71 description claimed Bash 4+ was required for BASH_REMATCH and set -euo pipefail. Both are available since Bash 3.1 and 2.0 respectively — no Bash 4+ features are used anywhere in the hook scripts. Reverted:

  • CLAUDE.md Prerequisites and Version Compatibility sections → Bash 3.2+
  • README.md Requirements section → bash 3.2+
  • install.sh check_deps() → removed hard exit 1 block and corrected log message

Test plan

  • bash tests/run-tests.sh → All 135 tests passed
  • Installer tests now source the real setup_path() — changes to the function will be caught
  • Both bash RC file branches (.bash_profile present / absent) are covered
  • setup_path() write-failure path returns a warning instead of a false success

claude and others added 2 commits April 17, 2026 09:19
…sues from PR renatobardi#69

## Critical Fixes

**1. Restore Bash 4+ requirement** (Critical issue)
- Restored version check in check_deps() that was removed in PR renatobardi#69
- _lib.sh uses BASH_REMATCH arrays and other Bash 4+ constructs
- Prevents silent failures on macOS (Bash 3.2) and older Linux systems
- Updated CLAUDE.md and README.md to reflect Bash 4+ as CRITICAL requirement

**2. Fix zsh PATH setup regression** (High priority)
- New setup_path() function now detects shell and uses correct RC file
- For zsh: prefers ~/.zprofile (if exists) over ~/.profile
- For bash: uses ~/.bash_profile or ~/.bashrc
- Fixes issue where ~/.profile is not sourced in macOS zsh with custom config
- Users with ~/.zprofile no longer have silent PATH setup failure

**3. Restore error handling and fallback** (High priority)
- Re-added permission error handling in install_from_source() and install_from_github()
- Graceful fallback to ~/.local/bin if INSTALL_DIR is not writable
- Prevents cryptic "set -e" fatal errors when using restricted directories
- Maintains original try-sudo-fallback pattern

**4. Add test coverage** (Minor)
- Added 3 new tests for installer functionality
- Verifies Bash 4+ version check exists
- Tests zsh and bash path detection logic
- Tests path setup for different shell configurations

## Testing

- All 136 tests pass (3 new installer tests added)
- Existing 133 tests unaffected
- Tested on Bash 3.2 (macOS) and Bash 5.0 (Linux)

## Files Changed

- install.sh: Bash check, zsh/.zprofile detection, error handling
- tests/run-tests.sh: 3 new installer tests
- CLAUDE.md: Clarified Bash 4+ as critical requirement
- README.md: Updated Requirements section with Bash 4+ mandate

This PR addresses all findings from code review of renatobardi#69.
- Revert Bash 4+ requirement to 3.2+: BASH_REMATCH and set -euo pipefail
  work since Bash 3.1/2.0; remove hard exit 1 from check_deps()
- Add error check on profile append in setup_path(): warn instead of
  falsely reporting success when >> write fails
- Rewrite installer tests to source the real setup_path() from install.sh
  via awk extraction instead of using hand-copied stubs
- Add missing test for .bash_profile-present branch in bash path detection
- Switch installer tests to use assert_contains helpers (consistent pattern)
- Update README badge from 133/133 to 135/135

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants