Skip to content

Commit 90f7916

Browse files
staticcheck: fix warnings in x/mongo/driver/topology
1 parent 5204f46 commit 90f7916

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

x/mongo/driver/topology/CMAP_spec_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ func runOperationInThread(t *testing.T, operation map[string]any, testInfo *test
428428
}
429429

430430
for {
431+
// nolint:staticcheck // QF1006: staticcheck solution onflicts with revive
431432
if atomic.LoadInt32(&thread.JobsCompleted) == atomic.LoadInt32(&thread.JobsAssigned) {
432433
break
433434
}

x/mongo/driver/topology/connection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ var (
654654
_ driver.Expirable = (*Connection)(nil)
655655
)
656656

657-
// WriteWireMessage handles writing a wire message to the underlying connection.
657+
// Write handles writing a wire message to the underlying connection.
658658
func (c *Connection) Write(ctx context.Context, wm []byte) error {
659659
c.mu.RLock()
660660
defer c.mu.RUnlock()
@@ -664,8 +664,8 @@ func (c *Connection) Write(ctx context.Context, wm []byte) error {
664664
return c.connection.writeWireMessage(ctx, wm)
665665
}
666666

667-
// ReadWireMessage handles reading a wire message from the underlying connection. The dst parameter
668-
// will be overwritten with the new wire message.
667+
// Read handles reading a wire message from the underlying connection. The dst
668+
// parameter will be overwritten with the new wire message.
669669
func (c *Connection) Read(ctx context.Context) ([]byte, error) {
670670
c.mu.RLock()
671671
defer c.mu.RUnlock()

x/mongo/driver/topology/server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func TestServerConnectionTimeout(t *testing.T) {
365365
}
366366

367367
func TestServer(t *testing.T) {
368-
var serverTestTable = []struct {
368+
serverTestTable := []struct {
369369
name string
370370
connectionError bool
371371
networkError bool
@@ -1280,7 +1280,7 @@ func includesClientMetadata(t *testing.T, wm []byte) bool {
12801280
t.Fatal("could not read numberToReturn")
12811281
}
12821282
var query bsoncore.Document
1283-
query, wm, ok = wiremessage.ReadQueryQuery(wm)
1283+
query, _, ok = wiremessage.ReadQueryQuery(wm)
12841284
if !ok {
12851285
t.Fatal("could not read query")
12861286
}

x/mongo/driver/topology/topology.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,10 @@ func (t *Topology) SelectServer(ctx context.Context, ss description.ServerSelect
549549
// try again if there are no servers available
550550
if mustLogServerSelection(t, logger.LevelInfo) {
551551
elapsed := time.Since(startTime)
552-
remainingTimeMS := t.cfg.ServerSelectionTimeout - elapsed
552+
remainingTime := t.cfg.ServerSelectionTimeout - elapsed
553553

554554
logServerSelection(ctx, t, logger.LevelInfo, logger.ServerSelectionWaiting, ss,
555-
logger.KeyRemainingTimeMS, remainingTimeMS.Milliseconds())
555+
logger.KeyRemainingTimeMS, remainingTime.Milliseconds())
556556
}
557557

558558
continue
@@ -687,7 +687,6 @@ func (t *Topology) selectServerFromSubscription(
687687
subscriptionCh <-chan description.Topology,
688688
srvSelector description.ServerSelector,
689689
) ([]description.Server, error) {
690-
691690
current := t.Description()
692691
for {
693692
select {
@@ -713,7 +712,6 @@ func (t *Topology) selectServerFromDescription(
713712
desc description.Topology,
714713
srvSelector description.ServerSelector,
715714
) ([]description.Server, error) {
716-
717715
// Unlike selectServerFromSubscription, this code path does not check ctx.Done or selectionState.timeoutChan because
718716
// selecting a server from a description is not a blocking operation.
719717

0 commit comments

Comments
 (0)