From 5965d29f9969f548c4a7a84f85b01bf08c282aee Mon Sep 17 00:00:00 2001 From: jack Date: Sun, 21 Jun 2026 02:27:33 +0800 Subject: [PATCH] chore(lint): fix pre-existing golangci-lint issues Clean up the trivial (non-deprecation) issues reported by golangci-lint that don't block CI but were flagged by the new quality gate: - unparam: drop the unused *Goal return from (*GoalStore).setStatus; both callers only used the bool. - goimports: regroup the third-party import in goal_test.go. - ineffassign: replace `remotePwd := "/root"` with `var remotePwd string` in ssh.go since the initializer was always overwritten. - gocritic (deprecatedComment): move the AutoApprove `Deprecated:` notice into its own paragraph. - gocritic (ifElseChain): rewrite the team_send_message if-else chain in acp.go as a switch. Fixing the Deprecated: comment format made staticcheck correctly recognize AutoApprove as deprecated, surfacing two SA1019 warnings on intentional fallback reads. Those reads are documented behavior (the field is still honored when DefaultMode is unset), so they are annotated with //nolint:staticcheck rather than removed. The 9 remaining adk.AgentMiddleware SA1019 warnings are intentionally left for the separate dependency-migration task. Co-Authored-By: Claude Opus 4.8 --- internal/command/interactive.go | 2 +- internal/command/ssh.go | 2 +- internal/config/config.go | 1 + internal/handler/acp.go | 7 ++++--- internal/tools/goal.go | 16 +++++++--------- internal/tools/goal_test.go | 3 ++- internal/tui/tui.go | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/internal/command/interactive.go b/internal/command/interactive.go index 89d9759..79e0cfd 100644 --- a/internal/command/interactive.go +++ b/internal/command/interactive.go @@ -1300,7 +1300,7 @@ func resolveStartupMode(cfg *config.Config, unsafe bool) mode.SessionMode { if cfg != nil && cfg.DefaultMode != "" { return mode.Parse(cfg.DefaultMode) } - if cfg != nil && cfg.AutoApprove { + if cfg != nil && cfg.AutoApprove { //nolint:staticcheck // intentional fallback to the deprecated field when DefaultMode is unset return mode.Autopilot } return mode.Ask diff --git a/internal/command/ssh.go b/internal/command/ssh.go index 9fd6795..dd2dec7 100644 --- a/internal/command/ssh.go +++ b/internal/command/ssh.go @@ -53,7 +53,7 @@ func HandleSSHConnect( return // Do not initialize agent yet } - remotePwd := "/root" + var remotePwd string if path != "" { remotePwd = path } else { diff --git a/internal/config/config.go b/internal/config/config.go index 9735968..a94f296 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -161,6 +161,7 @@ type Config struct { Team *TeamConfig `json:"team,omitempty"` // AutoApprove sets the default approval mode to auto on startup. + // // Deprecated: superseded by DefaultMode; still honored as a fallback when // DefaultMode is empty (true → "autopilot"). AutoApprove bool `json:"auto_approve,omitempty"` diff --git a/internal/handler/acp.go b/internal/handler/acp.go index 75de6c2..97aac42 100644 --- a/internal/handler/acp.go +++ b/internal/handler/acp.go @@ -208,11 +208,12 @@ func (h *ACPHandler) presentationForTool(name, argsJSON string) acpToolPresentat p.Title = "Load skill " + getString("name") case "team_send_message": to := getString("to") - if to == "*" { + switch { + case to == "*": p.Title = "Message team" - } else if to != "" { + case to != "": p.Title = "Message @" + to - } else { + default: p.Title = "Send team message" } case "team_create": diff --git a/internal/tools/goal.go b/internal/tools/goal.go index ba58c95..1df66ab 100644 --- a/internal/tools/goal.go +++ b/internal/tools/goal.go @@ -169,32 +169,30 @@ func (s *GoalStore) IsActive() bool { return s.goal != nil && s.goal.Status == GoalActive } -// setStatus transitions the goal to a terminal status. Returns the snapshot and -// whether a goal existed to update. -func (s *GoalStore) setStatus(status GoalStatus) (*Goal, bool) { +// setStatus transitions the goal to a terminal status. Returns whether a goal +// existed to update. +func (s *GoalStore) setStatus(status GoalStatus) bool { s.mu.Lock() if s.goal == nil { s.mu.Unlock() - return nil, false + return false } s.goal.Status = status s.goal.UpdatedAt = s.now() snap := s.goal.clone() s.mu.Unlock() s.fireUpdate(snap) - return snap, true + return true } // Complete marks the goal complete. Returns false if no goal is set. func (s *GoalStore) Complete() bool { - _, ok := s.setStatus(GoalComplete) - return ok + return s.setStatus(GoalComplete) } // Block marks the goal blocked. Returns false if no goal is set. func (s *GoalStore) Block() bool { - _, ok := s.setStatus(GoalBlocked) - return ok + return s.setStatus(GoalBlocked) } // Clear removes the goal entirely. diff --git a/internal/tools/goal_test.go b/internal/tools/goal_test.go index 3ab93d0..6e64479 100644 --- a/internal/tools/goal_test.go +++ b/internal/tools/goal_test.go @@ -3,9 +3,10 @@ package tools import ( "context" "encoding/json" - "github.com/cnjack/jcode/internal/session" "strings" "testing" + + "github.com/cnjack/jcode/internal/session" ) func TestGoalStore_SetAndGet(t *testing.T) { diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 2909d15..7ff2510 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -319,7 +319,7 @@ func NewModel(hasPrompt bool, pwd string, todoStore *tools.TodoStore) Model { if cfg, err := config.LoadConfig(); err == nil { m.activeProvider, m.activeModel = cfg.GetProviderModel() - if cfg.AutoApprove { + if cfg.AutoApprove { //nolint:staticcheck // intentional fallback to the deprecated field when DefaultMode is unset m.approvalMode = ModeAuto } }