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

@@ -19,8 +19,7 @@ func CreateKline(trades []order.TradeHistory, interval Interval, p currency.Pair
return Item{}, fmt.Errorf("invalid time interval: [%s]", interval)
}
err := validateData(trades)
if err != nil {
if err := validateData(trades); err != nil {
return Item{}, err
}

View File

@@ -92,7 +92,7 @@ func TestValidateData(t *testing.T) {
func TestCreateKline(t *testing.T) {
t.Parallel()
c, err := CreateKline(nil,
_, err := CreateKline(nil,
OneMin,
currency.NewPair(currency.BTC, currency.USD),
asset.Spot,
@@ -113,7 +113,7 @@ func TestCreateKline(t *testing.T) {
})
}
c, err = CreateKline(trades,
_, err = CreateKline(trades,
0,
currency.NewPair(currency.BTC, currency.USD),
asset.Spot,
@@ -122,7 +122,7 @@ func TestCreateKline(t *testing.T) {
t.Fatal("error cannot be nil")
}
c, err = CreateKline(trades,
c, err := CreateKline(trades,
OneMin,
currency.NewPair(currency.BTC, currency.USD),
asset.Spot,
@@ -251,6 +251,8 @@ func TestDurationToWord(t *testing.T) {
for x := range testCases {
test := testCases[x]
t.Run(test.name, func(t *testing.T) {
t.Parallel()
t.Helper()
v := durationToWord(test.interval)
if !strings.EqualFold(v, test.name) {
t.Fatalf("%v: received %v expected %v", test.name, v, test.name)
@@ -261,7 +263,7 @@ func TestDurationToWord(t *testing.T) {
func TestKlineErrors(t *testing.T) {
t.Parallel()
v := ErrorKline{
v := Error{
Interval: OneYear,
Pair: currency.NewPair(currency.BTC, currency.AUD),
Err: errors.New("hello world"),
@@ -398,6 +400,7 @@ func TestTotalCandlesPerInterval(t *testing.T) {
for x := range testCases {
test := testCases[x]
t.Run(test.name, func(t *testing.T) {
t.Parallel()
v := TotalCandlesPerInterval(start, end, test.interval)
if v != test.expected {
t.Fatalf("%v: received %v expected %v", test.name, v, test.expected)
@@ -506,6 +509,7 @@ func TestItem_SortCandlesByTimestamp(t *testing.T) {
}
func setupTest(t *testing.T) {
t.Helper()
if verbose {
testhelpers.EnableVerboseTestOutput()
}

View File

@@ -128,8 +128,8 @@ type ExchangeCapabilitiesEnabled struct {
// Interval type for kline Interval usage
type Interval time.Duration
// ErrorKline struct to hold kline interval errors
type ErrorKline struct {
// Error struct to hold kline interval errors
type Error struct {
Asset asset.Item
Pair currency.Pair
Interval Interval
@@ -137,13 +137,13 @@ type ErrorKline struct {
}
// Error returns short interval unsupported message
func (k *ErrorKline) Error() string {
return k.Err.Error()
func (e *Error) Error() string {
return e.Err.Error()
}
// Unwrap returns interval unsupported message
func (k *ErrorKline) Unwrap() error {
return k.Err
func (e *Error) Unwrap() error {
return e.Err
}
// IntervalRangeHolder holds the entire range of intervals