.github: add a staticcheck action (#326)
Add a staticcheck step to the lint job of the Test workflow, and fix reported diagnostics.
This commit is contained in:
parent
3db848abec
commit
46ba813860
5 changed files with 11 additions and 14 deletions
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
|
@ -30,6 +30,10 @@ jobs:
|
||||||
echo "All Go files are properly formatted"
|
echo "All Go files are properly formatted"
|
||||||
- name: Run Go vet
|
- name: Run Go vet
|
||||||
run: go vet ./...
|
run: go vet ./...
|
||||||
|
- name: Run staticcheck
|
||||||
|
uses: dominikh/staticcheck-action@v1
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
||||||
|
|
@ -719,10 +719,10 @@ func (c *Connection) processResult(from any, req *incomingRequest, result any, e
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
err = fmt.Errorf("%w: %q notification failed: %v", ErrInternal, req.Method, err)
|
err = fmt.Errorf("%w: %q notification failed: %v", ErrInternal, req.Method, err)
|
||||||
}
|
}
|
||||||
if err != nil {
|
}
|
||||||
// TODO: can/should we do anything with this error beyond writing it to the event log?
|
if err != nil {
|
||||||
// (Is this the right label to attach to the log?)
|
// TODO: can/should we do anything with this error beyond writing it to the event log?
|
||||||
}
|
// (Is this the right label to attach to the log?)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cancel the request to free any associated resources.
|
// Cancel the request to free any associated resources.
|
||||||
|
|
|
||||||
|
|
@ -178,10 +178,6 @@ type clientSessionState struct {
|
||||||
|
|
||||||
func (cs *ClientSession) InitializeResult() *InitializeResult { return cs.state.InitializeResult }
|
func (cs *ClientSession) InitializeResult() *InitializeResult { return cs.state.InitializeResult }
|
||||||
|
|
||||||
func (cs *ClientSession) setConn(c Connection) {
|
|
||||||
cs.mcpConn = c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cs *ClientSession) ID() string {
|
func (cs *ClientSession) ID() string {
|
||||||
if c, ok := cs.mcpConn.(hasSessionID); ok {
|
if c, ok := cs.mcpConn.(hasSessionID); ok {
|
||||||
return c.SessionID()
|
return c.SessionID()
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ func (h *StreamableHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
|
||||||
var transport *StreamableServerTransport
|
var transport *StreamableServerTransport
|
||||||
if id := req.Header.Get(sessionIDHeader); id != "" {
|
if id := req.Header.Get(sessionIDHeader); id != "" {
|
||||||
h.mu.Lock()
|
h.mu.Lock()
|
||||||
transport, _ = h.transports[id]
|
transport = h.transports[id]
|
||||||
h.mu.Unlock()
|
h.mu.Unlock()
|
||||||
if transport == nil {
|
if transport == nil {
|
||||||
http.Error(w, "session not found", http.StatusNotFound)
|
http.Error(w, "session not found", http.StatusNotFound)
|
||||||
|
|
@ -288,9 +288,6 @@ type streamableServerConn struct {
|
||||||
jsonResponse bool
|
jsonResponse bool
|
||||||
eventStore EventStore
|
eventStore EventStore
|
||||||
|
|
||||||
lastStreamID atomic.Int64 // last stream ID used, atomically incremented
|
|
||||||
|
|
||||||
opts StreamableServerTransportOptions
|
|
||||||
incoming chan jsonrpc.Message // messages from the client to the server
|
incoming chan jsonrpc.Message // messages from the client to the server
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -539,10 +539,10 @@ func TestStreamableServerTransport(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "background",
|
name: "background",
|
||||||
tool: func(t *testing.T, ctx context.Context, ss *ServerSession) {
|
tool: func(t *testing.T, _ context.Context, ss *ServerSession) {
|
||||||
// Perform operations on a background context, and ensure the client
|
// Perform operations on a background context, and ensure the client
|
||||||
// receives it.
|
// receives it.
|
||||||
ctx = context.Background()
|
ctx := context.Background()
|
||||||
if err := ss.NotifyProgress(ctx, &ProgressNotificationParams{}); err != nil {
|
if err := ss.NotifyProgress(ctx, &ProgressNotificationParams{}); err != nil {
|
||||||
t.Errorf("Notify failed: %v", err)
|
t.Errorf("Notify failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue