Skip to content

Commit

Permalink
CI: Bump go version, linters and fix minor issues (thrasher-corp#1130)
Browse files Browse the repository at this point in the history
* CI: Bump go version, linters and fix minor issues

* Bump version, fix loop variables

* Revert

* Rid TODOs now that 1.51 has been released
  • Loading branch information
thrasher- authored Feb 3, 2023
1 parent b384991 commit 7e08e48
Show file tree
Hide file tree
Showing 39 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ before_test:

test_script:
# test back-end
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0
- '%GOPATH%\bin\golangci-lint.exe run --verbose'
- ps: >-
if($env:APPVEYOR_SCHEDULED_BUILD -eq 'true') {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.19.x'
go-version: '1.20.x'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.48.0
version: v1.51.0
2 changes: 1 addition & 1 deletion .github/workflows/proto-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Setup build depends
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on: [push, pull_request]
name: CI
env:
GO_VERSION: 1.19.x
GO_VERSION: 1.20.x
jobs:
backend-psql:
name: GoCryptoTrader back-end with PSQL
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ config.json
config.dat
node_modules
lib

# VS Code
.vscode
tmp/

testdata/dump
testdata/preengine_config.json
Expand Down
22 changes: 15 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
timeout: 8m
timeout: 10m
issues-exit-code: 1
tests: true
skip-dirs:
Expand All @@ -12,15 +12,13 @@ linters:
disable-all: true
enable:
# defaults
# - deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
# - unused
# - varcheck

# disabled by default linters
# - asasalint
Expand All @@ -30,23 +28,27 @@ linters:
- containedctx
# - contextcheck
# - cyclop
# - deadcode // abandoned by its owner, replaced by unused
- decorder
- depguard
- dogsled
# - dupl
- dupword
- durationcheck
- errchkjson
- errname
# - errorlint
- execinquery
# - exhaustive
# - exhaustivestruct // abandoned by its owner, replaced with exhaustruct
# - exhaustivestruct // abandoned by its owner, replaced by exhaustruct
# - exhaustruct
- exportloopref
# - forbidigo
- forcetypeassert
# - funlen
- gci
# - ginkgolinter
- gocheckcompilerdirectives
# - gochecknoglobals
# - gochecknoinits
# - gocognit
Expand All @@ -69,13 +71,16 @@ linters:
- grouper
# - ifshort // deprecated by its owner
# - importas
# - interfacebloat
# - interfacer // deprecated by its owner
# - ireturn
# - lll
# - loggercheck
# - maintidx
- makezero
# - maligned
# - maligned // deprecated by its owner, replaced by govet 'fieldalignment'
- misspell
# - musttag
- nakedret
# - nestif
- nilerr
Expand All @@ -84,26 +89,29 @@ linters:
- noctx
- nolintlint
# - nonamedreturns
# - nosnakecase
# - nosnakecase // deprecated by its owner, replaced by revive 'var-naming'
- nosprintfhostport
# - paralleltest
- prealloc
- predeclared
# - promlinter
- reassign
- revive
- rowserrcheck
# - scopelint // deprecated since v1.39.0, replaced by exportloopref
- sqlclosecheck
- structcheck
# - structcheck // abandoned by its owner, replaced by unused
- stylecheck
# - tagliatelle
- tenv
- testableexamples
# - testpackage
- thelper
- tparallel
- unconvert
- unparam
- usestdlibvars
# - varcheck // abandoned by its owner, replaced by unused
# - varnamelen
- wastedassign
- whitespace
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19 as build
FROM golang:1.20 as build
WORKDIR /go/src/github.com/thrasher-corp/gocryptotrader
COPY . .
RUN GO111MODULE=on go mod vendor
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LDFLAGS = -ldflags "-w -s"
GCTPKG = github.com/thrasher-corp/gocryptotrader
LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0
LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0
LINTBIN = $(GOPATH)/bin/golangci-lint
GCTLISTENPORT=9050
GCTPROFILERLISTENPORT=8085
Expand Down
2 changes: 2 additions & 0 deletions backtester/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func TestCanTransact(t *testing.T) {
expected: false,
},
} {
ti := ti
t.Run(ti.side.String(), func(t *testing.T) {
t.Parallel()
if CanTransact(ti.side) != ti.expected {
Expand Down Expand Up @@ -123,6 +124,7 @@ func TestDataTypeConversion(t *testing.T) {
expectErr: true,
},
} {
ti := ti
t.Run(ti.title, func(t *testing.T) {
t.Parallel()
got, err := DataTypeToInt(ti.dataType)
Expand Down
5 changes: 2 additions & 3 deletions common/crypto/crypto.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package crypto

//nolint:gosec // md5/sha1 hash functions used by some exchanges
import (
"crypto/hmac"
"crypto/md5"
"crypto/md5" //nolint:gosec // Used for exchanges
"crypto/rand"
"crypto/sha1"
"crypto/sha1" //nolint:gosec // Used for exchanges
"crypto/sha256"
"crypto/sha512"
"encoding/base64"
Expand Down
2 changes: 1 addition & 1 deletion communications/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type CommunicationsConfig struct {
TelegramConfig TelegramConfig `json:"telegram"`
}

// IsAnyEnabled returns whether or any any comms relayers
// IsAnyEnabled returns whether any comms relayers
// are enabled
func (c *CommunicationsConfig) IsAnyEnabled() bool {
if c.SMSGlobalConfig.Enabled ||
Expand Down
2 changes: 1 addition & 1 deletion communications/smsglobal/smsglobal.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type SMSGlobal struct {
}

// Setup takes in a SMSGlobal configuration, sets username, password and
// and recipient list
// recipient list
func (s *SMSGlobal) Setup(cfg *base.CommunicationsConfig) {
s.Name = cfg.SMSGlobalConfig.Name
s.Enabled = cfg.SMSGlobalConfig.Enabled
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ func TestCheckExchangeConfigValues(t *testing.T) {
t.Error("unexpected values")
}

// Test feature and endpoint migrations migrations
// Test feature and endpoint migrations
cfg.Exchanges[0].Features = nil
cfg.Exchanges[0].SupportsAutoPairUpdates = convert.BoolPtr(true)
cfg.Exchanges[0].Websocket = convert.BoolPtr(true)
Expand Down
6 changes: 3 additions & 3 deletions currency/coinmarketcap/coinmarketcap.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (c *Coinmarketcap) GetCryptocurrencyHistoricalListings() ([]CryptocurrencyH
// NOTE unreachable code but will be utilised at a later date
// resp := struct {
// Data []CryptocurrencyHistoricalListings `json:"data"`
// Status Status `json:"status"`
// ServerStatus Status `json:"status"`
// }{}

//nolint:gocritic // unused code, used as example
Expand All @@ -143,8 +143,8 @@ func (c *Coinmarketcap) GetCryptocurrencyHistoricalListings() ([]CryptocurrencyH
// }

//nolint:gocritic // unused code, used as example
// if resp.Status.ErrorCode != 0 {
// return resp.Data, errors.New(resp.Status.ErrorMessage)
// if resp.ServerStatus.ErrorCode != 0 {
// return resp.Data, errors.New(resp.ServerStatus.ErrorMessage)
// }

//nolint:gocritic // unused code, used as example
Expand Down
3 changes: 1 addition & 2 deletions engine/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ func (bot *Engine) GetSpecificTicker(ctx context.Context, p currency.Pair, excha
}

// GetCollatedExchangeAccountInfoByCoin collates individual exchange account
// information and turns into into a map string of
// exchange.AccountCurrencyInfo
// information and turns it into a map string of exchange.AccountCurrencyInfo
func GetCollatedExchangeAccountInfoByCoin(accounts []account.Holdings) map[currency.Code]account.Balance {
result := make(map[currency.Code]account.Balance)
for x := range accounts {
Expand Down
2 changes: 1 addition & 1 deletion engine/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ func TestIsRelatablePairs(t *testing.T) {
t.Fatal(err)
}

// Test relationl crypto pairs with with similar names
// Test relationl crypto pairs with similar names
result = IsRelatablePairs(xbtltc, btcltc, false)
if !result {
t.Fatal("Unexpected result")
Expand Down
5 changes: 1 addition & 4 deletions engine/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2542,10 +2542,7 @@ func fillMissingCandlesWithStoredTrades(startTime, endTime time.Time, klineItem
if len(tradeCandles.Candles) == 0 {
continue
}

for i := range tradeCandles.Candles {
response.Candles = append(response.Candles, tradeCandles.Candles[i])
}
response.Candles = append(response.Candles, tradeCandles.Candles...)

for i := range response.Candles {
log.Infof(log.GRPCSys,
Expand Down
2 changes: 1 addition & 1 deletion exchanges/alphapoint/alphapoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func (a *Alphapoint) CancelExistingOrder(ctx context.Context, orderID int64, oms
return response.CancelOrderID, nil
}

// CancelAllExistingOrders cancels all open orders by symbol
// CancelAllExistingOrders cancels all open orders by symbol.
// symbol - Instrument code (ex: “BTCUSD”)
func (a *Alphapoint) CancelAllExistingOrders(ctx context.Context, omsid string) error {
req := make(map[string]interface{})
Expand Down
2 changes: 1 addition & 1 deletion exchanges/bitfinex/bitfinex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ func TestReOrderbyID(t *testing.T) {
func TestPopulateAcceptableMethods(t *testing.T) {
t.Parallel()
if acceptableMethods.loaded() {
// we may have have been loaded from another test, so reset
// we may have been loaded from another test, so reset
acceptableMethods.m.Lock()
acceptableMethods.a = make(map[string][]string)
acceptableMethods.m.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions exchanges/bitmex/bitmex.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (b *Bitmex) SendTrollboxMessage(ctx context.Context, params ChatSendParams)
&messages)
}

// GetTrollboxChannels the channels from the the bitmex trollbox
// GetTrollboxChannels the channels from the bitmex trollbox
func (b *Bitmex) GetTrollboxChannels(ctx context.Context) ([]ChatChannel, error) {
var channels []ChatChannel

Expand All @@ -198,7 +198,7 @@ func (b *Bitmex) GetTrollboxChannels(ctx context.Context) ([]ChatChannel, error)
&channels)
}

// GetTrollboxConnectedUsers the channels from the the bitmex trollbox
// GetTrollboxConnectedUsers the channels from the bitmex trollbox
func (b *Bitmex) GetTrollboxConnectedUsers(ctx context.Context) (ConnectedUsers, error) {
var users ConnectedUsers

Expand Down
2 changes: 1 addition & 1 deletion exchanges/bitmex/bitmex_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ type IndexComposite struct {
Weight float64 `json:"weight"`
}

// Insurance Insurance Fund Data
// Insurance stores insurance fund data
type Insurance struct {
Currency string `json:"currency"`
Timestamp time.Time `json:"timestamp"`
Expand Down
2 changes: 1 addition & 1 deletion exchanges/bitstamp/bitstamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func (b *Bitstamp) OpenInternationalBankWithdrawal(ctx context.Context, amount f
return resp, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, bitstampAPIOpenWithdrawal, true, req, &resp)
}

// GetCryptoDepositAddress returns a depositing address by crypto
// GetCryptoDepositAddress returns a depositing address by crypto.
// crypto - example "btc", "ltc", "eth", "xrp" or "bch"
func (b *Bitstamp) GetCryptoDepositAddress(ctx context.Context, crypto currency.Code) (*DepositAddress, error) {
path := crypto.Lower().String() + "_address"
Expand Down
5 changes: 1 addition & 4 deletions exchanges/btcmarkets/btcmarkets_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,10 +826,7 @@ func (b *BTCMarkets) GetActiveOrders(ctx context.Context, req *order.GetOrdersRe
if err != nil {
return nil, err
}
for a := range allPairs {
req.Pairs = append(req.Pairs,
allPairs[a])
}
req.Pairs = append(req.Pairs, allPairs...)
}

var resp []order.Detail
Expand Down
2 changes: 0 additions & 2 deletions exchanges/coinut/coinut_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"math/rand"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -131,7 +130,6 @@ func (c *COINUT) SetDefaults() {
c.WebsocketResponseMaxLimit = exchange.DefaultWebsocketResponseMaxLimit
c.WebsocketResponseCheckTimeout = exchange.DefaultWebsocketResponseCheckTimeout
c.WebsocketOrderbookBufferLimit = exchange.DefaultWebsocketOrderbookBufferLimit
rand.Seed(time.Now().UnixNano())
}

// Setup sets the current exchange configuration
Expand Down
2 changes: 1 addition & 1 deletion exchanges/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ func (b *Base) StoreAssetPairFormat(a asset.Item, f currency.PairStore) error {
}

// SetGlobalPairsManager sets defined asset and pairs management system with
// with global formatting
// global formatting
func (b *Base) SetGlobalPairsManager(request, config *currency.PairFormat, assets ...asset.Item) error {
if request == nil {
return fmt.Errorf("%s cannot set pairs manager, request pair format not provided",
Expand Down
2 changes: 1 addition & 1 deletion exchanges/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestSetDefaultEndpoints(t *testing.T) {
EdgeCase1: "",
})
if err != nil {
t.Errorf("expecting a warning due due to invalid url val but got an error: %v", err)
t.Errorf("expecting a warning due to invalid url value but got an error: %v", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion exchanges/gemini/gemini.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
// Gemini is the overarching type across the Gemini package, create multiple
// instances with differing APIkeys for segregation of roles for authenticated
// requests & sessions by appending new sessions to the Session map using
// AddSession, if sandbox test is needed append a new session with with the same
// AddSession. If sandbox test is needed, append a new session with the same
// API keys and change the IsSandbox variable to true.
type Gemini struct {
exchange.Base
Expand Down
2 changes: 1 addition & 1 deletion exchanges/huobi/huobi_futures.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ func (h *HUOBI) FGetOpenOrders(ctx context.Context, symbol currency.Code, pageIn
return resp, h.FuturesAuthenticatedHTTPRequest(ctx, exchange.RestFutures, http.MethodPost, fQueryOpenOrders, nil, req, &resp)
}

// FGetOrderHistory gets order order history for futures
// FGetOrderHistory gets order history for futures
func (h *HUOBI) FGetOrderHistory(ctx context.Context, contractCode currency.Pair, symbol, tradeType, reqType, orderType string, status []order.Status, createDate, pageIndex, pageSize int64) (FOrderHistoryData, error) {
var resp FOrderHistoryData
req := make(map[string]interface{})
Expand Down
2 changes: 1 addition & 1 deletion exchanges/huobi/huobi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ type Trade struct {
Timestamp int64 `json:"ts"`
}

// TradeHistory stores the the trade history data
// TradeHistory stores the trade history data
type TradeHistory struct {
ID int64 `json:"id"`
Timestamp int64 `json:"ts"`
Expand Down
Loading

0 comments on commit 7e08e48

Please sign in to comment.