Skip to content

Commit 2a73ba4

Browse files
committed
Fix client/ go lint & format
1 parent c1a86b2 commit 2a73ba4

12 files changed

Lines changed: 96 additions & 96 deletions

client/cmd/code_scanning_download_analysis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ func runDownloadAnalysis(cmd *cobra.Command, _ []string) error {
7676
}
7777
}
7878

79-
fmt.Fprintf(cmd.OutOrStdout(), "Downloaded SARIF to %s (%d bytes)\n", outPath, len(sarif))
79+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Downloaded SARIF to %s (%d bytes)\n", outPath, len(sarif))
8080
return nil
8181
}

client/cmd/code_scanning_list_alerts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ func runListAlerts(cmd *cobra.Command, _ []string) error {
7575
}
7676

7777
w := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 4, 2, ' ', 0)
78-
fmt.Fprintln(w, "NUM\tSTATE\tRULE\tSEVERITY\tFILE:LINE\tCREATED")
78+
_, _ = fmt.Fprintln(w, "NUM\tSTATE\tRULE\tSEVERITY\tFILE:LINE\tCREATED")
7979
for _, a := range alerts {
8080
loc := a.MostRecentInstance.Location
8181
locStr := fmt.Sprintf("%s:%d", loc.Path, loc.StartLine)
82-
fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%s\t%s\n",
82+
_, _ = fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%s\t%s\n",
8383
a.Number, a.State, a.Rule.ID, a.Rule.Severity, locStr, a.CreatedAt)
8484
}
8585
return w.Flush()

client/cmd/code_scanning_list_analyses.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ func runListAnalyses(cmd *cobra.Command, _ []string) error {
7272
}
7373

7474
w := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 4, 2, ' ', 0)
75-
fmt.Fprintln(w, "ID\tTOOL\tREF\tCATEGORY\tRESULTS\tRULES\tCREATED")
75+
_, _ = fmt.Fprintln(w, "ID\tTOOL\tREF\tCATEGORY\tRESULTS\tRULES\tCREATED")
7676
for _, a := range analyses {
77-
fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%d\t%d\t%s\n",
77+
_, _ = fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%d\t%d\t%s\n",
7878
a.ID, a.Tool.Name, a.Ref, a.Category, a.ResultsCount, a.RulesCount, a.CreatedAt)
7979
}
8080
return w.Flush()

