Skip to content

Commit 205b619

Browse files
feat: upgrade golangci-lint to v2 (#386)
Co-authored-by: William Martin <williammartin@github.com>
1 parent 2d6e3dd commit 205b619

File tree

7 files changed

+41
-22
lines changed

7 files changed

+41
-22
lines changed

.github/workflows/lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
go mod verify
2525
go mod download
2626
27-
LINT_VERSION=1.64.8
27+
LINT_VERSION=2.1.6
2828
curl -fsSL https://github.com/golangci/golangci-lint/releases/download/v${LINT_VERSION}/golangci-lint-${LINT_VERSION}-linux-amd64.tar.gz | \
2929
tar xz --strip-components 1 --wildcards \*/golangci-lint
3030
mkdir -p bin && mv golangci-lint bin/
@@ -45,6 +45,6 @@ jobs:
4545
assert-nothing-changed go fmt ./...
4646
assert-nothing-changed go mod tidy
4747
48-
bin/golangci-lint run --out-format=colored-line-number --timeout=3m || STATUS=$?
48+
bin/golangci-lint run --timeout=3m || STATUS=$?
4949
5050
exit $STATUS

.golangci.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# https://golangci-lint.run/usage/configuration
2+
version: "2"
3+
14
run:
25
timeout: 5m
36
tests: true
@@ -8,21 +11,37 @@ linters:
811
- govet
912
- errcheck
1013
- staticcheck
11-
- gofmt
12-
- goimports
1314
- revive
1415
- ineffassign
15-
- typecheck
1616
- unused
17-
- gosimple
1817
- misspell
1918
- nakedret
2019
- bodyclose
2120
- gocritic
2221
- makezero
2322
- gosec
23+
settings:
24+
staticcheck:
25+
checks:
26+
- all
27+
- '-QF1008' # Allow embedded structs to be referenced by field
28+
- '-ST1000' # Do not require package comments
29+
revive:
30+
rules:
31+
- name: exported
32+
disabled: true
33+
- name: exported
34+
disabled: true
35+
- name: package-comments
36+
disabled: true
37+
38+
formatters:
39+
enable:
40+
- gofmt
41+
- goimports
2442

2543
output:
26-
formats: colored-line-number
27-
print-issued-lines: true
28-
print-linter-name: true
44+
formats:
45+
text:
46+
print-linter-name: true
47+
print-issued-lines: true

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Please note that this project is released with a [Contributor Code of Conduct](C
1515
These are one time installations required to be able to test your changes locally as part of the pull request (PR) submission process.
1616

1717
1. install Go [through download](https://go.dev/doc/install) | [through Homebrew](https://formulae.brew.sh/formula/go)
18-
1. [install golangci-lint](https://golangci-lint.run/welcome/install/#local-installation)
18+
1. [install golangci-lint v2](https://golangci-lint.run/welcome/install/#local-installation)
1919

2020
## Submitting a pull request
2121

cmd/mcpcurl/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type (
7777
Arguments map[string]interface{} `json:"arguments"`
7878
}
7979

80-
// Define structure to match the response format
80+
// Content matches the response format of a text content response
8181
Content struct {
8282
Type string `json:"type"`
8383
Text string `json:"text"`
@@ -284,10 +284,10 @@ func addCommandFromTool(toolsCmd *cobra.Command, tool *Tool, prettyPrint bool) {
284284
cmd.Flags().Bool(name, false, description)
285285
case "array":
286286
if prop.Items != nil {
287-
if prop.Items.Type == "string" {
287+
switch prop.Items.Type {
288+
case "string":
288289
cmd.Flags().StringSlice(name, []string{}, description)
289-
} else if prop.Items.Type == "object" {
290-
// For complex objects in arrays, we'll use a JSON string that users can provide
290+
case "object":
291291
cmd.Flags().String(name+"-json", "", description+" (provide as JSON array)")
292292
}
293293
}
@@ -327,11 +327,12 @@ func buildArgumentsMap(cmd *cobra.Command, tool *Tool) (map[string]interface{},
327327
}
328328
case "array":
329329
if prop.Items != nil {
330-
if prop.Items.Type == "string" {
330+
switch prop.Items.Type {
331+
case "string":
331332
if values, _ := cmd.Flags().GetStringSlice(name); len(values) > 0 {
332333
arguments[name] = values
333334
}
334-
} else if prop.Items.Type == "object" {
335+
case "object":
335336
if jsonStr, _ := cmd.Flags().GetString(name + "-json"); jsonStr != "" {
336337
var jsonArray []interface{}
337338
if err := json.Unmarshal([]byte(jsonStr), &jsonArray); err != nil {

internal/ghmcp/server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/github/github-mcp-server/pkg/translations"
1515
gogithub "github.com/google/go-github/v69/github"
1616
"github.com/mark3labs/mcp-go/mcp"
17-
1817
"github.com/mark3labs/mcp-go/server"
1918
"github.com/sirupsen/logrus"
2019
)
@@ -170,7 +169,7 @@ func RunStdioServer(cfg StdioServerConfig) error {
170169

171170
logrusLogger := logrus.New()
172171
if cfg.LogFilePath != "" {
173-
file, err := os.OpenFile(cfg.LogFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
172+
file, err := os.OpenFile(cfg.LogFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
174173
if err != nil {
175174
return fmt.Errorf("failed to open log file: %w", err)
176175
}

pkg/github/repositories.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ func CreateBranch(getClient GetClientFn, t translations.TranslationHelperFunc) (
612612
if err != nil {
613613
return nil, fmt.Errorf("failed to get repository: %w", err)
614614
}
615-
defer resp.Body.Close()
615+
defer func() { _ = resp.Body.Close() }()
616616

617617
fromBranch = *repository.DefaultBranch
618618
}
@@ -622,7 +622,7 @@ func CreateBranch(getClient GetClientFn, t translations.TranslationHelperFunc) (
622622
if err != nil {
623623
return nil, fmt.Errorf("failed to get reference: %w", err)
624624
}
625-
defer resp.Body.Close()
625+
defer func() { _ = resp.Body.Close() }()
626626

627627
// Create new branch
628628
newRef := &github.Reference{
@@ -634,7 +634,7 @@ func CreateBranch(getClient GetClientFn, t translations.TranslationHelperFunc) (
634634
if err != nil {
635635
return nil, fmt.Errorf("failed to create branch: %w", err)
636636
}
637-
defer resp.Body.Close()
637+
defer func() { _ = resp.Body.Close() }()
638638

639639
r, err := json.Marshal(createdRef)
640640
if err != nil {

pkg/translations/translations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TranslationHelper() (TranslationHelperFunc, func()) {
5656
}
5757
}
5858

59-
// dump translationKeyMap to a json file called github-mcp-server-config.json
59+
// DumpTranslationKeyMap writes the translation map to a json file called github-mcp-server-config.json
6060
func DumpTranslationKeyMap(translationKeyMap map[string]string) error {
6161
file, err := os.Create("github-mcp-server-config.json")
6262
if err != nil {

0 commit comments

Comments
 (0)