CI/build: Update Go version, linters and fix minor issues (#1473)

* CI/build: Update Go version, linters and fix minor issues

* Bump golangci-lint to v1.56.1

* BinanceUS: Make uint usage consistent

* Throw blank identifiers into the trash
This commit is contained in:
Adrian Gallagher
2024-02-14 11:02:06 +11:00
committed by GitHub
parent 9ff502bac2
commit 08da42ddb7
79 changed files with 364 additions and 374 deletions

View File

@@ -460,7 +460,7 @@ func TestOrderbookLastUpdateID(t *testing.T) {
exp, itemArray[1][0].Price)
}
holder.checksum = func(state *orderbook.Base, checksum uint32) error { return errors.New("testerino") }
holder.checksum = func(*orderbook.Base, uint32) error { return errors.New("testerino") }
// this update invalidates the book
err = holder.Update(&orderbook.Update{
@@ -479,7 +479,7 @@ func TestOrderbookLastUpdateID(t *testing.T) {
t.Fatal(err)
}
holder.checksum = func(state *orderbook.Base, checksum uint32) error { return nil }
holder.checksum = func(*orderbook.Base, uint32) error { return nil }
holder.updateIDProgression = true
for i := range itemArray {

View File

@@ -893,8 +893,8 @@ func (w *Websocket) GetChannelDifference(genSubs []subscription.Subscription) (s
}
}
for _, c := range unsubMap {
unsub = append(unsub, c)
for x := range unsubMap {
unsub = append(unsub, unsubMap[x])
}
return
@@ -988,7 +988,7 @@ func (w *Websocket) AddSuccessfulSubscriptions(channels ...subscription.Subscrip
if w.subscriptions == nil {
w.subscriptions = subscriptionMap{}
}
for _, cN := range channels {
for _, cN := range channels { //nolint:gocritic // See below comment
c := cN // cN is an iteration var; Not safe to make a pointer to
key := c.EnsureKeyed()
c.State = subscription.SubscribedState

View File

@@ -73,8 +73,8 @@ var defaultSetup = &WebsocketSetup{
DefaultURL: "testDefaultURL",
RunningURL: "wss://testRunningURL",
Connector: func() error { return nil },
Subscriber: func(_ []subscription.Subscription) error { return nil },
Unsubscriber: func(_ []subscription.Subscription) error { return nil },
Subscriber: func([]subscription.Subscription) error { return nil },
Unsubscriber: func([]subscription.Subscription) error { return nil },
GenerateSubscriptions: func() ([]subscription.Subscription, error) {
return []subscription.Subscription{
{Channel: "TestSub"},
@@ -593,11 +593,11 @@ func TestSubscriptionState(t *testing.T) {
ws.AddSuccessfulSubscriptions(*c)
found = ws.GetSubscription(42)
assert.NotNil(t, found, "Should find the subscription")
assert.Equal(t, found.State, subscription.SubscribedState, "Subscription should be subscribed state")
assert.Equal(t, subscription.SubscribedState, found.State, "Subscription should be subscribed state")
assert.NoError(t, ws.SetSubscriptionState(c, subscription.UnsubscribingState), "Setting Unsub state should not error")
found = ws.GetSubscription(42)
assert.Equal(t, found.State, subscription.UnsubscribingState, "Subscription should be unsubscribing state")
assert.Equal(t, subscription.UnsubscribingState, found.State, "Subscription should be unsubscribing state")
}
// TestRemoveSubscriptions tests removing a subscription
@@ -1060,7 +1060,7 @@ func TestGetChannelDifference(t *testing.T) {
}
subs, unsubs := web.GetChannelDifference(newChans)
assert.Len(t, subs, 3, "Should get the correct number of subs")
assert.Len(t, unsubs, 0, "Should get the correct number of unsubs")
assert.Empty(t, unsubs, "Should get the correct number of unsubs")
web.AddSuccessfulSubscriptions(subs...)
@@ -1071,7 +1071,7 @@ func TestGetChannelDifference(t *testing.T) {
}
subs, unsubs = web.GetChannelDifference(flushedSubs)
assert.Len(t, subs, 0, "Should get the correct number of subs")
assert.Empty(t, subs, "Should get the correct number of subs")
assert.Len(t, unsubs, 2, "Should get the correct number of unsubs")
flushedSubs = []subscription.Subscription{
@@ -1085,12 +1085,12 @@ func TestGetChannelDifference(t *testing.T) {
subs, unsubs = web.GetChannelDifference(flushedSubs)
if assert.Len(t, subs, 1, "Should get the correct number of subs") {
assert.Equal(t, subs[0].Channel, "Test4", "Should subscribe to the right channel")
assert.Equal(t, "Test4", subs[0].Channel, "Should subscribe to the right channel")
}
if assert.Len(t, unsubs, 2, "Should get the correct number of unsubs") {
sort.Slice(unsubs, func(i, j int) bool { return unsubs[i].Channel <= unsubs[j].Channel })
assert.Equal(t, unsubs[0].Channel, "Test1", "Should unsubscribe from the right channels")
assert.Equal(t, unsubs[1].Channel, "Test3", "Should unsubscribe from the right channels")
assert.Equal(t, "Test1", unsubs[0].Channel, "Should unsubscribe from the right channels")
assert.Equal(t, "Test3", unsubs[1].Channel, "Should unsubscribe from the right channels")
}
}
@@ -1283,7 +1283,7 @@ func TestEnable(t *testing.T) {
GenerateSubs: func() ([]subscription.Subscription, error) {
return []subscription.Subscription{{Channel: "test"}}, nil
},
Subscriber: func(cs []subscription.Subscription) error { return nil },
Subscriber: func([]subscription.Subscription) error { return nil },
}
err := web.Enable()