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

@@ -1208,8 +1208,7 @@ func TestValidate(t *testing.T) {
},
},
}
err := c.Validate()
if !errors.Is(err, nil) {
if err := c.Validate(); !errors.Is(err, nil) {
t.Errorf("received %v expected %v", err, nil)
}
}

View File

@@ -399,8 +399,7 @@ func parseDatabase(reader *bufio.Reader, cfg *config.Config) error {
}
fmt.Printf("What is the end date? Leave blank for \"%v\"\n", defaultStart.Format(gctcommon.SimpleTimeFormat))
endDate := quickParse(reader)
if endDate != "" {
if endDate := quickParse(reader); endDate != "" {
cfg.DataSettings.DatabaseData.EndDate, err = time.Parse(endDate, gctcommon.SimpleTimeFormat)
if err != nil {
return err

View File

@@ -19,8 +19,7 @@ type fakeDataHandler struct {
func TestBaseDataFunctions(t *testing.T) {
t.Parallel()
var d Base
latest := d.Latest()
if latest != nil {
if latest := d.Latest(); latest != nil {
t.Error("expected nil")
}
d.Next()
@@ -37,17 +36,14 @@ func TestBaseDataFunctions(t *testing.T) {
if o != 0 {
t.Error("expected 0")
}
list := d.List()
if list != nil {
if list := d.List(); list != nil {
t.Error("expected nil")
}
history := d.History()
if history != nil {
if history := d.History(); history != nil {
t.Error("expected nil")
}
d.SetStream(nil)
st := d.GetStream()
if st != nil {
if st := d.GetStream(); st != nil {
t.Error("expected nil")
}
d.Reset()
@@ -91,24 +87,24 @@ func TestStream(t *testing.T) {
d.SortStream()
f = d.Next().(fakeDataHandler)
if f.time != 1 {
f, ok := d.Next().(fakeDataHandler)
if f.time != 1 || !ok {
t.Error("expected 1")
}
f = d.Next().(fakeDataHandler)
if f.time != 2 {
f, ok = d.Next().(fakeDataHandler)
if f.time != 2 || !ok {
t.Error("expected 2")
}
f = d.Next().(fakeDataHandler)
if f.time != 4 {
f, ok = d.Next().(fakeDataHandler)
if f.time != 4 || !ok {
t.Error("expected 4")
}
f = d.Next().(fakeDataHandler)
if f.time != 10 {
f, ok = d.Next().(fakeDataHandler)
if f.time != 10 || !ok {
t.Error("expected 10")
}
f = d.Next().(fakeDataHandler)
if f.time != 20 {
f, ok = d.Next().(fakeDataHandler)
if f.time != 20 || !ok {
t.Error("expected 20")
}
}

View File

@@ -81,8 +81,7 @@ func TestHasDataAtTime(t *testing.T) {
},
},
}
err := d.Load()
if err != nil {
if err := d.Load(); err != nil {
t.Error(err)
}

View File

@@ -28,8 +28,7 @@ func TestAppendEvent(t *testing.T) {
func TestNextEvent(t *testing.T) {
t.Parallel()
e := Holder{Queue: []common.EventHandler{}}
ev := e.NextEvent()
if ev != nil {
if ev := e.NextEvent(); ev != nil {
t.Error("expected not ok")
}

View File

@@ -58,8 +58,7 @@ func (h *Holding) HasFunds() bool {
func (h *Holding) update(e fill.Event, f funding.IPairReader) {
direction := e.GetDirection()
o := e.GetOrder()
if o != nil {
if o := e.GetOrder(); o != nil {
amount := decimal.NewFromFloat(o.Amount)
fee := decimal.NewFromFloat(o.Fee)
price := decimal.NewFromFloat(o.Price)

View File

@@ -60,7 +60,7 @@ func TestUpdate(t *testing.T) {
if err != nil {
t.Error(err)
}
t1 := h.Timestamp
t1 := h.Timestamp // nolint:ifshort,nolintlint // false positive and triggers only on Windows
h.Update(&fill.Fill{
Base: event.Base{
Time: time.Now(),

View File

@@ -262,8 +262,7 @@ func (p *Portfolio) addComplianceSnapshot(fillEvent fill.Event) error {
return err
}
prevSnap := complianceManager.GetLatestSnapshot()
fo := fillEvent.GetOrder()
if fo != nil {
if fo := fillEvent.GetOrder(); fo != nil {
price := decimal.NewFromFloat(fo.Price)
amount := decimal.NewFromFloat(fo.Amount)
fee := decimal.NewFromFloat(fo.Fee)

View File

@@ -376,8 +376,7 @@ func TestAddComplianceSnapshotForTime(t *testing.T) {
func TestSerialise(t *testing.T) {
t.Parallel()
s := Statistic{}
_, err := s.Serialise()
if err != nil {
if _, err := s.Serialise(); err != nil {
t.Error(err)
}
}

View File

@@ -21,8 +21,7 @@ import (
func TestName(t *testing.T) {
d := Strategy{}
n := d.Name()
if n != Name {
if n := d.Name(); n != Name {
t.Errorf("expected %v", Name)
}
}

View File

@@ -55,9 +55,8 @@ func (s *Strategy) OnSignal(d data.Handler, _ funding.IFundTransferer) (signal.E
return nil, err
}
es.SetPrice(d.Latest().ClosePrice())
offset := d.Offset()
if offset <= int(s.rsiPeriod.IntPart()) {
if offset := d.Offset(); offset <= int(s.rsiPeriod.IntPart()) {
es.AppendReason("Not enough data for signal generation")
es.SetDirection(common.DoNothing)
return &es, nil

View File

@@ -22,8 +22,7 @@ import (
func TestName(t *testing.T) {
t.Parallel()
d := Strategy{}
n := d.Name()
if n != Name {
if n := d.Name(); n != Name {
t.Errorf("expected %v", Name)
}
}

View File

@@ -23,8 +23,7 @@ import (
func TestName(t *testing.T) {
t.Parallel()
d := Strategy{}
n := d.Name()
if n != Name {
if n := d.Name(); n != Name {
t.Errorf("expected %v", Name)
}
}
@@ -94,8 +93,7 @@ func TestSetCustomSettings(t *testing.T) {
func TestOnSignal(t *testing.T) {
t.Parallel()
s := Strategy{}
_, err := s.OnSignal(nil, nil)
if !errors.Is(err, errStrategyOnlySupportsSimultaneousProcessing) {
if _, err := s.OnSignal(nil, nil); !errors.Is(err, errStrategyOnlySupportsSimultaneousProcessing) {
t.Errorf("received: %v, expected: %v", err, errStrategyOnlySupportsSimultaneousProcessing)
}
}

View File

@@ -25,8 +25,7 @@ func TestEvent_GetAssetType(t *testing.T) {
e := &Base{
AssetType: asset.Spot,
}
y := e.GetAssetType()
if y != asset.Spot {
if y := e.GetAssetType(); y != asset.Spot {
t.Error("expected spot")
}
}
@@ -36,8 +35,7 @@ func TestEvent_GetExchange(t *testing.T) {
e := &Base{
Exchange: "test",
}
y := e.GetExchange()
if y != "test" {
if y := e.GetExchange(); y != "test" {
t.Error("expected test")
}
}
@@ -47,8 +45,7 @@ func TestEvent_GetInterval(t *testing.T) {
e := &Base{
Interval: gctkline.OneMin,
}
y := e.GetInterval()
if y != gctkline.OneMin {
if y := e.GetInterval(); y != gctkline.OneMin {
t.Error("expected one minute")
}
}