CI/build: Update Go version, linters and fix minor issues (#1612)

* CI/build: Update Go version, linters and fix minor issues

* linters: Add intrange, copyloopvar, additional go vet linters to match gopls and fix issues
This commit is contained in:
Adrian Gallagher
2024-08-16 17:41:11 +10:00
committed by GitHub
parent facf291069
commit 225429bda6
111 changed files with 239 additions and 379 deletions

View File

@@ -76,8 +76,7 @@ func TestAudit(t *testing.T) {
},
}
for _, tests := range testCases {
test := tests
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
if !testhelpers.CheckValidConfig(&test.config.ConnectionDetails) {
t.Skip("database not configured skipping test")
@@ -103,7 +102,7 @@ func writeAudit(t *testing.T) {
t.Helper()
var wg sync.WaitGroup
for x := 0; x < 20; x++ {
for x := range 20 {
wg.Add(1)
go func(x int) {

View File

@@ -293,7 +293,7 @@ func genOHCLVData() (out Item, err error) {
out.Asset = "spot"
start := time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)
for x := 0; x < 365; x++ {
for x := range 365 {
out.Candles = append(out.Candles, Candle{
Timestamp: start.Add(time.Hour * 24 * time.Duration(x)),
Open: 1000,

View File

@@ -118,7 +118,7 @@ func TestDataHistoryJob(t *testing.T) {
}
var jerberinos, jerberoos []*DataHistoryJob
for i := 0; i < 20; i++ {
for i := range 20 {
uu, _ := uuid.NewV4()
jerberinos = append(jerberinos, &DataHistoryJob{
ID: uu.String(),
@@ -138,7 +138,7 @@ func TestDataHistoryJob(t *testing.T) {
t.Fatal(err)
}
// insert the same jerbs to test conflict resolution
for i := 0; i < 20; i++ {
for i := range 20 {
uu, _ := uuid.NewV4()
j := &DataHistoryJob{
ID: uu.String(),

View File

@@ -139,7 +139,7 @@ func TestDataHistoryJob(t *testing.T) {
}
var resulterinos, resultaroos []*DataHistoryJobResult
for i := 0; i < 20; i++ {
for range 20 {
uu, _ := uuid.NewV4()
resulterinos = append(resulterinos, &DataHistoryJobResult{
ID: uu.String(),
@@ -156,7 +156,7 @@ func TestDataHistoryJob(t *testing.T) {
t.Fatal(err)
}
// insert the same results to test conflict resolution
for i := 0; i < 20; i++ {
for i := range 20 {
uu, _ := uuid.NewV4()
j := &DataHistoryJobResult{
ID: uu.String(),

View File

@@ -99,7 +99,7 @@ func TestScript(t *testing.T) {
func writeScript() {
var wg sync.WaitGroup
for x := 0; x < 20; x++ {
for x := range 20 {
wg.Add(1)
go func(x int) {

View File

@@ -107,11 +107,11 @@ func TestTrades(t *testing.T) {
func tradeSQLTester(t *testing.T) {
t.Helper()
var trades, trades2 []Data
trades := make([]Data, 20)
firstTime := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
for i := 0; i < 20; i++ {
for i := range 20 {
uu, _ := uuid.NewV4()
trades = append(trades, Data{
trades[i] = Data{
ID: uu.String(),
Timestamp: firstTime.Add(time.Minute * time.Duration(i+1)),
Exchange: testExchanges[0].Name,
@@ -122,16 +122,18 @@ func tradeSQLTester(t *testing.T) {
Amount: float64(i * (i + 2)),
Side: order.Buy.String(),
TID: strconv.Itoa(i),
})
}
}
err := Insert(trades...)
if err != nil {
t.Fatal(err)
}
// insert the same trades to test conflict resolution
for i := 0; i < 20; i++ {
trades2 := make([]Data, 20)
for i := range 20 {
uu, _ := uuid.NewV4()
trades2 = append(trades2, Data{
trades2[i] = Data{
ID: uu.String(),
Timestamp: firstTime.Add(time.Minute * time.Duration(i+1)),
Exchange: testExchanges[0].Name,
@@ -142,7 +144,7 @@ func tradeSQLTester(t *testing.T) {
Amount: float64(i * (i + 2)),
Side: order.Buy.String(),
TID: strconv.Itoa(i),
})
}
}
err = Insert(trades2...)
if err != nil {

View File

@@ -80,8 +80,7 @@ func TestWithdraw(t *testing.T) {
},
}
for _, tests := range testCases {
test := tests
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
if !testhelpers.CheckValidConfig(&test.config.ConnectionDetails) {
t.Skip("database not configured skipping test")
@@ -112,7 +111,7 @@ func TestWithdraw(t *testing.T) {
}
func seedWithdrawData() {
for x := 0; x < 20; x++ {
for x := range 20 {
test := fmt.Sprintf("test-%v", x)
resp := &withdraw.Response{
Exchange: withdraw.ExchangeResponse{