Skip to content

Commit 1d58e9e

Browse files
committed
refactor(migrator): simplify function signatures by combining parameters
1 parent 9485dce commit 1d58e9e

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

cmd/internal/migrations/v3/client_usage.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func MigrateClientUsage(cmd *cobra.Command, cwd string, _, _ *semver.Version) er
108108
return nil
109109
}
110110

111-
func rewriteAcquireAgentBlocksWithAlias(content string, alias string) (string, bool) {
111+
func rewriteAcquireAgentBlocksWithAlias(content, alias string) (string, bool) {
112112
patterns := buildAliasPatterns(alias)
113113
acquireAgentPattern := patterns["acquireAgent"]
114114
releaseAgentPattern := patterns["releaseAgent"]
@@ -239,10 +239,6 @@ func rewriteAcquireAgentBlocksWithAlias(content string, alias string) (string, b
239239
case len(structMatch) > 0 && structMatch[5] == agentVar:
240240
statusVar := strings.TrimSpace(structMatch[2])
241241
bodyVar := strings.TrimSpace(structMatch[3])
242-
assignOp := structMatch[4]
243-
if assignOp == "" {
244-
assignOp = "="
245-
}
246242
structTarget := strings.TrimSpace(structMatch[6])
247243

248244
structBody := []string{}
@@ -293,10 +289,6 @@ func rewriteAcquireAgentBlocksWithAlias(content string, alias string) (string, b
293289
case len(bytesMatch) > 0 && bytesMatch[5] == agentVar:
294290
statusVar := strings.TrimSpace(bytesMatch[2])
295291
bodyVar := strings.TrimSpace(bytesMatch[3])
296-
assignOp := bytesMatch[4]
297-
if assignOp == "" {
298-
assignOp = "="
299-
}
300292

301293
respLine := fmt.Sprintf("%sresp, err := client.%s(%s%s)", indent, methodName, uriExpr, configLine)
302294
out = append(out, respLine)
@@ -382,7 +374,7 @@ func buildConfig(headers map[string]string) string {
382374
return fmt.Sprintf(", client.Config{Header: map[string]string{%s}}", strings.Join(parts, ", "))
383375
}
384376

385-
func rewriteClientExamplesWithAlias(content string, alias string) (string, bool) {
377+
func rewriteClientExamplesWithAlias(content, alias string) (string, bool) {
386378
patterns := buildAliasPatterns(alias)
387379

388380
updated, changedSimple := rewriteSimpleAgentBlocksWithAlias(content, alias)
@@ -431,7 +423,7 @@ type headerValue struct {
431423
raw bool
432424
}
433425

434-
func rewriteSimpleAgentBlocksWithAlias(content string, alias string) (string, bool) {
426+
func rewriteSimpleAgentBlocksWithAlias(content, alias string) (string, bool) {
435427
patterns := buildAliasPatterns(alias)
436428
simpleAgentPattern := patterns["simpleAgent"]
437429

0 commit comments

Comments
 (0)