mirror of
https://github.com/aaddrick/claude-desktop-debian.git
synced 2026-05-17 08:36:35 +03:00
fix: resolve shellcheck and codespell CI failures
- Fix codespell: replace "caf" trigger word in BATS test data - Fix SC2155: separate declare and assign in log functions - Fix SC2129: use grouped redirects instead of individual ones - Fix SC2034: remove unused variables (EXIT_SUCCESS, IMPLEMENT_STATUS, IMPLEMENT_EXIT_CODE, PROCESS_EXIT_CODE, worktree_branch) - Fix SC2034: add shellcheck disable for RESUME_* vars (reserved for future resume functionality) - Fix SC2317/SC2329: add shellcheck disable for trap-invoked release_lock - Fix SC2002: use input redirection instead of useless cat - Remove dead code: unused update_stage() function Co-Authored-By: Claude <claude@anthropic.com>
This commit is contained in:
@@ -159,6 +159,7 @@ acquire_lock() {
|
||||
echo $$ > "$LOCK_FILE"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2317,SC2329 # Called indirectly via trap
|
||||
release_lock() {
|
||||
if [[ -f "$LOCK_FILE" ]] && [[ "$(cat "$LOCK_FILE" 2>/dev/null)" == "$$" ]]; then
|
||||
rm -f "$LOCK_FILE"
|
||||
@@ -399,9 +400,6 @@ cleanup_worktree() {
|
||||
return
|
||||
fi
|
||||
|
||||
local worktree_branch
|
||||
worktree_branch=$(jq -r '.branch // empty' "$issue_status_file" 2>/dev/null)
|
||||
|
||||
log "Cleaning up worktree for issue #$issue_num: $worktree_path"
|
||||
|
||||
if git worktree remove "$worktree_path" --force 2>/dev/null; then
|
||||
@@ -454,9 +452,11 @@ process_issue() {
|
||||
--status-file "$issue_status_file" \
|
||||
2>&1) || impl_exit=$?
|
||||
|
||||
echo "=== implement-issue output ===" >> "$issue_log"
|
||||
echo "$impl_output" >> "$issue_log"
|
||||
echo "=== exit code: $impl_exit ===" >> "$issue_log"
|
||||
{
|
||||
echo "=== implement-issue output ==="
|
||||
echo "$impl_output"
|
||||
echo "=== exit code: $impl_exit ==="
|
||||
} >> "$issue_log"
|
||||
|
||||
# Parse result from status file
|
||||
local impl_status="error"
|
||||
@@ -527,9 +527,11 @@ process_issue() {
|
||||
--json-schema "$PROCESS_SCHEMA" \
|
||||
2>&1) || proc_exit=$?
|
||||
|
||||
echo "=== process-pr output ===" >> "$issue_log"
|
||||
echo "$proc_output" >> "$issue_log"
|
||||
echo "=== exit code: $proc_exit ===" >> "$issue_log"
|
||||
{
|
||||
echo "=== process-pr output ==="
|
||||
echo "$proc_output"
|
||||
echo "=== exit code: $proc_exit ==="
|
||||
} >> "$issue_log"
|
||||
|
||||
# Update session ID
|
||||
session_id=$(echo "$proc_output" | jq -r '.session_id // empty' 2>/dev/null)
|
||||
|
||||
@@ -32,7 +32,6 @@ ISSUE_NUMBER="${1:?Usage: batch-runner.sh <issue_number> <base_branch>}"
|
||||
BASE_BRANCH="${2:?Usage: batch-runner.sh <issue_number> <base_branch>}"
|
||||
|
||||
# Exit codes for different failure types
|
||||
EXIT_SUCCESS=0
|
||||
EXIT_RATE_LIMIT=10
|
||||
EXIT_PARSE_ERROR=20
|
||||
EXIT_LOGIC_ERROR=30
|
||||
@@ -153,13 +152,10 @@ if claude -p "/implement-issue $ISSUE_NUMBER $BASE_BRANCH" \
|
||||
--output-format json \
|
||||
> "$IMPLEMENT_OUTPUT" 2>&1; then
|
||||
|
||||
IMPLEMENT_STATUS="success"
|
||||
: # success - fall through to PR extraction
|
||||
else
|
||||
IMPLEMENT_EXIT_CODE=$?
|
||||
|
||||
# Check if rate limited
|
||||
if check_rate_limit "$(cat "$IMPLEMENT_OUTPUT")"; then
|
||||
IMPLEMENT_STATUS="rate_limit"
|
||||
RATE_INFO=$(extract_rate_limit_info "$(cat "$IMPLEMENT_OUTPUT")")
|
||||
RETRY_AFTER=$(echo "$RATE_INFO" | cut -d'|' -f1)
|
||||
RESET_AT=$(echo "$RATE_INFO" | cut -d'|' -f2)
|
||||
@@ -183,9 +179,8 @@ else
|
||||
rm -f "$IMPLEMENT_OUTPUT"
|
||||
exit $EXIT_RATE_LIMIT
|
||||
else
|
||||
IMPLEMENT_STATUS="error"
|
||||
# Capture full error but limit to 2000 chars for JSON safety
|
||||
ERROR_MSG=$(cat "$IMPLEMENT_OUTPUT" | tr '\n' ' ' | sed 's/"/\\"/g' | cut -c1-2000)
|
||||
ERROR_MSG=$(tr '\n' ' ' < "$IMPLEMENT_OUTPUT" | sed 's/"/\\"/g' | cut -c1-2000)
|
||||
if [ ${#ERROR_MSG} -eq 2000 ]; then
|
||||
ERROR_MSG="${ERROR_MSG}... [truncated, see log file]"
|
||||
fi
|
||||
@@ -261,8 +256,6 @@ if claude -p "/process-pr $PR_NUMBER $ISSUE_NUMBER $BASE_BRANCH" \
|
||||
PROCESS_STATUS="approved"
|
||||
fi
|
||||
else
|
||||
PROCESS_EXIT_CODE=$?
|
||||
|
||||
# Check if rate limited
|
||||
if check_rate_limit "$(cat "$PROCESS_OUTPUT")"; then
|
||||
PROCESS_STATUS="rate_limit"
|
||||
@@ -291,7 +284,7 @@ else
|
||||
else
|
||||
PROCESS_STATUS="error"
|
||||
# Capture full error but limit to 2000 chars for JSON safety
|
||||
ERROR_MSG=$(cat "$PROCESS_OUTPUT" | tr '\n' ' ' | sed 's/"/\\"/g' | cut -c1-2000)
|
||||
ERROR_MSG=$(tr '\n' ' ' < "$PROCESS_OUTPUT" | sed 's/"/\\"/g' | cut -c1-2000)
|
||||
if [ ${#ERROR_MSG} -eq 2000 ]; then
|
||||
ERROR_MSG="${ERROR_MSG}... [truncated, see log file]"
|
||||
fi
|
||||
|
||||
@@ -127,7 +127,8 @@ LOG_FILE=""
|
||||
STAGE_COUNTER=0
|
||||
|
||||
log() {
|
||||
local msg="[$(date -Iseconds)] $*"
|
||||
local msg
|
||||
msg="[$(date -Iseconds)] $*"
|
||||
if [[ -n "$LOG_FILE" ]]; then
|
||||
printf '%s\n' "$msg" >> "$LOG_FILE"
|
||||
fi
|
||||
@@ -135,7 +136,8 @@ log() {
|
||||
}
|
||||
|
||||
log_error() {
|
||||
local msg="[$(date -Iseconds)] ERROR: $*"
|
||||
local msg
|
||||
msg="[$(date -Iseconds)] ERROR: $*"
|
||||
if [[ -n "$LOG_FILE" ]]; then
|
||||
printf '%s\n' "$msg" >> "$LOG_FILE"
|
||||
fi
|
||||
@@ -195,33 +197,6 @@ init_status() {
|
||||
sync_status_to_log
|
||||
}
|
||||
|
||||
update_stage() {
|
||||
local stage="$1"
|
||||
local status="$2"
|
||||
local extra_field="${3:-}"
|
||||
local extra_value="${4:-}"
|
||||
|
||||
if [[ -n "$extra_field" ]]; then
|
||||
jq --arg stage "$stage" \
|
||||
--arg status "$status" \
|
||||
--arg field "$extra_field" \
|
||||
--arg value "$extra_value" \
|
||||
'.stages[$stage].status = $status |
|
||||
.stages[$stage][$field] = $value |
|
||||
.current_stage = $stage |
|
||||
.last_update = (now | todate)' \
|
||||
"$STATUS_FILE" > "${STATUS_FILE}.tmp" && mv "${STATUS_FILE}.tmp" "$STATUS_FILE"
|
||||
else
|
||||
jq --arg stage "$stage" \
|
||||
--arg status "$status" \
|
||||
'.stages[$stage].status = $status |
|
||||
.current_stage = $stage |
|
||||
.last_update = (now | todate)' \
|
||||
"$STATUS_FILE" > "${STATUS_FILE}.tmp" && mv "${STATUS_FILE}.tmp" "$STATUS_FILE"
|
||||
fi
|
||||
sync_status_to_log
|
||||
}
|
||||
|
||||
set_stage_started() {
|
||||
local stage="$1"
|
||||
jq --arg stage "$stage" \
|
||||
@@ -372,12 +347,16 @@ load_resume_state() {
|
||||
RESUME_TASK=$(jq -r '.current_task // 0' "$status_path")
|
||||
RESUME_TASKS_JSON=$(jq -c '.tasks // []' "$status_path")
|
||||
|
||||
# Restore iteration counters
|
||||
# Restore iteration counters (reserved for future resume functionality)
|
||||
# shellcheck disable=SC2034
|
||||
RESUME_QUALITY_ITERATIONS=$(jq -r '.quality_iterations // 0' "$status_path")
|
||||
# shellcheck disable=SC2034
|
||||
RESUME_TEST_ITERATIONS=$(jq -r '.test_iterations // 0' "$status_path")
|
||||
# shellcheck disable=SC2034
|
||||
RESUME_PR_ITERATIONS=$(jq -r '.pr_review_iterations // 0' "$status_path")
|
||||
|
||||
# Get PR number if it exists
|
||||
# shellcheck disable=SC2034
|
||||
RESUME_PR_NUMBER=$(jq -r '.stages.pr.pr_number // empty' "$status_path")
|
||||
}
|
||||
|
||||
@@ -422,9 +401,13 @@ BRANCH=""
|
||||
RESUME_STAGE=""
|
||||
RESUME_TASK=""
|
||||
RESUME_TASKS_JSON=""
|
||||
# shellcheck disable=SC2034 # Reserved for future resume functionality
|
||||
RESUME_QUALITY_ITERATIONS=0
|
||||
# shellcheck disable=SC2034
|
||||
RESUME_TEST_ITERATIONS=0
|
||||
# shellcheck disable=SC2034
|
||||
RESUME_PR_ITERATIONS=0
|
||||
# shellcheck disable=SC2034
|
||||
RESUME_PR_NUMBER=""
|
||||
|
||||
if [[ "$RESUME_MODE" == "logdir" ]]; then
|
||||
@@ -660,7 +643,8 @@ run_stage() {
|
||||
local schema_file="$3"
|
||||
local agent="${4:-}"
|
||||
|
||||
local stage_log="$LOG_BASE/stages/$(next_stage_log "$stage_name")"
|
||||
local stage_log
|
||||
stage_log="$LOG_BASE/stages/$(next_stage_log "$stage_name")"
|
||||
|
||||
# Validate schema file exists
|
||||
if [[ ! -f "$SCHEMA_DIR/$schema_file" ]]; then
|
||||
@@ -692,9 +676,11 @@ run_stage() {
|
||||
--json-schema "$schema" \
|
||||
2>&1) || exit_code=$?
|
||||
|
||||
printf '%s\n' "=== $stage_name output ===" >> "$stage_log"
|
||||
printf '%s\n' "$output" >> "$stage_log"
|
||||
printf '%s\n' "=== exit code: $exit_code ===" >> "$stage_log"
|
||||
{
|
||||
printf '%s\n' "=== $stage_name output ==="
|
||||
printf '%s\n' "$output"
|
||||
printf '%s\n' "=== exit code: $exit_code ==="
|
||||
} >> "$stage_log"
|
||||
|
||||
# Check timeout
|
||||
if (( exit_code == 124 )); then
|
||||
|
||||
@@ -735,7 +735,7 @@ FIXTURE_EOF
|
||||
|
||||
@test "BINARY: JSON with high ASCII characters" {
|
||||
# Characters > 127 might cause issues
|
||||
local json='{"data":"caf\xc3\xa9"}' # UTF-8 for "cafe" with accent
|
||||
local json='{"data":"\xc3\xa9"}' # UTF-8 for e-with-accent
|
||||
|
||||
local result
|
||||
result=$(echo "$json" | jq -c '.' 2>&1) || true
|
||||
|
||||
Reference in New Issue
Block a user