Skip to content

quality-debt: setup-modules/config.sh — PR #2103 review feedback (medium) #3263

@marcusquinn

Description

@marcusquinn

Unactioned Review Feedback

Source PR: #2103
File: setup-modules/config.sh
Reviewers: gemini, human
Findings: 4
Max severity: medium


MEDIUM: gemini (gemini-code-assist[bot])

File: setup-modules/config.sh:159
medium

The pattern of checking for a script's existence and then executing it is repeated for generate-claude-commands.sh, generate-claude-agents.sh, and subagent-index-helper.sh. This duplication also exists in the update_opencode_config function.

To improve maintainability and reduce code duplication, you could extract this logic into a helper function. This is an optional suggestion for future refactoring, but it would make the code much cleaner.

Here's an example of what that could look like:

# Helper function (could be placed at top of file)
_run_generator() {
    local script_path="$1"
    local info_msg="$2"
    local success_msg="$3"
    local failure_msg="$4"
    shift 4
    local script_args=("$@")

    if [[ ! -f "$script_path" ]]; then
        print_warning "Generator script not found: $script_path"
        return
    fi

    print_info "$info_msg"
    if bash "$script_path" "${script_args[@]}"; then
        print_success "$success_msg"
    else
        print_warning "$failure_msg"
    fi
}

update_claude_config() {
    # ... guard clause ...
    print_info "Updating Claude Code configuration..."

    _run_generator ".agents/scripts/generate-claude-commands.sh" \
        "Generating Claude Code commands..." \
        "Claude Code commands configured" \
        "Claude Code command generation encountered issues"

    _run_generator ".agents/scripts/generate-claude-agents.sh" \
        "Generating Claude Code agent configuration..." \
        "Claude Code agents configured (MCPs, settings, commands)" \
        "Claude Code agent generation encountered issues"

    _run_generator ".agents/scripts/subagent-index-helper.sh" \
        "Regenerating subagent index..." \
        "Subagent index regenerated" \
        "Subagent index generation encountered issues" \
        generate

    return 0
}
References
  1. In shell scripts, extract repeated logic into an internal helper function to improve maintainability. This applies even for standalone scripts where external source dependencies are avoided.

View comment

MEDIUM: gemini (gemini-code-assist[bot])

File: setup-modules/config.sh:170
medium

This check for subagent-index-helper.sh is missing an else block to handle the case where the script is not found. For consistency with the other script checks in this file and for better error reporting, it would be good to add a print_warning message.

 	if [[ -f "$index_script" ]]; then
 		if bash "$index_script" generate; then
 			print_success "Subagent index regenerated"
 		else
 			print_warning "Subagent index generation encountered issues"
 		fi
 	else
 		print_warning "Subagent index helper not found at $index_script"
 	fi
References
  1. When reporting errors for failed file operations in shell scripts, such as 'jq' writes, include the file path in the error message. Avoid suppressing stderr with '2>/dev/null' to ensure that diagnostic information about malformed files or write failures is visible.

View comment

MEDIUM: human (marcusquinn)

File: setup-modules/config.sh:170
Fixed — extracted _run_generator() helper that handles existence check, execution, and consistent success/warning messaging. All 5 instances (including this one) now use the helper, which includes the not-found warning path. See e77114c.

View comment

MEDIUM: human (marcusquinn)

File: setup-modules/config.sh:159
Fixed — adopted the suggested _run_generator() pattern. All 5 check-and-execute blocks across update_opencode_config() and update_claude_config() now use the shared helper. Net -12 lines. See e77114c.

View comment


Auto-generated by quality-feedback-helper.sh scan-merged. Review each finding and either fix the code or dismiss with a reason.

Metadata

Metadata

Assignees

Labels

already-fixedAlready fixed by another changepriority:mediumMedium severity — moderate quality issuequality-debtAuto-created from TODO.md tagstatus:queuedWorker dispatched, not yet started

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions