Skip to content

Commit 237c843

Browse files
Dumbrisclaude
andcommitted
fix: remove unnecessary nil checks in configimport
Fixes staticcheck S1009 and S1031 lint errors: - len() for nil maps/slices is defined as zero - range over nil map is a no-op Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent dbd1cd2 commit 237c843

6 files changed

Lines changed: 8 additions & 10 deletions

File tree

internal/configimport/claude_code.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (p *ClaudeCodeParser) Parse(content []byte) ([]*ParsedServer, error) {
3838
}
3939
}
4040

41-
if cfg.MCPServers == nil || len(cfg.MCPServers) == 0 {
41+
if len(cfg.MCPServers) == 0 {
4242
return nil, &ImportError{
4343
Type: "no_servers",
4444
Message: "no MCP servers found in Claude Code config",

internal/configimport/claude_desktop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (p *ClaudeDesktopParser) Parse(content []byte) ([]*ParsedServer, error) {
3636
}
3737
}
3838

39-
if cfg.MCPServers == nil || len(cfg.MCPServers) == 0 {
39+
if len(cfg.MCPServers) == 0 {
4040
return nil, &ImportError{
4141
Type: "no_servers",
4242
Message: "no MCP servers found in Claude Desktop config",

internal/configimport/codex.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (p *CodexParser) Parse(content []byte) ([]*ParsedServer, error) {
5757
}
5858
}
5959

60-
if cfg.MCPServers == nil || len(cfg.MCPServers) == 0 {
60+
if len(cfg.MCPServers) == 0 {
6161
return nil, &ImportError{
6262
Type: "no_servers",
6363
Message: "no MCP servers found in Codex config (looking for [mcp_servers.*] sections)",

internal/configimport/cursor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (p *CursorParser) Parse(content []byte) ([]*ParsedServer, error) {
4848
}
4949
}
5050

51-
if cfg.MCPServers == nil || len(cfg.MCPServers) == 0 {
51+
if len(cfg.MCPServers) == 0 {
5252
return nil, &ImportError{
5353
Type: "no_servers",
5454
Message: "no MCP servers found in Cursor config",

internal/configimport/gemini.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (p *GeminiParser) Parse(content []byte) ([]*ParsedServer, error) {
7272
}
7373
}
7474

75-
if cfg.MCPServers == nil || len(cfg.MCPServers) == 0 {
75+
if len(cfg.MCPServers) == 0 {
7676
return nil, &ImportError{
7777
Type: "no_servers",
7878
Message: "no MCP servers found in Gemini config",

internal/configimport/import.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,9 @@ func Import(content []byte, opts *ImportOptions) (*ImportResult, error) {
129129
}
130130

131131
// Validate filter - check if requested servers were found
132-
if filterSet != nil {
133-
for name := range filterSet {
134-
if !foundServers[name] {
135-
result.Warnings = append(result.Warnings, fmt.Sprintf("requested server '%s' not found in config", name))
136-
}
132+
for name := range filterSet {
133+
if !foundServers[name] {
134+
result.Warnings = append(result.Warnings, fmt.Sprintf("requested server '%s' not found in config", name))
137135
}
138136
}
139137

0 commit comments

Comments
 (0)