refactor(cron): flatten if-else chains and suppress dupl lint

This commit is contained in:
sutra 2026-06-01 20:08:40 +08:00
parent be13201f02
commit 28eafaeef2
2 changed files with 13 additions and 6 deletions

View file

@ -85,6 +85,8 @@ Use 'command' to execute shell commands directly.`
} }
// Parameters returns the tool parameters schema // 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 { func (t *CronTool) Parameters() map[string]any {
return map[string]any{ return map[string]any{
"type": "object", "type": "object",
@ -317,16 +319,20 @@ func (t *CronTool) updateJob(ctx context.Context, args map[string]any) *ToolResu
patches := 0 patches := 0
if name, present, errResult := optionalNonEmptyString(args, "name"); errResult != nil { name, namePresent, nameErr := optionalNonEmptyString(args, "name")
return errResult if nameErr != nil {
} else if present { return nameErr
}
if namePresent {
job.Name = name job.Name = name
patches++ patches++
} }
if message, present, errResult := optionalNonEmptyString(args, "message"); errResult != nil { message, messagePresent, messageErr := optionalNonEmptyString(args, "message")
return errResult if messageErr != nil {
} else if present { return messageErr
}
if messagePresent {
job.Payload.Message = message job.Payload.Message = message
patches++ patches++
} }

View file

@ -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.` 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 { func (t *ExecTool) Parameters() map[string]any {
return map[string]any{ return map[string]any{
"type": "object", "type": "object",