Skip to content

Commit 8cf70e9

Browse files
authored
Merge pull request #2 from pujidjayanto/add-lint-config
chore: add lint configuration and fix lint issue
2 parents d8e9e66 + ad9b800 commit 8cf70e9

File tree

7 files changed

+241
-117
lines changed

7 files changed

+241
-117
lines changed

.golangci.yaml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
version: "2"
2+
run:
3+
issues-exit-code: 1
4+
output:
5+
formats:
6+
text:
7+
path: stdout
8+
print-linter-name: true
9+
print-issued-lines: true
10+
linters:
11+
default: none
12+
enable:
13+
- depguard
14+
- exhaustive
15+
- goconst
16+
- gocyclo
17+
- gosec
18+
- govet
19+
- ineffassign
20+
- lll
21+
- paralleltest
22+
- promlinter
23+
- revive
24+
- staticcheck
25+
- thelper
26+
- tparallel
27+
- unparam
28+
- unused
29+
settings:
30+
depguard:
31+
rules:
32+
prevent_unmaintained_packages:
33+
list-mode: lax
34+
files:
35+
- $all
36+
- '!$test'
37+
deny:
38+
- pkg: io/ioutil
39+
desc: this is deprecated
40+
gocyclo:
41+
min-complexity: 15
42+
gosec:
43+
excludes:
44+
- G601
45+
lll:
46+
line-length: 130
47+
revive:
48+
severity: warning
49+
rules:
50+
- name: blank-imports
51+
severity: warning
52+
- name: context-as-argument
53+
- name: context-keys-type
54+
- name: duplicated-imports
55+
- name: error-naming
56+
- name: error-return
57+
- name: exported
58+
severity: error
59+
- name: if-return
60+
- name: identical-branches
61+
- name: indent-error-flow
62+
- name: import-shadowing
63+
- name: package-comments
64+
- name: redefines-builtin-id
65+
- name: struct-tag
66+
- name: unconditional-recursion
67+
- name: unnecessary-stmt
68+
- name: unreachable-code
69+
- name: unused-parameter
70+
- name: unused-receiver
71+
- name: unhandled-error
72+
disabled: true
73+
exclusions:
74+
generated: lax
75+
rules:
76+
- linters:
77+
- lll
78+
- gocyclo
79+
- errcheck
80+
- dupl
81+
- gosec
82+
- paralleltest
83+
path: (.+)_test\.go
84+
- linters:
85+
- lll
86+
path: .golangci.yml
87+
paths:
88+
- third_party$
89+
- builtin$
90+
- examples$
91+
formatters:
92+
enable:
93+
- gci
94+
- gofmt
95+
settings:
96+
gci:
97+
sections:
98+
- standard
99+
- default
100+
- prefix(github.com/StacklokLabs/osv-mcp)
101+
exclusions:
102+
generated: lax
103+
paths:
104+
- third_party$
105+
- builtin$
106+
- examples$

cmd/server/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main provides the entry point for the OSV MCP Server.
12
package main
23

34
import (
@@ -45,4 +46,4 @@ func main() {
4546
}
4647

4748
log.Println("Shutting down server")
48-
}
49+
}

cmd/server/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ func TestCreateServer(t *testing.T) {
2424
// Verify server properties
2525
assert.Equal(t, mcp.ServerName, "osv-mcp")
2626
assert.Equal(t, mcp.ServerVersion, "0.1.0")
27-
}
27+
}

pkg/mcp/server.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package mcp provides MCP server tools for OSV.
12
package mcp
23

34
import (
@@ -15,7 +16,7 @@ import (
1516
const (
1617
// ServerName is the name of the MCP server
1718
ServerName = "osv-mcp"
18-
19+
1920
// ServerVersion is the version of the MCP server
2021
ServerVersion = "0.1.0"
2122
)
@@ -235,7 +236,9 @@ func (s *Server) handleQueryVulnerabilitiesBatch(ctx context.Context, request mc
235236
}
236237

237238
if purl != "" && (packageName != "" || ecosystem != "") {
238-
return mcp.NewToolResultError(fmt.Sprintf("If purl is specified, package_name and ecosystem should not be specified in query %d", i)), nil
239+
return mcp.NewToolResultError(
240+
fmt.Sprintf("If purl is specified, package_name and ecosystem should not be specified in query %d", i),
241+
), nil
239242
}
240243

241244
// Create query request
@@ -293,4 +296,4 @@ func (s *Server) handleGetVulnerability(ctx context.Context, request mcp.CallToo
293296
}
294297

295298
return mcp.NewToolResultText(string(result)), nil
296-
}
299+
}

0 commit comments

Comments
 (0)