linters: Bump golangci-lint version to v1.52.2 and fix issues (#1169)

* fix linter issues

* linter issue suppressing and fixing

* change linter version and linter issues fix

* Bump version
This commit is contained in:
Samuael A
2023-04-27 00:13:46 +00:00
committed by GitHub
parent 42475bf2b8
commit 969669cb0d
70 changed files with 346 additions and 329 deletions

View File

@@ -794,7 +794,7 @@ func wsSaveConfig(client *websocketClient, data interface{}) error {
return client.SendWebsocketMessage(wsResp)
}
func wsGetAccountInfo(client *websocketClient, data interface{}) error {
func wsGetAccountInfo(client *websocketClient, _ interface{}) error {
accountInfo := getAllActiveAccounts(client.exchangeManager)
wsResp := WebsocketEventResponse{
Event: "GetAccountInfo",
@@ -803,7 +803,7 @@ func wsGetAccountInfo(client *websocketClient, data interface{}) error {
return client.SendWebsocketMessage(wsResp)
}
func wsGetTickers(client *websocketClient, data interface{}) error {
func wsGetTickers(client *websocketClient, _ interface{}) error {
wsResp := WebsocketEventResponse{
Event: "GetTickers",
}
@@ -863,7 +863,7 @@ func wsGetTicker(client *websocketClient, data interface{}) error {
return client.SendWebsocketMessage(wsResp)
}
func wsGetOrderbooks(client *websocketClient, data interface{}) error {
func wsGetOrderbooks(client *websocketClient, _ interface{}) error {
wsResp := WebsocketEventResponse{
Event: "GetOrderbooks",
}
@@ -923,7 +923,7 @@ func wsGetOrderbook(client *websocketClient, data interface{}) error {
return nil
}
func wsGetExchangeRates(client *websocketClient, data interface{}) error {
func wsGetExchangeRates(client *websocketClient, _ interface{}) error {
wsResp := WebsocketEventResponse{
Event: "GetExchangeRates",
}
@@ -937,7 +937,7 @@ func wsGetExchangeRates(client *websocketClient, data interface{}) error {
return client.SendWebsocketMessage(wsResp)
}
func wsGetPortfolio(client *websocketClient, data interface{}) error {
func wsGetPortfolio(client *websocketClient, _ interface{}) error {
wsResp := WebsocketEventResponse{
Event: "GetPortfolio",
}

View File

@@ -86,35 +86,35 @@ func (f *fakerino) GetCurrencyStateSnapshot() ([]currencystate.Snapshot, error)
}, nil
}
func (f *fakerino) CanWithdraw(c currency.Code, a asset.Item) error {
func (f *fakerino) CanWithdraw(_ currency.Code, _ asset.Item) error {
if f.errorMe {
return errExchange
}
return nil
}
func (f *fakerino) CanDeposit(c currency.Code, a asset.Item) error {
func (f *fakerino) CanDeposit(_ currency.Code, _ asset.Item) error {
if f.errorMe {
return errExchange
}
return nil
}
func (f *fakerino) CanTrade(c currency.Code, a asset.Item) error {
func (f *fakerino) CanTrade(_ currency.Code, _ asset.Item) error {
if f.errorMe {
return errExchange
}
return nil
}
func (f *fakerino) CanTradePair(p currency.Pair, a asset.Item) error {
func (f *fakerino) CanTradePair(_ currency.Pair, _ asset.Item) error {
if f.errorMe {
return errExchange
}
return nil
}
func (f *fakerino) GetAvailablePairs(a asset.Item) (currency.Pairs, error) {
func (f *fakerino) GetAvailablePairs(_ asset.Item) (currency.Pairs, error) {
if f.GetAvailablePairsError {
return nil, errExchange
}
@@ -366,7 +366,7 @@ func TestCanTradePairRPC(t *testing.T) {
}
}
func TestUpdate(t *testing.T) {
func TestUpdate(_ *testing.T) {
man := &CurrencyStateManager{}
var wg sync.WaitGroup
wg.Add(3)

View File

@@ -10,6 +10,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/database/drivers"
)
//nolint:gocritic // Only used as a testing helper function in this package
func CreateDatabase(t *testing.T) {
t.Helper()
// fun workarounds to globals ruining testing

View File

@@ -1561,7 +1561,7 @@ type dhmExchange struct {
exchange.IBotExchange
}
func (f dhmExchange) GetHistoricCandlesExtended(ctx context.Context, p currency.Pair, a asset.Item, interval kline.Interval, timeStart, _ time.Time) (*kline.Item, error) {
func (f dhmExchange) GetHistoricCandlesExtended(_ context.Context, p currency.Pair, a asset.Item, interval kline.Interval, timeStart, _ time.Time) (*kline.Item, error) {
return &kline.Item{
Exchange: testExchange,
Pair: p,
@@ -1596,7 +1596,7 @@ func (f dhmExchange) GetHistoricCandlesExtended(ctx context.Context, p currency.
}, nil
}
func (f dhmExchange) GetHistoricTrades(ctx context.Context, p currency.Pair, a asset.Item, startTime, endTime time.Time) ([]trade.Data, error) {
func (f dhmExchange) GetHistoricTrades(_ context.Context, p currency.Pair, a asset.Item, startTime, _ time.Time) ([]trade.Data, error) {
return []trade.Data{
{
Exchange: testExchange,

View File

@@ -1034,7 +1034,7 @@ func (f fakeDepositExchange) GetAvailableTransferChains(_ context.Context, c cur
return []string{"BITCOIN"}, nil
}
func (f fakeDepositExchange) GetDepositAddress(_ context.Context, c currency.Code, chain, accountID string) (*deposit.Address, error) {
func (f fakeDepositExchange) GetDepositAddress(_ context.Context, _ currency.Code, _, _ string) (*deposit.Address, error) {
if f.ThrowDepositAddressError {
return nil, errors.New("unable to get deposit address")
}

View File

@@ -29,11 +29,11 @@ type omfExchange struct {
// CancelOrder overrides testExchange's cancel order function
// to do the bare minimum required with no API calls or credentials required
func (f omfExchange) CancelOrder(ctx context.Context, o *order.Cancel) error {
func (f omfExchange) CancelOrder(_ context.Context, _ *order.Cancel) error {
return nil
}
func (f omfExchange) FetchTicker(ctx context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error) {
func (f omfExchange) FetchTicker(_ context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error) {
return &ticker.Price{
Last: 1337,
High: 1337,
@@ -60,7 +60,7 @@ func (f omfExchange) FetchTicker(ctx context.Context, p currency.Pair, a asset.I
// GetOrderInfo overrides testExchange's get order function
// to do the bare minimum required with no API calls or credentials required
func (f omfExchange) GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (order.Detail, error) {
func (f omfExchange) GetOrderInfo(_ context.Context, orderID string, pair currency.Pair, assetType asset.Item) (order.Detail, error) {
switch orderID {
case "":
return order.Detail{}, errors.New("")
@@ -98,7 +98,7 @@ func (f omfExchange) GetOrderInfo(ctx context.Context, orderID string, pair curr
}
// GetActiveOrders overrides the function used by processOrders to return 1 active order
func (f omfExchange) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest) (order.FilteredOrders, error) {
func (f omfExchange) GetActiveOrders(_ context.Context, _ *order.GetOrdersRequest) (order.FilteredOrders, error) {
return []order.Detail{{
Exchange: testExchange,
Pair: currency.Pair{Base: currency.BTC, Quote: currency.USD},
@@ -111,7 +111,7 @@ func (f omfExchange) GetActiveOrders(ctx context.Context, req *order.GetOrdersRe
}}, nil
}
func (f omfExchange) ModifyOrder(ctx context.Context, action *order.Modify) (*order.ModifyResponse, error) {
func (f omfExchange) ModifyOrder(_ context.Context, action *order.Modify) (*order.ModifyResponse, error) {
modResp, err := action.DeriveModifyResponse()
if err != nil {
return nil, err
@@ -120,7 +120,7 @@ func (f omfExchange) ModifyOrder(ctx context.Context, action *order.Modify) (*or
return modResp, nil
}
func (f omfExchange) GetFuturesPositions(ctx context.Context, req *order.PositionsRequest) ([]order.PositionDetails, error) {
func (f omfExchange) GetFuturesPositions(_ context.Context, req *order.PositionsRequest) ([]order.PositionDetails, error) {
id, err := uuid.NewV4()
if err != nil {
return nil, err

View File

@@ -1589,7 +1589,7 @@ func (s *RPCServer) AddEvent(_ context.Context, r *gctrpc.AddEventRequest) (*gct
}
// RemoveEvent removes an event, specified by an event ID
func (s *RPCServer) RemoveEvent(ctx context.Context, r *gctrpc.RemoveEventRequest) (*gctrpc.GenericResponse, error) {
func (s *RPCServer) RemoveEvent(_ context.Context, r *gctrpc.RemoveEventRequest) (*gctrpc.GenericResponse, error) {
if !s.eventManager.Remove(r.Id) {
return nil, fmt.Errorf("event %d not removed", r.Id)
}
@@ -1599,7 +1599,7 @@ func (s *RPCServer) RemoveEvent(ctx context.Context, r *gctrpc.RemoveEventReques
// GetCryptocurrencyDepositAddresses returns a list of cryptocurrency deposit
// addresses specified by an exchange
func (s *RPCServer) GetCryptocurrencyDepositAddresses(ctx context.Context, r *gctrpc.GetCryptocurrencyDepositAddressesRequest) (*gctrpc.GetCryptocurrencyDepositAddressesResponse, error) {
func (s *RPCServer) GetCryptocurrencyDepositAddresses(_ context.Context, r *gctrpc.GetCryptocurrencyDepositAddressesRequest) (*gctrpc.GetCryptocurrencyDepositAddressesResponse, error) {
exch, err := s.GetExchangeByName(r.Exchange)
if err != nil {
return nil, err
@@ -5329,7 +5329,7 @@ func (s *RPCServer) GetMarginRatesHistory(ctx context.Context, r *gctrpc.GetMarg
// GetOrderbookMovement using the requested amount simulates a buy or sell and
// returns the nominal/impact percentages and costings.
func (s *RPCServer) GetOrderbookMovement(ctx context.Context, r *gctrpc.GetOrderbookMovementRequest) (*gctrpc.GetOrderbookMovementResponse, error) {
func (s *RPCServer) GetOrderbookMovement(_ context.Context, r *gctrpc.GetOrderbookMovementRequest) (*gctrpc.GetOrderbookMovementResponse, error) {
exch, err := s.GetExchangeByName(r.Exchange)
if err != nil {
return nil, err
@@ -5406,7 +5406,7 @@ func (s *RPCServer) GetOrderbookMovement(ctx context.Context, r *gctrpc.GetOrder
// GetOrderbookAmountByNominal using the requested nominal percentage requirement
// returns the amount on orderbook that can fit without exceeding that value.
func (s *RPCServer) GetOrderbookAmountByNominal(ctx context.Context, r *gctrpc.GetOrderbookAmountByNominalRequest) (*gctrpc.GetOrderbookAmountByNominalResponse, error) {
func (s *RPCServer) GetOrderbookAmountByNominal(_ context.Context, r *gctrpc.GetOrderbookAmountByNominalRequest) (*gctrpc.GetOrderbookAmountByNominalResponse, error) {
exch, err := s.GetExchangeByName(r.Exchange)
if err != nil {
return nil, err
@@ -5479,7 +5479,7 @@ func (s *RPCServer) GetOrderbookAmountByNominal(ctx context.Context, r *gctrpc.G
// GetOrderbookAmountByImpact using the requested impact percentage requirement
// determines the amount on orderbook that can fit that will slip the orderbook.
func (s *RPCServer) GetOrderbookAmountByImpact(ctx context.Context, r *gctrpc.GetOrderbookAmountByImpactRequest) (*gctrpc.GetOrderbookAmountByImpactResponse, error) {
func (s *RPCServer) GetOrderbookAmountByImpact(_ context.Context, r *gctrpc.GetOrderbookAmountByImpactRequest) (*gctrpc.GetOrderbookAmountByImpactResponse, error) {
exch, err := s.GetExchangeByName(r.Exchange)
if err != nil {
return nil, err

View File

@@ -75,7 +75,7 @@ func (f fExchange) GetPositionSummary(context.Context, *order.PositionSummaryReq
}, nil
}
func (f fExchange) GetFuturesPositions(ctx context.Context, req *order.PositionsRequest) ([]order.PositionDetails, error) {
func (f fExchange) GetFuturesPositions(_ context.Context, req *order.PositionsRequest) ([]order.PositionDetails, error) {
id, err := uuid.NewV4()
if err != nil {
return nil, err
@@ -110,7 +110,7 @@ func (f fExchange) GetFuturesPositions(ctx context.Context, req *order.Positions
return resp, nil
}
func (f fExchange) GetFundingRates(ctx context.Context, request *order.FundingRatesRequest) ([]order.FundingRates, error) {
func (f fExchange) GetFundingRates(_ context.Context, request *order.FundingRatesRequest) ([]order.FundingRates, error) {
leet := decimal.NewFromInt(1337)
return []order.FundingRates{
{
@@ -141,7 +141,7 @@ func (f fExchange) GetFundingRates(ctx context.Context, request *order.FundingRa
}, nil
}
func (f fExchange) GetHistoricCandles(ctx context.Context, p currency.Pair, a asset.Item, interval kline.Interval, timeStart, _ time.Time) (*kline.Item, error) {
func (f fExchange) GetHistoricCandles(_ context.Context, p currency.Pair, a asset.Item, interval kline.Interval, timeStart, _ time.Time) (*kline.Item, error) {
return &kline.Item{
Exchange: fakeExchangeName,
Pair: p,
@@ -176,7 +176,7 @@ func generateCandles(amount int, timeStart time.Time, interval kline.Interval) [
return candy
}
func (f fExchange) GetHistoricCandlesExtended(ctx context.Context, p currency.Pair, a asset.Item, interval kline.Interval, timeStart, _ time.Time) (*kline.Item, error) {
func (f fExchange) GetHistoricCandlesExtended(_ context.Context, p currency.Pair, a asset.Item, interval kline.Interval, timeStart, _ time.Time) (*kline.Item, error) {
if interval == 0 {
return nil, errExpectedTestError
}
@@ -220,7 +220,7 @@ func (f fExchange) GetMarginRatesHistory(context.Context, *margin.RateHistoryReq
return resp, nil
}
func (f fExchange) FetchTicker(ctx context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error) {
func (f fExchange) FetchTicker(_ context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error) {
return &ticker.Price{
Last: 1337,
High: 1337,
@@ -311,7 +311,7 @@ func (f fExchange) CalculateTotalCollateral(context.Context, *order.TotalCollate
// UpdateAccountInfo overrides testExchange's update account info function
// to do the bare minimum required with no API calls or credentials required
func (f fExchange) UpdateAccountInfo(ctx context.Context, a asset.Item) (account.Holdings, error) {
func (f fExchange) UpdateAccountInfo(_ context.Context, a asset.Item) (account.Holdings, error) {
if a == asset.Futures {
return account.Holdings{}, errAssetTypeDisabled
}
@@ -338,22 +338,22 @@ func (f fExchange) GetCurrencyStateSnapshot() ([]currencystate.Snapshot, error)
}
// CanTradePair overrides interface function
func (f fExchange) CanTradePair(p currency.Pair, a asset.Item) error {
func (f fExchange) CanTradePair(_ currency.Pair, _ asset.Item) error {
return nil
}
// CanTrade overrides interface function
func (f fExchange) CanTrade(c currency.Code, a asset.Item) error {
func (f fExchange) CanTrade(_ currency.Code, _ asset.Item) error {
return nil
}
// CanWithdraw overrides interface function
func (f fExchange) CanWithdraw(c currency.Code, a asset.Item) error {
func (f fExchange) CanWithdraw(_ currency.Code, _ asset.Item) error {
return nil
}
// CanDeposit overrides interface function
func (f fExchange) CanDeposit(c currency.Code, a asset.Item) error {
func (f fExchange) CanDeposit(_ currency.Code, _ asset.Item) error {
return nil
}
@@ -1132,8 +1132,8 @@ func (d *dummyServer) SetHeader(metadata.MD) error { return nil }
func (d *dummyServer) SendHeader(metadata.MD) error { return nil }
func (d *dummyServer) SetTrailer(metadata.MD) {}
func (d *dummyServer) Context() context.Context { return context.Background() }
func (d *dummyServer) SendMsg(m interface{}) error { return nil }
func (d *dummyServer) RecvMsg(m interface{}) error { return nil }
func (d *dummyServer) SendMsg(_ interface{}) error { return nil }
func (d *dummyServer) RecvMsg(_ interface{}) error { return nil }
func TestGetHistoricTrades(t *testing.T) {
engerino := RPCTestSetup(t)