Skip to content

Commit 6656e11

Browse files
Bump golangci-lint to v2.12.2 and fix new lint findings
Co-Authored-By: shayan <shayan@cognition.ai>
1 parent df38020 commit 6656e11

5 files changed

Lines changed: 12 additions & 8 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: golangci-lint
2121
uses: golangci/golangci-lint-action@v8
2222
with:
23-
version: v2.1
23+
version: v2.12.2

cmd/github-mcp-server/generate_docs.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func generateReadmeDocs(readmePath string) error {
8686
updatedContent = replaceSection(updatedContent, "START AUTOMATED TOOLS", "END AUTOMATED TOOLS", toolsDoc)
8787

8888
// Write back to file
89+
// #nosec G703 - readmePath is controlled by command line flag, not user input
8990
err = os.WriteFile(readmePath, []byte(updatedContent), 0600)
9091
if err != nil {
9192
return fmt.Errorf("failed to write README.md: %w", err)
@@ -117,7 +118,8 @@ func generateRemoteServerDocs(docsPath string) error {
117118

118119
newContent := contentStr[:startIndex] + startMarker + "\n" + toolsetsDoc + "\n" + endMarker + contentStr[endIndex+len(endMarker):]
119120

120-
return os.WriteFile(docsPath, []byte(newContent), 0600) //#nosec G306
121+
// #nosec G306,G703 - docsPath is controlled by command line flag, not user input
122+
return os.WriteFile(docsPath, []byte(newContent), 0600)
121123
}
122124

123125
func generateToolsetsDoc(tsg *toolsets.ToolsetGroup) string {
@@ -340,14 +342,14 @@ func generateRemoteToolsetsDoc() string {
340342
installLink := fmt.Sprintf("[Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-%s&config=%s)", name, installConfig)
341343
readonlyInstallLink := fmt.Sprintf("[Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-%s&config=%s)", name, readonlyConfig)
342344

343-
buf.WriteString(fmt.Sprintf("| %-14s | %-48s | %-53s | %-218s | %-110s | %-288s |\n",
345+
fmt.Fprintf(&buf, "| %-14s | %-48s | %-53s | %-218s | %-110s | %-288s |\n",
344346
formattedName,
345347
description,
346348
apiURL,
347349
installLink,
348350
fmt.Sprintf("[read-only](%s)", readonlyURL),
349351
readonlyInstallLink,
350-
))
352+
)
351353
}
352354

353355
return buf.String()

internal/githubv4mock/query.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func queryArguments(variables map[string]any) string {
8181
// value indicates whether t is a value (required) type or pointer (optional) type.
8282
// If value is true, then "!" is written at the end of t.
8383
func writeArgumentType(w io.Writer, t reflect.Type, value bool) {
84-
if t.Kind() == reflect.Ptr {
84+
if t.Kind() == reflect.Pointer {
8585
// Pointer is an optional type, so no "!" at the end of the pointer's underlying type.
8686
writeArgumentType(w, t.Elem(), false)
8787
return
@@ -122,7 +122,7 @@ func query(v any) string {
122122
// If inline is true, the struct fields of t are inlined into parent struct.
123123
func writeQuery(w io.Writer, t reflect.Type, inline bool) {
124124
switch t.Kind() {
125-
case reflect.Ptr, reflect.Slice:
125+
case reflect.Pointer, reflect.Slice:
126126
writeQuery(w, t.Elem(), false)
127127
case reflect.Struct:
128128
// If the type implements json.Unmarshaler, it's a scalar. Don't expand it.

pkg/github/issues.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,15 +686,15 @@ func (d *mvpDescription) String() string {
686686
sb.WriteString("\n\n")
687687
sb.WriteString("This tool can help with the following outcomes:\n")
688688
for _, outcome := range d.outcomes {
689-
sb.WriteString(fmt.Sprintf("- %s\n", outcome))
689+
fmt.Fprintf(&sb, "- %s\n", outcome)
690690
}
691691
}
692692

693693
if len(d.referenceLinks) > 0 {
694694
sb.WriteString("\n\n")
695695
sb.WriteString("More information can be found at:\n")
696696
for _, link := range d.referenceLinks {
697-
sb.WriteString(fmt.Sprintf("- %s\n", link))
697+
fmt.Fprintf(&sb, "- %s\n", link)
698698
}
699699
}
700700

pkg/github/secret_scanning.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func GetSecretScanningAlert(getClient GetClientFn, t translations.TranslationHel
7272
return mcp.NewToolResultError(fmt.Sprintf("failed to get alert: %s", string(body))), nil
7373
}
7474

75+
// #nosec G117 - returning the alert payload is the purpose of this tool
7576
r, err := json.Marshal(alert)
7677
if err != nil {
7778
return nil, fmt.Errorf("failed to marshal alert: %w", err)
@@ -153,6 +154,7 @@ func ListSecretScanningAlerts(getClient GetClientFn, t translations.TranslationH
153154
return mcp.NewToolResultError(fmt.Sprintf("failed to list alerts: %s", string(body))), nil
154155
}
155156

157+
// #nosec G117 - returning the alert payloads is the purpose of this tool
156158
r, err := json.Marshal(alerts)
157159
if err != nil {
158160
return nil, fmt.Errorf("failed to marshal alerts: %w", err)

0 commit comments

Comments
 (0)