diff --git a/.appveyor.yml b/.appveyor.yml index 11be377c..3aef67cb 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -28,7 +28,7 @@ before_test: test_script: # test back-end - - go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.16.0 + - go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.18.0 - '%GOPATH%\bin\golangci-lint.exe run --verbose' - ps: >- if($env:APPVEYOR_SCHEDULED_BUILD -eq 'true') { diff --git a/.golangci.yml b/.golangci.yml index 9357ce01..3fb7dc86 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ run: tests: true skip-dirs: - vendor - - web + - web/ - testdata linters: @@ -21,14 +21,13 @@ linters: - ineffassign # - deadcode - typecheck - - goimports - - govet # disabled by default linters +# - bodyclose - golint - stylecheck - gosec -# - interfacer +# - interfacer - unconvert # - dupl - goconst @@ -46,6 +45,7 @@ linters: - gocritic # - gochecknoinits # - gochecknoglobals +# - funlen linters-settings: govet: @@ -67,6 +67,7 @@ linters-settings: - wrapperFunc - importShadow - methodExprCall + - evalOrder issues: max-issues-per-linter: 0 diff --git a/.travis.yml b/.travis.yml index 7b00bb23..e04d4cf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ matrix: dist: xenial name: 'GoCryptoTrader [back-end] [linux]' go: - - 1.12.x + - 1.13.x env: - GO111MODULE=on install: true @@ -35,7 +35,7 @@ matrix: os: osx name: 'GoCryptoTrader [back-end] [darwin]' go: - - 1.12.x + - 1.13.x env: - GO111MODULE=on install: true diff --git a/Makefile b/Makefile index 41d83cf9..05ff8891 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ LDFLAGS = -ldflags "-w -s" GCTPKG = github.com/thrasher-corp/gocryptotrader -LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.16.0 +LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.18.0 LINTBIN = $(GOPATH)/bin/golangci-lint GCTLISTENPORT=9050 GCTPROFILERLISTENPORT=8085 diff --git a/config/config.go b/config/config.go index 34f679ed..1eac78b7 100644 --- a/config/config.go +++ b/config/config.go @@ -1374,33 +1374,37 @@ func (c *Config) DisableNTPCheck(input io.Reader) (string, error) { defer m.Unlock() reader := bufio.NewReader(input) - log.Warnln(log.ConfigMgr, "Your system time is out of sync, this may cause issues with trading.") - log.Warnln(log.ConfigMgr, "How would you like to show future notifications? (a)lert / (w)arn / (d)isable.") + log.Warnln(log.ConfigMgr, "Your system time is out of sync, this may cause issues with trading") + log.Warnln(log.ConfigMgr, "How would you like to show future notifications? (a)lert / (w)arn / (d)isable") - var answered = false - for ok := true; ok; ok = (!answered) { + var resp string + answered := false + for !answered { answer, err := reader.ReadString('\n') if err != nil { - return "", err + return resp, err } answer = strings.TrimRight(answer, "\r\n") switch answer { case "a": c.NTPClient.Level = 0 + resp = "Time sync has been set to alert" answered = true - return "Time sync has been set to alert", nil case "w": c.NTPClient.Level = 1 + resp = "Time sync has been set to warn only" answered = true - return "Time sync has been set to warn only", nil case "d": c.NTPClient.Level = -1 + resp = "Future notifications for out of time sync has been disabled" answered = true - return "Future notications for out time sync have been disabled", nil + default: + log.Warnln(log.ConfigMgr, + "Invalid option selected, please try again (a)lert / (w)arn / (d)isable") } } - return "", errors.New("something went wrong, NTPCheck should never make it this far") + return resp, nil } // CheckConnectionMonitorConfig checks and if zero value assigns default values diff --git a/config/config_test.go b/config/config_test.go index 17865bb3..c6930769 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1647,8 +1647,8 @@ func TestDisableNTPCheck(t *testing.T) { } disable, _ := c.DisableNTPCheck(strings.NewReader("d\n")) - if disable != "Future notications for out time sync have been disabled" { - t.Errorf("failed expected %v got %v", "Future notications for out time sync have been disabled", disable) + if disable != "Future notifications for out of time sync has been disabled" { + t.Errorf("failed expected %v got %v", "Future notifications for out of time sync has been disabled", disable) } _, err = c.DisableNTPCheck(strings.NewReader(" ")) diff --git a/currency/code.go b/currency/code.go index acb5062e..a1902769 100644 --- a/currency/code.go +++ b/currency/code.go @@ -547,7 +547,7 @@ var ( BAT = NewCode("BAT") ETP = NewCode("ETP") HOT = NewCode("HOT") - STRAT = NewCode("STRAT") + STRAT = NewCode("STRAT") // nolint: misspell GNT = NewCode("GNT") REP = NewCode("REP") SNT = NewCode("SNT") diff --git a/currency/coinmarketcap/coinmarketcap.go b/currency/coinmarketcap/coinmarketcap.go index cebcb02f..b676f4ed 100644 --- a/currency/coinmarketcap/coinmarketcap.go +++ b/currency/coinmarketcap/coinmarketcap.go @@ -155,28 +155,28 @@ func (c *Coinmarketcap) GetCryptocurrencyIDMap() ([]CryptoCurrencyMap, error) { // GetCryptocurrencyHistoricalListings returns a paginated list of all // cryptocurrencies with market data for a given historical time. func (c *Coinmarketcap) GetCryptocurrencyHistoricalListings() ([]CryptocurrencyHistoricalListings, error) { - return nil, errors.New("this endpoint is not yet available") + return nil, common.ErrNotYetImplemented // NOTE unreachable code but will be utilised at a later date // resp := struct { // Data []CryptocurrencyHistoricalListings `json:"data"` // Status Status `json:"status"` // }{} - // err := c.CheckAccountPlan(0) + // nolint: gocritic err := c.CheckAccountPlan(0) // if err != nil { // return resp.Data, err // } - // err = c.SendHTTPRequest(http.MethodGet, endpointCryptocurrencyHistoricalListings, nil, &resp) + // nolint: gocritic err = c.SendHTTPRequest(http.MethodGet, endpointCryptocurrencyHistoricalListings, nil, &resp) // if err != nil { // return resp.Data, err // } - //nolint:gocritic if resp.Status.ErrorCode != 0 { + // nolint: gocritic nolint:gocritic if resp.Status.ErrorCode != 0 { // return resp.Data, errors.New(resp.Status.ErrorMessage) // } - //nolint:gocritic return resp.Data, nil + // nolint: gocritic nolint:gocritic return resp.Data, nil } // GetCryptocurrencyLatestListing returns a paginated list of all diff --git a/exchanges/bitflyer/bitflyer.go b/exchanges/bitflyer/bitflyer.go index e0fb6b6a..77aad8c5 100644 --- a/exchanges/bitflyer/bitflyer.go +++ b/exchanges/bitflyer/bitflyer.go @@ -323,7 +323,7 @@ func (b *Bitflyer) SendHTTPRequest(path string, result interface{}) error { // if you have access and update the authenticated requests // TODO: Fill out this function once API access is obtained func (b *Bitflyer) SendAuthHTTPRequest() { - // headers := make(map[string]string) + // nolint: gocritic headers := make(map[string]string) // headers["ACCESS-KEY"] = b.API.Credentials.Key // headers["ACCESS-TIMESTAMP"] = strconv.FormatInt(time.Now().UnixNano(), 10) } diff --git a/exchanges/bitflyer/bitflyer_wrapper.go b/exchanges/bitflyer/bitflyer_wrapper.go index ab9f7ddc..0ca12330 100644 --- a/exchanges/bitflyer/bitflyer_wrapper.go +++ b/exchanges/bitflyer/bitflyer_wrapper.go @@ -1,7 +1,6 @@ package bitflyer import ( - "errors" "strings" "sync" "time" @@ -248,26 +247,13 @@ func (b *Bitflyer) UpdateOrderbook(p currency.Pair, assetType asset.Item) (order // GetAccountInfo retrieves balances for all enabled currencies on the // Bitflyer exchange func (b *Bitflyer) GetAccountInfo() (exchange.AccountInfo, error) { - var response exchange.AccountInfo - response.Exchange = b.GetName() - // accountBalance, err := b.GetAccountBalance() - // if err != nil { - // return response, err - // } - if !b.Enabled { - return response, errors.New("exchange not enabled") - } - - // implement once authenticated requests are introduced - - return response, nil + return exchange.AccountInfo{}, common.ErrNotYetImplemented } // GetFundingHistory returns funding history, deposits and // withdrawals func (b *Bitflyer) GetFundingHistory() ([]exchange.FundHistory, error) { - var fundHistory []exchange.FundHistory - return fundHistory, common.ErrFunctionNotSupported + return nil, common.ErrFunctionNotSupported } // GetExchangeHistory returns historic trade data since exchange opening. diff --git a/exchanges/lbank/lbank_wrapper.go b/exchanges/lbank/lbank_wrapper.go index e6c5c4df..2090dcc4 100644 --- a/exchanges/lbank/lbank_wrapper.go +++ b/exchanges/lbank/lbank_wrapper.go @@ -533,13 +533,10 @@ func (l *Lbank) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([] var finalResp []exchange.OrderDetail var resp exchange.OrderDetail var tempCurr currency.Pairs - var x int if len(getOrdersRequest.Currencies) == 0 { tempCurr = l.GetEnabledPairs(asset.Spot) } else { - for x < len(getOrdersRequest.Currencies) { - tempCurr = getOrdersRequest.Currencies - } + tempCurr = getOrdersRequest.Currencies } for a := range tempCurr { p := l.FormatExchangeCurrency(tempCurr[a], asset.Spot).String() diff --git a/exchanges/websocket/wsorderbook/wsorderbook_test.go b/exchanges/websocket/wsorderbook/wsorderbook_test.go index a6ad5ee6..b3edf789 100644 --- a/exchanges/websocket/wsorderbook/wsorderbook_test.go +++ b/exchanges/websocket/wsorderbook/wsorderbook_test.go @@ -577,6 +577,6 @@ func TestSetup(t *testing.T) { w := WebsocketOrderbookLocal{} w.Setup(1, true, true, true, true, "hi") if w.obBufferLimit != 1 || !w.bufferEnabled || !w.sortBuffer || !w.sortBufferByUpdateIDs || !w.updateEntriesByID || w.exchangeName != "hi" { - t.Errorf("Setup incorrectly loaded %v", w) + t.Errorf("Setup incorrectly loaded %s", w.exchangeName) } } diff --git a/go.mod b/go.mod index 1044d580..38ee1c2f 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/toorop/go-pusher v0.0.0-20180521062818-4521e2eb39fb github.com/urfave/cli v1.20.0 golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 - golang.org/x/net v0.0.0-20190606173856-1492cefac77f // indirect + golang.org/x/net v0.0.0-20190606173856-1492cefac77f google.golang.org/genproto v0.0.0-20190605220351-eb0b1bdb6ae6 google.golang.org/grpc v1.21.1 )