linters: Exclude govet shadow check on exchange instances (#2097)

* Linters: Exclude govet shadow check on e in tests

* Linters: Remove nolint rule for new(Exchange) in tests

Replay with:
```
perl -pi -e 's{(\se\s:=\s.*?)\s*//nolint:govet // Intentional shadow.*}{$1}' **/*_test.go
```
This commit is contained in:
Gareth Kirwan
2025-10-29 05:30:23 +07:00
committed by GitHub
parent a7ff3efdcc
commit 5d6755b76e
23 changed files with 106 additions and 102 deletions

View File

@@ -2088,7 +2088,7 @@ func TestCrossMarginBalanceLoan(t *testing.T) {
// TestFuturesDataHandler ensures that messages from various futures channels do not error
func TestFuturesDataHandler(t *testing.T) {
t.Parallel()
e := new(Exchange) //nolint:govet // Intentional shadow
e := new(Exchange)
require.NoError(t, testexch.Setup(e), "Test instance Setup must not error")
testexch.FixtureToDataHandler(t, "testdata/wsFutures.json", func(ctx context.Context, m []byte) error {
if strings.Contains(string(m), "futures.balances") {
@@ -2283,7 +2283,7 @@ func TestOptionsPongPushData(t *testing.T) {
func TestGenerateSubscriptionsSpot(t *testing.T) {
t.Parallel()
e := new(Exchange) //nolint:govet // Intentional shadow
e := new(Exchange)
require.NoError(t, testexch.Setup(e), "Test instance Setup must not error")
e.Websocket.SetCanUseAuthenticatedEndpoints(true)
@@ -2343,7 +2343,7 @@ func TestGenerateDeliveryFuturesDefaultSubscriptions(t *testing.T) {
func TestGenerateFuturesDefaultSubscriptions(t *testing.T) {
t.Parallel()
e := new(Exchange) //nolint:govet // Intentional shadow
e := new(Exchange)
require.NoError(t, testexch.Setup(e), "Test instance Setup must not error")
subs, err := e.GenerateFuturesDefaultSubscriptions(asset.USDTMarginedFutures)
require.NoError(t, err)
@@ -3608,7 +3608,7 @@ func TestWebsocketSubmitOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.Spot) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.Spot)
sub.AssetType = asset.Spot
cpy.AssetType = asset.Spot

View File

@@ -31,7 +31,7 @@ func TestWebsocketFuturesSubmitOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures)
out.AutoSize = ""
got, err := e.WebsocketFuturesSubmitOrder(t.Context(), asset.USDTMarginedFutures, out)
@@ -73,7 +73,7 @@ func TestWebsocketFuturesSubmitOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures)
// test single order
got, err := e.WebsocketFuturesSubmitOrders(t.Context(), asset.CoinMarginedFutures, out)
@@ -99,7 +99,7 @@ func TestWebsocketFuturesCancelOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures)
got, err := e.WebsocketFuturesCancelOrder(t.Context(), "513160761072", BTCUSDT, asset.USDTMarginedFutures)
require.NoError(t, err)
@@ -119,7 +119,7 @@ func TestWebsocketFuturesCancelAllOpenFuturesOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures)
got, err := e.WebsocketFuturesCancelAllOpenFuturesOrders(t.Context(), BTCUSDT, asset.USDTMarginedFutures, order.Bid.Lower())
require.NoError(t, err)
@@ -151,7 +151,7 @@ func TestWebsocketFuturesAmendOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures)
amend.OrderID = "513170215869"
got, err := e.WebsocketFuturesAmendOrder(t.Context(), amend)
@@ -178,7 +178,7 @@ func TestWebsocketFuturesOrderList(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures)
list.Status = statusOpen
got, err := e.WebsocketFuturesOrderList(t.Context(), list)
@@ -199,7 +199,7 @@ func TestWebsocketFuturesGetOrderStatus(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.USDTMarginedFutures)
got, err := e.WebsocketFuturesGetOrderStatus(t.Context(), BTCUSDT, asset.USDTMarginedFutures, "513170215869")
require.NoError(t, err)

View File

@@ -20,7 +20,7 @@ func TestWebsocketLogin(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.Spot) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.Spot)
c, err := e.Websocket.GetConnection(asset.Spot)
require.NoError(t, err)
@@ -50,7 +50,7 @@ func TestWebsocketSpotSubmitOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.Spot) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.Spot)
got, err := e.WebsocketSpotSubmitOrder(t.Context(), out)
require.NoError(t, err)
@@ -78,7 +78,7 @@ func TestWebsocketSpotSubmitOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.Spot) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.Spot)
// test single order
got, err := e.WebsocketSpotSubmitOrders(t.Context(), out)
@@ -100,7 +100,7 @@ func TestWebsocketSpotCancelOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.Spot) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.Spot)
got, err := e.WebsocketSpotCancelOrder(t.Context(), "644913098758", BTCUSDT, "")
require.NoError(t, err)
@@ -122,7 +122,7 @@ func TestWebsocketSpotCancelAllOrdersByIDs(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.Spot) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.Spot)
out.OrderID = "644913101755"
got, err := e.WebsocketSpotCancelAllOrdersByIDs(t.Context(), []WebsocketOrderBatchRequest{out})
@@ -137,7 +137,7 @@ func TestWebsocketSpotCancelAllOrdersByPair(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.Spot) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.Spot)
got, err := e.WebsocketSpotCancelAllOrdersByPair(t.Context(), currency.EMPTYPAIR, order.Buy, "")
require.NoError(t, err)
@@ -166,7 +166,7 @@ func TestWebsocketSpotAmendOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
e := newExchangeWithWebsocket(t, asset.Spot) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.Spot)
amend.OrderID = "645029162673"
got, err := e.WebsocketSpotAmendOrder(t.Context(), amend)
@@ -185,7 +185,7 @@ func TestWebsocketSpotGetOrderStatus(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
testexch.UpdatePairsOnce(t, e)
e := newExchangeWithWebsocket(t, asset.Spot) //nolint:govet // Intentional shadow
e := newExchangeWithWebsocket(t, asset.Spot)
got, err := e.WebsocketSpotGetOrderStatus(t.Context(), "644999650452", BTCUSDT, "")
require.NoError(t, err)
@@ -199,7 +199,7 @@ func newExchangeWithWebsocket(t *testing.T, a asset.Item) *Exchange {
if apiKey == "" || apiSecret == "" {
t.Skip()
}
e := new(Exchange) //nolint:govet // Intentional shadow
e := new(Exchange)
require.NoError(t, testexch.Setup(e), "Test instance Setup must not error")
testexch.UpdatePairsOnce(t, e)
e.API.AuthenticatedSupport = true

View File

@@ -50,7 +50,7 @@ type websocketBalancesTest struct {
func TestProcessSpotBalances(t *testing.T) { //nolint:tparallel // Sequential tests, do not use t.Parallel(); Some timestamps are deliberately identical from trading activity
t.Parallel()
e := new(Exchange) //nolint:govet // Intentional shadow
e := new(Exchange)
e.SetDefaults()
e.Name = "ProcessSpotBalancesTest"
e.Accounts = accounts.MustNewAccounts(e)
@@ -120,7 +120,7 @@ func TestProcessSpotBalances(t *testing.T) { //nolint:tparallel // Sequential te
func TestProcessBalancePushData(t *testing.T) { //nolint:tparallel // Sequential tests, do not use t.Parallel(); Some timestamps are deliberately identical from trading activity
t.Parallel()
e := new(Exchange) //nolint:govet // Intentional shadow
e := new(Exchange)
e.SetDefaults()
e.Name = "ProcessFuturesBalancesTest"
e.Accounts = accounts.MustNewAccounts(e)