From f285804b6c5c45d0a37fad2e2edb0e56fe8aa034 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Fri, 6 Feb 2026 16:31:53 -0300 Subject: [PATCH] refactor: remove empty slice declarations (#2150) --- internal/agent/tools/diagnostics.go | 6 +++--- internal/cmd/logs.go | 4 ++-- internal/config/config.go | 2 +- internal/config/load.go | 8 +------- internal/config/load_test.go | 2 +- internal/ui/chat/agent.go | 2 +- internal/ui/chat/lsp_restart.go | 2 +- internal/ui/common/elements.go | 2 +- internal/ui/dialog/arguments.go | 2 +- internal/ui/model/lsp.go | 2 +- internal/ui/model/mcp.go | 2 +- 11 files changed, 14 insertions(+), 20 deletions(-) diff --git a/internal/agent/tools/diagnostics.go b/internal/agent/tools/diagnostics.go index 04cf79ee793a742c00f7c8d4a1e0e869663569e4..41a1b8abfa8e54c32de783cd2bf1da11f3bdf264 100644 --- a/internal/agent/tools/diagnostics.go +++ b/internal/agent/tools/diagnostics.go @@ -67,8 +67,8 @@ func getDiagnostics(filePath string, manager *lsp.Manager) string { return "" } - fileDiagnostics := []string{} - projectDiagnostics := []string{} + var fileDiagnostics []string + var projectDiagnostics []string for lspName, client := range manager.Clients().Seq2() { for location, diags := range client.GetDiagnostics() { @@ -163,7 +163,7 @@ func formatDiagnostic(pth string, diagnostic protocol.Diagnostic, source string) tagsInfo := "" if len(diagnostic.Tags) > 0 { - tags := []string{} + var tags []string for _, tag := range diagnostic.Tags { switch tag { case protocol.Unnecessary: diff --git a/internal/cmd/logs.go b/internal/cmd/logs.go index 4c66d499a08393972ec1ad740ddb4c29293b88d9..804b23310fa1e3fb86e4b32983bfcdd571df47aa 100644 --- a/internal/cmd/logs.go +++ b/internal/cmd/logs.go @@ -171,8 +171,8 @@ func printLogLine(lineText string) { } msg := data["msg"] level := data["level"] - otherData := []any{} - keys := []string{} + var otherData []any + var keys []string for k := range data { keys = append(keys, k) } diff --git a/internal/config/config.go b/internal/config/config.go index 9a5f0eebfcd557f0ef71e5da471bc3348aeb5d55..2de7afbc106c48214716e1338236768e77ed2e97 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -730,7 +730,7 @@ func resolveReadOnlyTools(tools []string) []string { } func filterSlice(data []string, mask []string, include bool) []string { - filtered := []string{} + var filtered []string for _, s := range data { // if include is true, we include items that ARE in the mask // if include is false, we include items that are NOT in the mask diff --git a/internal/config/load.go b/internal/config/load.go index a651f4846307ed9729ba8a10835e98aece486dbd..0815f86d0faa4b94476c6c57670371b3eb5632f6 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -95,7 +95,7 @@ func Load(workingDir, dataDir string, debug bool) (*Config, error) { } func PushPopCrushEnv() func() { - found := []string{} + var found []string for _, ev := range os.Environ() { if strings.HasPrefix(ev, "CRUSH_") { pair := strings.SplitN(ev, "=", 2) @@ -342,12 +342,6 @@ func (c *Config) setDefaults(workingDir, dataDir string) { if c.Options.TUI == nil { c.Options.TUI = &TUIOptions{} } - if c.Options.ContextPaths == nil { - c.Options.ContextPaths = []string{} - } - if c.Options.SkillsPaths == nil { - c.Options.SkillsPaths = []string{} - } if dataDir != "" { c.Options.DataDirectory = dataDir } else if c.Options.DataDirectory == "" { diff --git a/internal/config/load_test.go b/internal/config/load_test.go index 0e23d22485c23e2b5e1c5fb1a98a86b561e00540..7229ac51d4a4c0616f268ea2a592cb12e1b818bb 100644 --- a/internal/config/load_test.go +++ b/internal/config/load_test.go @@ -513,7 +513,7 @@ func TestConfig_setupAgentsWithEveryReadOnlyToolDisabled(t *testing.T) { taskAgent, ok := cfg.Agents[AgentTask] require.True(t, ok) - assert.Equal(t, []string{}, taskAgent.AllowedTools) + assert.Len(t, taskAgent.AllowedTools, 0) } func TestConfig_configureProvidersWithDisabledProvider(t *testing.T) { diff --git a/internal/ui/chat/agent.go b/internal/ui/chat/agent.go index c2a439ff23d0bd046b75076ea30de68b60cdcc54..e8840cc53be358010dc006aef6961290902b5983 100644 --- a/internal/ui/chat/agent.go +++ b/internal/ui/chat/agent.go @@ -242,7 +242,7 @@ func (r *AgenticFetchToolRenderContext) RenderTool(sty *styles.Styles, width int prompt = strings.ReplaceAll(prompt, "\n", " ") // Build header with optional URL param. - toolParams := []string{} + var toolParams []string if params.URL != "" { toolParams = append(toolParams, params.URL) } diff --git a/internal/ui/chat/lsp_restart.go b/internal/ui/chat/lsp_restart.go index 66c316fcaf7c949711babeb9ebe864e558ae5bc0..a75dce932ed5fc2da1757e4a139a93d0d7d3fab4 100644 --- a/internal/ui/chat/lsp_restart.go +++ b/internal/ui/chat/lsp_restart.go @@ -38,7 +38,7 @@ func (r *LSPRestartToolRenderContext) RenderTool(sty *styles.Styles, width int, var params tools.LSPRestartParams _ = json.Unmarshal([]byte(opts.ToolCall.Input), ¶ms) - toolParams := []string{} + var toolParams []string if params.Name != "" { toolParams = append(toolParams, params.Name) } diff --git a/internal/ui/common/elements.go b/internal/ui/common/elements.go index a129d1861e483c5c2064dc70d70ebd5c09cbd1f8..1477b2a5208e31831a1725042daa6190364ced46 100644 --- a/internal/ui/common/elements.go +++ b/internal/ui/common/elements.go @@ -137,7 +137,7 @@ func Status(t *styles.Styles, opts StatusOpts, width int) string { description = t.Base.Foreground(descriptionColor).Render(description) } - content := []string{} + var content []string if icon != "" { content = append(content, icon) } diff --git a/internal/ui/dialog/arguments.go b/internal/ui/dialog/arguments.go index 96eff11940841e2377e85fafeab9850fb844f139..5cec78593a15356b8fd18d952f78e88c7f158bab 100644 --- a/internal/ui/dialog/arguments.go +++ b/internal/ui/dialog/arguments.go @@ -342,7 +342,7 @@ func (a *Arguments) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor { if scrollbar != "" { content = lipgloss.JoinHorizontal(lipgloss.Top, content, scrollbar) } - contentParts := []string{} + var contentParts []string if description != "" { contentParts = append(contentParts, description) } diff --git a/internal/ui/model/lsp.go b/internal/ui/model/lsp.go index f597c1100682a535cada2ae2c694471d9743c40a..9566e7b28403685e4a961e01158cfbf027d5e156 100644 --- a/internal/ui/model/lsp.go +++ b/internal/ui/model/lsp.go @@ -60,7 +60,7 @@ func (m *UI) lspInfo(width, maxItems int, isSection bool) string { // lspDiagnostics formats diagnostic counts with appropriate icons and colors. func lspDiagnostics(t *styles.Styles, diagnostics map[protocol.DiagnosticSeverity]int) string { - errs := []string{} + var errs []string if diagnostics[protocol.SeverityError] > 0 { errs = append(errs, t.LSP.ErrorDiagnostic.Render(fmt.Sprintf("%s%d", styles.LSPErrorIcon, diagnostics[protocol.SeverityError]))) } diff --git a/internal/ui/model/mcp.go b/internal/ui/model/mcp.go index 3345841618f0fdb6663fec80eb7784b1297c329c..517016f0dcb9b5f237d4ac09c9816a290a42fdcc 100644 --- a/internal/ui/model/mcp.go +++ b/internal/ui/model/mcp.go @@ -36,7 +36,7 @@ func (m *UI) mcpInfo(width, maxItems int, isSection bool) string { // mcpCounts formats tool, prompt, and resource counts for display. func mcpCounts(t *styles.Styles, counts mcp.Counts) string { - parts := []string{} + var parts []string if counts.Tools > 0 { parts = append(parts, t.Subtle.Render(fmt.Sprintf("%d tools", counts.Tools))) }