Skip to content

Commit 54f0e1a

Browse files
masegrayeclaude
andcommitted
fix: resolve golangci-lint issues in models command
- Remove unused env parameter (unparam) - Use strings.EqualFold for case-insensitive comparison (gocritic) - Use strings.SplitSeq for range iteration (modernize) - Fix import ordering: standard > third-party > project (gci) - Remove trailing blank line Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 06c69e7 commit 54f0e1a

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

cmd/root/models.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/docker/docker-agent/pkg/cli"
1414
"github.com/docker/docker-agent/pkg/config"
1515
"github.com/docker/docker-agent/pkg/config/latest"
16-
"github.com/docker/docker-agent/pkg/environment"
1716
"github.com/docker/docker-agent/pkg/model/provider"
1817
"github.com/docker/docker-agent/pkg/modelsdev"
1918
"github.com/docker/docker-agent/pkg/telemetry"
@@ -100,13 +99,12 @@ func (f *modelsListFlags) runModelsListCommand(cmd *cobra.Command, args []string
10099
// Determine which model auto-selection would pick.
101100
autoModel := config.AutoModelConfig(ctx, f.runConfig.ModelsGateway, env, f.runConfig.DefaultModel)
102101

103-
rows := f.collectModels(ctx, env, availableProviders, autoModel)
102+
rows := f.collectModels(ctx, availableProviders, autoModel)
104103

105104
// Apply provider filter
106105
if f.providerFilter != "" {
107-
filter := strings.ToLower(f.providerFilter)
108106
rows = slices.DeleteFunc(rows, func(r modelRow) bool {
109-
return strings.ToLower(r.Provider) != filter
107+
return !strings.EqualFold(r.Provider, f.providerFilter)
110108
})
111109
}
112110

@@ -143,7 +141,7 @@ func (f *modelsListFlags) runModelsListCommand(cmd *cobra.Command, args []string
143141
// collectModels returns all models from the catalog, filtered by credential
144142
// availability unless --all is set. Default models for each available provider
145143
// are always included even if the catalog fetch fails.
146-
func (f *modelsListFlags) collectModels(ctx context.Context, env environment.Provider, availableProviders map[string]bool, autoModel latest.ModelConfig) []modelRow {
144+
func (f *modelsListFlags) collectModels(ctx context.Context, availableProviders map[string]bool, autoModel latest.ModelConfig) []modelRow {
147145
seen := make(map[string]bool)
148146
var rows []modelRow
149147

cmd/root/models_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestModelsListCommand_ProviderFilter(t *testing.T) {
6060

6161
output := buf.String()
6262
// Every non-header line should be anthropic
63-
for _, line := range strings.Split(output, "\n") {
63+
for line := range strings.SplitSeq(output, "\n") {
6464
line = strings.TrimSpace(line)
6565
if line == "" || strings.HasPrefix(line, "PROVIDER") {
6666
continue
@@ -166,4 +166,3 @@ func TestModelsListCommand_NoCredentials(t *testing.T) {
166166
// DMR is always available as fallback
167167
assert.Contains(t, output, "dmr")
168168
}
169-

0 commit comments

Comments
 (0)