on main help sign in
refactor: remove empty slice declarations (#2150)
f285804Andrey Nering
internal/agent/tools/diagnostics.go+3−3
@@ -67,8 +67,8 @@ func getDiagnostics(filePath string, manager *lsp.Manager) string {
67 return ""
67 return ""
68 }
68 }
69
69
70− fileDiagnostics := []string{}
70+ var fileDiagnostics []string
71− projectDiagnostics := []string{}
71+ var projectDiagnostics []string
72
72
73 for lspName, client := range manager.Clients().Seq2() {
73 for lspName, client := range manager.Clients().Seq2() {
74 for location, diags := range client.GetDiagnostics() {
74 for location, diags := range client.GetDiagnostics() {
@@ -163,7 +163,7 @@ func formatDiagnostic(pth string, diagnostic protocol.Diagnostic, source string)
163
163
164 tagsInfo := ""
164 tagsInfo := ""
165 if len(diagnostic.Tags) > 0 {
165 if len(diagnostic.Tags) > 0 {
166− tags := []string{}
166+ var tags []string
167 for _, tag := range diagnostic.Tags {
167 for _, tag := range diagnostic.Tags {
168 switch tag {
168 switch tag {
169 case protocol.Unnecessary:
169 case protocol.Unnecessary:
internal/cmd/logs.go+2−2
@@ -171,8 +171,8 @@ func printLogLine(lineText string) {
171 }
171 }
172 msg := data["msg"]
172 msg := data["msg"]
173 level := data["level"]
173 level := data["level"]
174− otherData := []any{}
174+ var otherData []any
175− keys := []string{}
175+ var keys []string
176 for k := range data {
176 for k := range data {
177 keys = append(keys, k)
177 keys = append(keys, k)
178 }
178 }
internal/config/config.go+1−1
@@ -730,7 +730,7 @@ func resolveReadOnlyTools(tools []string) []string {
730}
730}
731
731
732func filterSlice(data []string, mask []string, include bool) []string {
732func filterSlice(data []string, mask []string, include bool) []string {
733− filtered := []string{}
733+ var filtered []string
734 for _, s := range data {
734 for _, s := range data {
735 // if include is true, we include items that ARE in the mask
735 // if include is true, we include items that ARE in the mask
736 // if include is false, we include items that are NOT in the mask
736 // if include is false, we include items that are NOT in the mask
internal/config/load.go+1−7
@@ -95,7 +95,7 @@ func Load(workingDir, dataDir string, debug bool) (*Config, error) {
95}
95}
96
96
97func PushPopCrushEnv() func() {
97func PushPopCrushEnv() func() {
98− found := []string{}
98+ var found []string
99 for _, ev := range os.Environ() {
99 for _, ev := range os.Environ() {
100 if strings.HasPrefix(ev, "CRUSH_") {
100 if strings.HasPrefix(ev, "CRUSH_") {
101 pair := strings.SplitN(ev, "=", 2)
101 pair := strings.SplitN(ev, "=", 2)
@@ -342,12 +342,6 @@ func (c *Config) setDefaults(workingDir, dataDir string) {
342 if c.Options.TUI == nil {
342 if c.Options.TUI == nil {
343 c.Options.TUI = &TUIOptions{}
343 c.Options.TUI = &TUIOptions{}
344 }
344 }
345− if c.Options.ContextPaths == nil {
346− c.Options.ContextPaths = []string{}
347− }
348− if c.Options.SkillsPaths == nil {
349− c.Options.SkillsPaths = []string{}
350− }
351 if dataDir != "" {
345 if dataDir != "" {
352 c.Options.DataDirectory = dataDir
346 c.Options.DataDirectory = dataDir
353 } else if c.Options.DataDirectory == "" {
347 } else if c.Options.DataDirectory == "" {
internal/config/load_test.go+1−1
@@ -513,7 +513,7 @@ func TestConfig_setupAgentsWithEveryReadOnlyToolDisabled(t *testing.T) {
513
513
514 taskAgent, ok := cfg.Agents[AgentTask]
514 taskAgent, ok := cfg.Agents[AgentTask]
515 require.True(t, ok)
515 require.True(t, ok)
516− assert.Equal(t, []string{}, taskAgent.AllowedTools)
516+ assert.Len(t, taskAgent.AllowedTools, 0)
517}
517}
518
518
519func TestConfig_configureProvidersWithDisabledProvider(t *testing.T) {
519func TestConfig_configureProvidersWithDisabledProvider(t *testing.T) {
internal/ui/chat/agent.go+1−1
@@ -242,7 +242,7 @@ func (r *AgenticFetchToolRenderContext) RenderTool(sty *styles.Styles, width int
242 prompt = strings.ReplaceAll(prompt, "\n", " ")
242 prompt = strings.ReplaceAll(prompt, "\n", " ")
243
243
244 // Build header with optional URL param.
244 // Build header with optional URL param.
245− toolParams := []string{}
245+ var toolParams []string
246 if params.URL != "" {
246 if params.URL != "" {
247 toolParams = append(toolParams, params.URL)
247 toolParams = append(toolParams, params.URL)
248 }
248 }
internal/ui/chat/lsp_restart.go+1−1
@@ -38,7 +38,7 @@ func (r *LSPRestartToolRenderContext) RenderTool(sty *styles.Styles, width int,
38 var params tools.LSPRestartParams
38 var params tools.LSPRestartParams
39 _ = json.Unmarshal([]byte(opts.ToolCall.Input), &params)
39 _ = json.Unmarshal([]byte(opts.ToolCall.Input), &params)
40
40
41− toolParams := []string{}
41+ var toolParams []string
42 if params.Name != "" {
42 if params.Name != "" {
43 toolParams = append(toolParams, params.Name)
43 toolParams = append(toolParams, params.Name)
44 }
44 }
internal/ui/common/elements.go+1−1
@@ -137,7 +137,7 @@ func Status(t *styles.Styles, opts StatusOpts, width int) string {
137 description = t.Base.Foreground(descriptionColor).Render(description)
137 description = t.Base.Foreground(descriptionColor).Render(description)
138 }
138 }
139
139
140− content := []string{}
140+ var content []string
141 if icon != "" {
141 if icon != "" {
142 content = append(content, icon)
142 content = append(content, icon)
143 }
143 }
internal/ui/dialog/arguments.go+1−1
@@ -342,7 +342,7 @@ func (a *Arguments) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
342 if scrollbar != "" {
342 if scrollbar != "" {
343 content = lipgloss.JoinHorizontal(lipgloss.Top, content, scrollbar)
343 content = lipgloss.JoinHorizontal(lipgloss.Top, content, scrollbar)
344 }
344 }
345− contentParts := []string{}
345+ var contentParts []string
346 if description != "" {
346 if description != "" {
347 contentParts = append(contentParts, description)
347 contentParts = append(contentParts, description)
348 }
348 }
internal/ui/model/lsp.go+1−1
@@ -60,7 +60,7 @@ func (m *UI) lspInfo(width, maxItems int, isSection bool) string {
60
60
61// lspDiagnostics formats diagnostic counts with appropriate icons and colors.
61// lspDiagnostics formats diagnostic counts with appropriate icons and colors.
62func lspDiagnostics(t *styles.Styles, diagnostics map[protocol.DiagnosticSeverity]int) string {
62func lspDiagnostics(t *styles.Styles, diagnostics map[protocol.DiagnosticSeverity]int) string {
63− errs := []string{}
63+ var errs []string
64 if diagnostics[protocol.SeverityError] > 0 {
64 if diagnostics[protocol.SeverityError] > 0 {
65 errs = append(errs, t.LSP.ErrorDiagnostic.Render(fmt.Sprintf("%s%d", styles.LSPErrorIcon, diagnostics[protocol.SeverityError])))
65 errs = append(errs, t.LSP.ErrorDiagnostic.Render(fmt.Sprintf("%s%d", styles.LSPErrorIcon, diagnostics[protocol.SeverityError])))
66 }
66 }
internal/ui/model/mcp.go+1−1
@@ -36,7 +36,7 @@ func (m *UI) mcpInfo(width, maxItems int, isSection bool) string {
36
36
37// mcpCounts formats tool, prompt, and resource counts for display.
37// mcpCounts formats tool, prompt, and resource counts for display.
38func mcpCounts(t *styles.Styles, counts mcp.Counts) string {
38func mcpCounts(t *styles.Styles, counts mcp.Counts) string {
39− parts := []string{}
39+ var parts []string
40 if counts.Tools > 0 {
40 if counts.Tools > 0 {
41 parts = append(parts, t.Subtle.Render(fmt.Sprintf("%d tools", counts.Tools)))
41 parts = append(parts, t.Subtle.Render(fmt.Sprintf("%d tools", counts.Tools)))
42 }
42 }