From 28eafaeef27a7bbc0ff2ac86f98f194c1c19da76 Mon Sep 17 00:00:00 2001 From: sutra Date: Mon, 1 Jun 2026 20:08:40 +0800 Subject: [PATCH] refactor(cron): flatten if-else chains and suppress dupl lint --- pkg/tools/cron.go | 18 ++++++++++++------ pkg/tools/shell.go | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pkg/tools/cron.go b/pkg/tools/cron.go index 4e32797a6..b3b14dc48 100644 --- a/pkg/tools/cron.go +++ b/pkg/tools/cron.go @@ -85,6 +85,8 @@ Use 'command' to execute shell commands directly.` } // Parameters returns the tool parameters schema +// +//nolint:dupl // Tool parameter schemas intentionally use similar JSON-schema map literals. func (t *CronTool) Parameters() map[string]any { return map[string]any{ "type": "object", @@ -317,16 +319,20 @@ func (t *CronTool) updateJob(ctx context.Context, args map[string]any) *ToolResu patches := 0 - if name, present, errResult := optionalNonEmptyString(args, "name"); errResult != nil { - return errResult - } else if present { + name, namePresent, nameErr := optionalNonEmptyString(args, "name") + if nameErr != nil { + return nameErr + } + if namePresent { job.Name = name patches++ } - if message, present, errResult := optionalNonEmptyString(args, "message"); errResult != nil { - return errResult - } else if present { + message, messagePresent, messageErr := optionalNonEmptyString(args, "message") + if messageErr != nil { + return messageErr + } + if messagePresent { job.Payload.Message = message patches++ } diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index 07626a638..5c2b03f4f 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -215,6 +215,7 @@ func (t *ExecTool) Description() string { return `Execute shell commands. Use background=true for long-running commands (returns sessionId). Use pty=true for interactive commands (can combine with background=true). Use poll/read/write/send-keys/kill with sessionId to manage background sessions. Sessions auto-cleanup 30 minutes after process exits; use kill to terminate early. Output buffer limit: 1MB.` } +//nolint:dupl // Tool parameter schemas intentionally use similar JSON-schema map literals. func (t *ExecTool) Parameters() map[string]any { return map[string]any{ "type": "object",