client/cmd/integration_tests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func runIntegrationTests(cmd *cobra.Command, _ []string) error {
9595
// server/.tmp/) which causes log directory validation failures.
9696
tmpBase := filepath.Join(repoRoot, ".tmp")
9797
if os.Getenv("CODEQL_MCP_TMP_DIR") == "" {
98-
os.Setenv("CODEQL_MCP_TMP_DIR", tmpBase)
98+
_ = os.Setenv("CODEQL_MCP_TMP_DIR", tmpBase)
9999
}
100100

101101
// Connect to MCP server

client/cmd/list.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func runListTools(_ *cobra.Command, _ []string) error {
6161
if err != nil {
6262
return err
6363
}
64-
defer client.Close()
64+
defer func() { _ = client.Close() }()
6565

6666
tools, err := client.ListTools(ctx)
6767
if err != nil {
@@ -87,15 +87,15 @@ func runListTools(_ *cobra.Command, _ []string) error {
8787
}
8888

8989
w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
90-
fmt.Fprintf(w, "NAME\tDESCRIPTION\n")
90+
_, _ = fmt.Fprintf(w, "NAME\tDESCRIPTION\n")
9191
for _, t := range tools {
9292
desc := t.Description
9393
if len(desc) > 80 {
9494
desc = desc[:77] + "..."
9595
}
96-
fmt.Fprintf(w, "%s\t%s\n", t.Name, desc)
96+
_, _ = fmt.Fprintf(w, "%s\t%s\n", t.Name, desc)
9797
}
98-
w.Flush()
98+
_ = w.Flush()
9999
fmt.Printf("\n%d tools registered\n", len(tools))
100100
return nil
101101
}
@@ -106,7 +106,7 @@ func runListPrompts(_ *cobra.Command, _ []string) error {
106106
if err != nil {
107107
return err
108108
}
109-
defer client.Close()
109+
defer func() { _ = client.Close() }()
110110

111111
prompts, err := client.ListPrompts(ctx)
112112
if err != nil {
@@ -132,15 +132,15 @@ func runListPrompts(_ *cobra.Command, _ []string) error {
132132
}
133133

134134
w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
135-
fmt.Fprintf(w, "NAME\tDESCRIPTION\n")
135+
_, _ = fmt.Fprintf(w, "NAME\tDESCRIPTION\n")
136136
for _, p := range prompts {
137137
desc := p.Description
138138
if len(desc) > 80 {
139139
desc = desc[:77] + "..."
140140
}
141-
fmt.Fprintf(w, "%s\t%s\n", p.Name, desc)
141+
_, _ = fmt.Fprintf(w, "%s\t%s\n", p.Name, desc)
142142
}
143-
w.Flush()
143+
_ = w.Flush()
144144
fmt.Printf("\n%d prompts registered\n", len(prompts))
145145
return nil
146146
}
@@ -151,7 +151,7 @@ func runListResources(_ *cobra.Command, _ []string) error {
151151
if err != nil {
152152
return err
153153
}
154-
defer client.Close()
154+
defer func() { _ = client.Close() }()
155155

156156
resources, err := client.ListResources(ctx)
157157
if err != nil {
@@ -178,15 +178,15 @@ func runListResources(_ *cobra.Command, _ []string) error {
178178
}
179179

180180
w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
181-
fmt.Fprintf(w, "NAME\tURI\tDESCRIPTION\n")
181+
_, _ = fmt.Fprintf(w, "NAME\tURI\tDESCRIPTION\n")
182182
for _, r := range resources {
183183
desc := r.Description
184184
if len(desc) > 60 {
185185
desc = desc[:57] + "..."
186186
}
187-
fmt.Fprintf(w, "%s\t%s\t%s\n", r.Name, r.URI, desc)
187+
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\n", r.Name, r.URI, desc)
188188
}
189-
w.Flush()
189+
_ = w.Flush()
190190
fmt.Printf("\n%d resources registered\n", len(resources))
191191
return nil
192192
}

client/cmd/use_prompt.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func runUsePrompt(_ *cobra.Command, args []string) error {
4141
if err != nil {
4242
return err
4343
}
44-
defer client.Close()
44+
defer func() { _ = client.Close() }()
4545

4646
result, err := mcpclient.GetPrompt(ctx, client, promptName, params)
4747
if err != nil {
@@ -58,11 +58,11 @@ func outputPromptMessages(result *mcpclient.PromptMessages) error {
5858
if err != nil {
5959
return err
6060
}
61-
fmt.Fprintln(os.Stdout, s)
61+
_, _ = fmt.Fprintln(os.Stdout, s)
6262
case "markdown":
63-
fmt.Fprint(os.Stdout, mcpclient.FormatPromptMessagesMarkdown(result))
63+
_, _ = fmt.Fprint(os.Stdout, mcpclient.FormatPromptMessagesMarkdown(result))
6464
default:
65-
fmt.Fprint(os.Stdout, mcpclient.FormatPromptMessagesText(result))
65+
_, _ = fmt.Fprint(os.Stdout, mcpclient.FormatPromptMessagesText(result))
6666
}
6767
return nil
6868
}

client/cmd/use_resource.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func runUseResource(_ *cobra.Command, args []string) error {
3333
if err != nil {
3434
return err
3535
}
36-
defer client.Close()
36+
defer func() { _ = client.Close() }()
3737

3838
result, err := mcpclient.ReadResource(ctx, client, uri)
3939
if err != nil {
@@ -50,11 +50,11 @@ func outputResourceContent(result *mcpclient.ResourceContent) error {
5050
if err != nil {
5151
return err
5252
}
53-
fmt.Fprintln(os.Stdout, s)
53+
_, _ = fmt.Fprintln(os.Stdout, s)
5454
case "markdown":
55-
fmt.Fprint(os.Stdout, mcpclient.FormatResourceContentMarkdown(result))
55+
_, _ = fmt.Fprint(os.Stdout, mcpclient.FormatResourceContentMarkdown(result))
5656
default:
57-
fmt.Fprint(os.Stdout, mcpclient.FormatResourceContentText(result))
57+
_, _ = fmt.Fprint(os.Stdout, mcpclient.FormatResourceContentText(result))
5858
}
5959
return nil
6060
}

client/cmd/use_tool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func runUseTool(_ *cobra.Command, args []string) error {
4242
if err != nil {
4343
return err
4444
}
45-
defer client.Close()
45+
defer func() { _ = client.Close() }()
4646

4747
result, err := mcpclient.CallTool(ctx, client, toolName, params)
4848
if err != nil {
@@ -59,11 +59,11 @@ func outputToolResult(result *mcpclient.ToolResult) error {
5959
if err != nil {
6060
return err
6161
}
62-
fmt.Fprintln(os.Stdout, s)
62+
_, _ = fmt.Fprintln(os.Stdout, s)
6363
case "markdown":
64-
fmt.Fprint(os.Stdout, mcpclient.FormatToolResultMarkdown(result))
64+
_, _ = fmt.Fprint(os.Stdout, mcpclient.FormatToolResultMarkdown(result))
6565
default:
66-
fmt.Fprint(os.Stdout, mcpclient.FormatToolResultText(result))
66+
_, _ = fmt.Fprint(os.Stdout, mcpclient.FormatToolResultText(result))
6767
}
6868
if result.IsError {
6969
return fmt.Errorf("tool returned error")

client/internal/mcp/primitives.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ func FormatResourceContentText(rc *ResourceContent) string {
195195
sb.WriteString("\n---\n")
196196
}
197197
if item.URI != "" {
198-
sb.WriteString(fmt.Sprintf("URI: %s\n", item.URI))
198+
fmt.Fprintf(&sb, "URI: %s\n", item.URI)
199199
}
200200
if item.MIMEType != "" {
201-
sb.WriteString(fmt.Sprintf("Type: %s\n", item.MIMEType))
201+
fmt.Fprintf(&sb, "Type: %s\n", item.MIMEType)
202202
}
203203
sb.WriteString("\n")
204204
sb.WriteString(item.Text)
@@ -211,13 +211,13 @@ func FormatResourceContentText(rc *ResourceContent) string {
211211
func FormatPromptMessagesText(pm *PromptMessages) string {
212212
var sb strings.Builder
213213
if pm.Description != "" {
214-
sb.WriteString(fmt.Sprintf("Description: %s\n\n", pm.Description))
214+
fmt.Fprintf(&sb, "Description: %s\n\n", pm.Description)
215215
}
216216
for i, msg := range pm.Messages {
217217
if i > 0 {
218218
sb.WriteString("\n---\n")
219219
}
220-
sb.WriteString(fmt.Sprintf("[%s]\n", msg.Role))
220+
fmt.Fprintf(&sb, "[%s]\n", msg.Role)
221221
sb.WriteString(msg.Content)
222222
sb.WriteString("\n")
223223
}
@@ -254,13 +254,13 @@ func FormatResourceContentMarkdown(rc *ResourceContent) string {
254254
func FormatPromptMessagesMarkdown(pm *PromptMessages) string {
255255
var sb strings.Builder
256256
if pm.Description != "" {
257-
sb.WriteString(fmt.Sprintf("*%s*\n\n", pm.Description))
257+
fmt.Fprintf(&sb, "*%s*\n\n", pm.Description)
258258
}
259259
for i, msg := range pm.Messages {
260260
if i > 0 {
261261
sb.WriteString("\n---\n\n")
262262
}
263-
sb.WriteString(fmt.Sprintf("### %s\n\n", msg.Role))
263+
fmt.Fprintf(&sb, "### %s\n\n", msg.Role)
264264
sb.WriteString(msg.Content)
265265
sb.WriteString("\n")
266266
}

0 commit comments

Comments
 (0)