Skip to content

Commit 0e95ced

Browse files
fix(cli): satisfy golangci-lint (errcheck, unused, errorlint, ineffassign)
Ignore RegisterFlagCompletionFunc errors like other commands; drop unused projectCredentialEnvValues wrapper; call redactTelemetryFields from noop telemetry sinks; use errors.As in agent_infer test helper; fix separator init in agent rule append path.
1 parent 566a9db commit 0e95ced

5 files changed

Lines changed: 18 additions & 14 deletions

File tree

internal/cli/agent_infer_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package cli
22

3-
import "testing"
3+
import (
4+
"errors"
5+
"testing"
6+
)
47

58
func TestAgentLabelFromOSEnv(t *testing.T) {
69
tests := []struct {
@@ -92,8 +95,9 @@ func asCliError(err error, target **cliError) bool {
9295
if err == nil {
9396
return false
9497
}
95-
if c, ok := err.(*cliError); ok {
96-
*target = c
98+
var ce *cliError
99+
if errors.As(err, &ce) {
100+
*target = ce
97101
return true
98102
}
99103
return false

internal/cli/agent_rules.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,11 @@ func writeOrAppendAgentRuleBlock(path, body, target string) (string, error) {
139139
}
140140
return "updated", nil
141141
}
142-
separator := "\n"
142+
var separator string
143143
if len(existing) > 0 && existing[len(existing)-1] != '\n' {
144144
separator = "\n\n"
145145
} else if len(existing) >= 2 && string(existing[len(existing)-2:]) != "\n\n" {
146146
separator = "\n"
147-
} else {
148-
separator = ""
149147
}
150148
next := append([]byte{}, existing...)
151149
next = append(next, []byte(separator)...)

internal/cli/projects.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,6 @@ func credentialLayoutFromProjectType(projectType string) projectEnvCredentialLay
549549
}
550550
}
551551

552-
func projectCredentialEnvValues(project projectDetail) (map[string]any, error) {
553-
return projectCredentialEnvValuesForLayout(project, projectEnvLayoutStandard)
554-
}
555-
556552
func projectCredentialEnvValuesForLayout(project projectDetail, layout projectEnvCredentialLayout) (map[string]any, error) {
557553
if project.SignKey == nil || *project.SignKey == "" {
558554
return nil, &cliError{Message: fmt.Sprintf("project %q does not have an app certificate. Enable one in Agora Console or use a different project with `agora project use`.", project.Name), Code: "PROJECT_NO_CERTIFICATE"}

internal/cli/skills.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ func (a *App) buildSkillsListCommand() *cobra.Command {
194194
}
195195
cmd.Flags().StringVar(&category, "category", "", "filter by category (scaffold, ops, agent)")
196196
cmd.Flags().StringVar(&tag, "tag", "", "filter by tag (e.g. nextjs, rtc, mcp)")
197-
cmd.RegisterFlagCompletionFunc("category", func(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
197+
_ = cmd.RegisterFlagCompletionFunc("category", func(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
198198
return completeSkillCategories(toComplete), cobra.ShellCompDirectiveNoFileComp
199199
})
200-
cmd.RegisterFlagCompletionFunc("tag", func(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
200+
_ = cmd.RegisterFlagCompletionFunc("tag", func(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
201201
return completeSkillTags(toComplete), cobra.ShellCompDirectiveNoFileComp
202202
})
203203
return cmd

internal/cli/telemetry.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,14 @@ type versionInformation = map[string]any
8989
type noopTelemetry struct{}
9090

9191
func (noopTelemetry) Enabled() bool { return false }
92-
func (noopTelemetry) CaptureException(_ error, _ map[string]any) {}
93-
func (noopTelemetry) CaptureEvent(_, _ string, _ map[string]any) {}
92+
func (noopTelemetry) CaptureException(_ error, fields map[string]any) {
93+
// Contract: redact before any sink transports fields; keep call so
94+
// redactTelemetryFields stays covered until Sentry wiring lands.
95+
_ = redactTelemetryFields(fields)
96+
}
97+
func (noopTelemetry) CaptureEvent(_, _ string, fields map[string]any) {
98+
_ = redactTelemetryFields(fields)
99+
}
94100
func (noopTelemetry) Flush(_ time.Duration) bool { return true }
95101

96102
// sentryClient is the placeholder for the Sentry-backed sink. Until the

0 commit comments

Comments
 (0)