golangci-lint/CI: Bump versions and introduce new linters (#798)

* golangci-lint/CI: Bump versions

Fix remaining linter issues

* Specifically set AppVeyor version

* Fix the infamous typos 👀

* Add go env cmd to AppVeyor

* Add go version cmd to AppVeyor

* Specify AppVeyor image, adjust linters

* Update go get to go install due to deprecation

* Bump golangci-lint timeout time for AppVeyor

* Change NW contract to NQ

* Address nitters

* GetRandomPair -> Pair{}

* Address nits

* Address time nitterinos plus additional tweaks

* More time inception upgrades!

* Bending time and space
This commit is contained in:
Adrian Gallagher
2021-10-14 16:38:53 +11:00
committed by GitHub
parent 0a91af0f2e
commit f0d45aa1d2
194 changed files with 1506 additions and 1233 deletions

View File

@@ -565,7 +565,10 @@ func addExch(exchName, checkType string, data interface{}, isUpdate bool) error
func fillData(exchName, checkType string, data interface{}) (ExchangeInfo, error) {
switch checkType {
case github:
tempData := data.(GithubData)
tempData, ok := data.(GithubData)
if !ok {
return ExchangeInfo{}, errors.New("unable to type assert GithubData")
}
tempSha, err := getSha(path)
if err != nil {
return ExchangeInfo{}, err
@@ -579,7 +582,10 @@ func fillData(exchName, checkType string, data interface{}) (ExchangeInfo, error
},
}, nil
case htmlScrape:
tempData := data.(HTMLScrapingData)
tempData, ok := data.(HTMLScrapingData)
if !ok {
return ExchangeInfo{}, errors.New("unable to type assert HTMLScrapingData")
}
checkStr, err := checkChangeLog(&tempData)
if err != nil {
return ExchangeInfo{}, err

View File

@@ -142,8 +142,7 @@ func TestCheckChangeLog(t *testing.T) {
DateFormat: "2006/01/02",
RegExp: `^20(\d){2}/(\d){2}/(\d){2}$`,
Path: "https://docs.gemini.com/rest-api/#revision-history"}
_, err := checkChangeLog(&data)
if err != nil {
if _, err := checkChangeLog(&data); err != nil {
t.Error(err)
}
}
@@ -236,8 +235,7 @@ func TestHTMLScrapeBitmex(t *testing.T) {
DateFormat: "Jan-2-2006",
RegExp: `([A-Z]{1}[a-z]{2}-\d{1,2}-2\d{3})`,
Path: "https://www.bitmex.com/static/md/en-US/apiChangelog"}
_, err := htmlScrapeBitmex(&data)
if err != nil {
if _, err := htmlScrapeBitmex(&data); err != nil {
t.Error(err)
}
}
@@ -246,8 +244,7 @@ func TestHTMLScrapeHitBTC(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `newest version \d{1}.\d{1}`,
Path: "https://api.hitbtc.com/"}
_, err := htmlScrapeHitBTC(&data)
if err != nil {
if _, err := htmlScrapeHitBTC(&data); err != nil {
t.Error(err)
}
}
@@ -273,8 +270,7 @@ func TestHTMLScrapeBTSE(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `^version: \d{1}.\d{1}.\d{1}`,
Path: "https://api.btcmarkets.net/openapi/info/index.yaml"}
_, err := htmlScrapeBTSE(&data)
if err != nil {
if _, err := htmlScrapeBTSE(&data); err != nil {
t.Error(err)
}
}
@@ -283,8 +279,7 @@ func TestHTMLScrapeBTCMarkets(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `^version: \d{1}.\d{1}.\d{1}`,
Path: "https://api.btcmarkets.net/openapi/info/index.yaml"}
_, err := htmlScrapeBTCMarkets(&data)
if err != nil {
if _, err := htmlScrapeBTCMarkets(&data); err != nil {
t.Error(err)
}
}
@@ -296,8 +291,7 @@ func TestHTMLScrapeBitflyer(t *testing.T) {
TextTokenData: "code",
RegExp: `^https://api.bitflyer.com/v\d{1}/$`,
Path: "https://lightning.bitflyer.com/docs?lang=en"}
_, err := htmlScrapeBitflyer(&data)
if err != nil {
if _, err := htmlScrapeBitflyer(&data); err != nil {
t.Error(err)
}
}
@@ -306,8 +300,7 @@ func TestHTMLScrapeANX(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `ANX Exchange API v\d{1}`,
Path: "https://anxv3.docs.apiary.io/#reference/quickstart-catalog"}
_, err := htmlScrapeANX(&data)
if err != nil {
if _, err := htmlScrapeANX(&data); err != nil {
t.Error(err)
}
}
@@ -322,8 +315,7 @@ func TestHTMLPoloniex(t *testing.T) {
DateFormat: "2006-01-02",
RegExp: `(2\d{3}-\d{1,2}-\d{1,2})`,
Path: "https://docs.poloniex.com/#changelog"}
_, err := htmlScrapePoloniex(&data)
if err != nil {
if _, err := htmlScrapePoloniex(&data); err != nil {
t.Error(err)
}
}
@@ -338,8 +330,7 @@ func TestHTMLItBit(t *testing.T) {
DateFormat: "2006-01-02",
RegExp: `^https://api.itbit.com/v\d{1}/$`,
Path: "https://api.itbit.com/docs"}
_, err := htmlScrapeItBit(&data)
if err != nil {
if _, err := htmlScrapeItBit(&data); err != nil {
t.Error(err)
}
}
@@ -348,8 +339,7 @@ func TestHTMLScrapeExmo(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `Last updated on [\s\S]*, 20\d{2}`,
Path: "https://exmo.com/en/api/"}
_, err := htmlScrapeExmo(&data)
if err != nil {
if _, err := htmlScrapeExmo(&data); err != nil {
t.Error(err)
}
}
@@ -358,8 +348,7 @@ func TestHTMLBitstamp(t *testing.T) {
t.Parallel()
data := HTMLScrapingData{RegExp: `refer to the v\d{1} API for future references.`,
Path: "https://www.bitstamp.net/api/"}
_, err := htmlScrapeBitstamp(&data)
if err != nil {
if _, err := htmlScrapeBitstamp(&data); err != nil {
t.Error(err)
}
}
@@ -371,8 +360,7 @@ func TestHTMLKraken(t *testing.T) {
TextTokenData: "p",
RegExp: `URL: https://api.kraken.com/\d{1}/private/Balance`,
Path: "https://www.kraken.com/features/api"}
_, err := htmlScrapeKraken(&data)
if err != nil {
if _, err := htmlScrapeKraken(&data); err != nil {
t.Error(err)
}
}
@@ -386,8 +374,7 @@ func TestHTMLAlphaPoint(t *testing.T) {
TextTokenData: "h3",
RegExp: `revised-calls-\d{1}-\d{1}-\d{1}-gt-\d{1}-\d{1}-\d{1}`,
Path: "https://alphapoint.github.io/slate/#introduction"}
_, err := htmlScrapeAlphaPoint(&data)
if err != nil {
if _, err := htmlScrapeAlphaPoint(&data); err != nil {
t.Error(err)
}
}
@@ -397,8 +384,7 @@ func TestHTMLYobit(t *testing.T) {
data := HTMLScrapingData{TokenData: "h2",
Key: "id",
Path: "https://www.yobit.net/en/api/"}
_, err := htmlScrapeYobit(&data)
if err != nil {
if _, err := htmlScrapeYobit(&data); err != nil {
t.Error(err)
}
}
@@ -408,8 +394,7 @@ func TestHTMLScrapeLocalBitcoins(t *testing.T) {
data := HTMLScrapingData{TokenData: "div",
RegExp: `col-md-12([\s\S]*?)clearfix`,
Path: "https://localbitcoins.com/api-docs/"}
_, err := htmlScrapeLocalBitcoins(&data)
if err != nil {
if _, err := htmlScrapeLocalBitcoins(&data); err != nil {
t.Error(err)
}
}
@@ -422,8 +407,7 @@ func TestHTMLScrapeOk(t *testing.T) {
TokenDataEnd: "./#change-",
RegExp: `./#change-\d{8}`,
Path: "https://www.okex.com/docs/en/"}
_, err := htmlScrapeOk(&data)
if err != nil {
if _, err := htmlScrapeOk(&data); err != nil {
t.Error(err)
}
}
@@ -547,8 +531,7 @@ func TestTrelloGetLists(t *testing.T) {
if !areTestAPIKeysSet() {
t.Skip()
}
_, err := trelloGetLists()
if err != nil {
if _, err := trelloGetLists(); err != nil {
t.Error(err)
}
}
@@ -557,8 +540,7 @@ func TestGetAllCards(t *testing.T) {
if !areTestAPIKeysSet() {
t.Skip()
}
_, err := trelloGetAllCards()
if err != nil {
if _, err := trelloGetAllCards(); err != nil {
t.Error(err)
}
}
@@ -567,8 +549,7 @@ func TestGetAllChecklists(t *testing.T) {
if !areTestAPIKeysSet() {
t.Skip()
}
_, err := trelloGetAllChecklists()
if err != nil {
if _, err := trelloGetAllChecklists(); err != nil {
t.Error(err)
}
}
@@ -580,8 +561,7 @@ func TestTrelloGetAllBoards(t *testing.T) {
if trelloBoardID != "" || testBoardName != "" {
t.Skip()
}
_, err := trelloGetBoardID()
if err != nil {
if _, err := trelloGetBoardID(); err != nil {
t.Error(err)
}
}
@@ -590,8 +570,7 @@ func TestCreateNewList(t *testing.T) {
if !areTestAPIKeysSet() {
t.Skip()
}
err := trelloCreateNewList()
if err != nil {
if err := trelloCreateNewList(); err != nil {
t.Error(err)
}
}
@@ -600,8 +579,7 @@ func TestTrelloCreateNewCard(t *testing.T) {
if !areTestAPIKeysSet() {
t.Skip()
}
err := trelloCreateNewCard()
if err != nil {
if err := trelloCreateNewCard(); err != nil {
t.Error(err)
}
}
@@ -610,8 +588,7 @@ func TestCreateNewChecklist(t *testing.T) {
if !areTestAPIKeysSet() {
t.Skip()
}
err := trelloCreateNewChecklist()
if err != nil {
if err := trelloCreateNewChecklist(); err != nil {
t.Error(err)
}
}
@@ -619,8 +596,7 @@ func TestCreateNewChecklist(t *testing.T) {
func TestWriteAuthVars(t *testing.T) {
if canTestMainFile {
trelloCardID = "jdsfl"
err := writeAuthVars(testMode)
if err != nil {
if err := writeAuthVars(testMode); err != nil {
t.Error(err)
}
}

View File

@@ -38,8 +38,7 @@ func TestLoad(t *testing.T) {
fs := &flag.FlagSet{}
fs.String("config", testConfig, "")
newCtx := cli.NewContext(testApp, fs, &cli.Context{})
err := load(newCtx)
if err != nil {
if err := load(newCtx); err != nil {
t.Fatal(err)
}
}

View File

@@ -951,12 +951,10 @@ func outputToConsole(exchangeResponses []ExchangeResponses) {
// disruptFormatting adds in an unused delimiter and strange casing features to
// ensure format currency pair is used throughout the code base.
func disruptFormatting(p currency.Pair) (currency.Pair, error) {
base := p.Base.String()
if base == "" {
if p.Base.IsEmpty() {
return currency.Pair{}, errors.New("cannot disrupt formatting as base is not populated")
}
quote := p.Quote.String()
if quote == "" {
if p.Quote.IsEmpty() {
return currency.Pair{}, errors.New("cannot disrupt formatting as quote is not populated")
}

View File

@@ -24,8 +24,7 @@ func clearScreen() error {
}
func closeConn(conn *grpc.ClientConn, cancel context.CancelFunc) {
err := conn.Close()
if err != nil {
if err := conn.Close(); err != nil {
fmt.Println(err)
}
if cancel != nil {