From fd80f4dbb3ea5dabcb46d7b90f8353a7d4981278 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Sat, 8 Aug 2020 11:15:22 -0400 Subject: [PATCH] internal/lsp: fix a few small staticcheck warnings Address unused context / unused error warnings. Change-Id: Ibd302d58a3d6db5aa274ed95fb6d5a337978779a Reviewed-on: https://go-review.googlesource.com/c/tools/+/247597 Run-TryBot: Rebecca Stambler Reviewed-by: Danish Dua --- internal/lsp/lsp_test.go | 12 +++++++++--- internal/lsp/source/call_hierarchy.go | 6 ++++++ internal/lsp/source/source_test.go | 12 +++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/internal/lsp/lsp_test.go b/internal/lsp/lsp_test.go index 1f12bca98b..bda2092cb1 100644 --- a/internal/lsp/lsp_test.go +++ b/internal/lsp/lsp_test.go @@ -129,17 +129,23 @@ func (r *runner) CallHierarchy(t *testing.T, spn span.Span, expectedCalls *tests Range: items[0].Range, } if callLocation != loc { - t.Errorf("expected server.PrepareCallHierarchy to return identifier at %v but got %v\n", loc, callLocation) + t.Fatalf("expected server.PrepareCallHierarchy to return identifier at %v but got %v\n", loc, callLocation) } // TODO: add span comparison tests for expectedCalls once call hierarchy is implemented incomingCalls, err := r.server.IncomingCalls(r.ctx, &protocol.CallHierarchyIncomingCallsParams{Item: items[0]}) + if err != nil { + t.Fatal(err) + } if len(incomingCalls) != 0 { - t.Errorf("expected no incoming calls but got %d", len(incomingCalls)) + t.Fatalf("expected no incoming calls but got %d", len(incomingCalls)) } outgoingCalls, err := r.server.OutgoingCalls(r.ctx, &protocol.CallHierarchyOutgoingCallsParams{Item: items[0]}) + if err != nil { + t.Fatal(err) + } if len(outgoingCalls) != 0 { - t.Errorf("expected no outgoing calls but got %d", len(outgoingCalls)) + t.Fatalf("expected no outgoing calls but got %d", len(outgoingCalls)) } } diff --git a/internal/lsp/source/call_hierarchy.go b/internal/lsp/source/call_hierarchy.go index 6ec7a714a7..23425b9225 100644 --- a/internal/lsp/source/call_hierarchy.go +++ b/internal/lsp/source/call_hierarchy.go @@ -56,6 +56,9 @@ func IncomingCalls(ctx context.Context, snapshot Snapshot, fh FileHandle, pos pr ctx, done := event.Start(ctx, "source.incomingCalls") defer done() + // TODO: Remove this once the context is used. + _ = ctx // avoid staticcheck SA4006 warning + return []protocol.CallHierarchyIncomingCall{}, nil } @@ -64,5 +67,8 @@ func OutgoingCalls(ctx context.Context, snapshot Snapshot, fh FileHandle, pos pr ctx, done := event.Start(ctx, "source.outgoingCalls") defer done() + // TODO: Remove this once the context is used. + _ = ctx // avoid staticcheck SA4006 warning + return []protocol.CallHierarchyOutgoingCall{}, nil } diff --git a/internal/lsp/source/source_test.go b/internal/lsp/source/source_test.go index 8bc69f3ace..5906ccfd5f 100644 --- a/internal/lsp/source/source_test.go +++ b/internal/lsp/source/source_test.go @@ -123,17 +123,23 @@ func (r *runner) CallHierarchy(t *testing.T, spn span.Span, expectedCalls *tests Range: items[0].Range, } if callLocation != loc { - t.Errorf("expected source.PrepareCallHierarchy to return identifier at %v but got %v\n", loc, callLocation) + t.Fatalf("expected source.PrepareCallHierarchy to return identifier at %v but got %v\n", loc, callLocation) } // TODO: add span comparison tests for expectedCalls once call hierarchy is implemented incomingCalls, err := source.IncomingCalls(r.ctx, r.snapshot, fh, loc.Range.Start) + if err != nil { + t.Fatal(err) + } if len(incomingCalls) != 0 { - t.Errorf("expected no incoming calls but got %d", len(incomingCalls)) + t.Fatalf("expected no incoming calls but got %d", len(incomingCalls)) } outgoingCalls, err := source.OutgoingCalls(r.ctx, r.snapshot, fh, loc.Range.Start) + if err != nil { + t.Fatal(err) + } if len(outgoingCalls) != 0 { - t.Errorf("expected no outgoing calls but got %d", len(outgoingCalls)) + t.Fatalf("expected no outgoing calls but got %d", len(outgoingCalls)) } }