Skip to content

Commit 46ba813

Browse files
authored
.github: add a staticcheck action (#326)
Add a staticcheck step to the lint job of the Test workflow, and fix reported diagnostics.
1 parent 3db848a commit 46ba813

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
echo "All Go files are properly formatted"
3131
- name: Run Go vet
3232
run: go vet ./...
33+
- name: Run staticcheck
34+
uses: dominikh/staticcheck-action@v1
35+
with:
36+
version: "latest"
3337

3438
test:
3539
runs-on: ubuntu-latest

internal/jsonrpc2/conn.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,10 @@ func (c *Connection) processResult(from any, req *incomingRequest, result any, e
719719
} else if err != nil {
720720
err = fmt.Errorf("%w: %q notification failed: %v", ErrInternal, req.Method, err)
721721
}
722-
if err != nil {
723-
// TODO: can/should we do anything with this error beyond writing it to the event log?
724-
// (Is this the right label to attach to the log?)
725-
}
722+
}
723+
if err != nil {
724+
// TODO: can/should we do anything with this error beyond writing it to the event log?
725+
// (Is this the right label to attach to the log?)
726726
}
727727

728728
// Cancel the request to free any associated resources.

mcp/client.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,6 @@ type clientSessionState struct {
178178

179179
func (cs *ClientSession) InitializeResult() *InitializeResult { return cs.state.InitializeResult }
180180

181-
func (cs *ClientSession) setConn(c Connection) {
182-
cs.mcpConn = c
183-
}
184-
185181
func (cs *ClientSession) ID() string {
186182
if c, ok := cs.mcpConn.(hasSessionID); ok {
187183
return c.SessionID()

mcp/streamable.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (h *StreamableHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
121121
var transport *StreamableServerTransport
122122
if id := req.Header.Get(sessionIDHeader); id != "" {
123123
h.mu.Lock()
124-
transport, _ = h.transports[id]
124+
transport = h.transports[id]
125125
h.mu.Unlock()
126126
if transport == nil {
127127
http.Error(w, "session not found", http.StatusNotFound)
@@ -288,9 +288,6 @@ type streamableServerConn struct {
288288
jsonResponse bool
289289
eventStore EventStore
290290

291-
lastStreamID atomic.Int64 // last stream ID used, atomically incremented
292-
293-
opts StreamableServerTransportOptions
294291
incoming chan jsonrpc.Message // messages from the client to the server
295292
done chan struct{}
296293

mcp/streamable_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,10 @@ func TestStreamableServerTransport(t *testing.T) {
539539
},
540540
{
541541
name: "background",
542-
tool: func(t *testing.T, ctx context.Context, ss *ServerSession) {
542+
tool: func(t *testing.T, _ context.Context, ss *ServerSession) {
543543
// Perform operations on a background context, and ensure the client
544544
// receives it.
545-
ctx = context.Background()
545+
ctx := context.Background()
546546
if err := ss.NotifyProgress(ctx, &ProgressNotificationParams{}); err != nil {
547547
t.Errorf("Notify failed: %v", err)
548548
}

0 commit comments

Comments
 (0)