Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bump golangci lint to 1.62 #3278

Merged
merged 9 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ linters-settings:
excludes:
- G204 # Subprocess launched with a potential tainted input or cmd arguments
- G306 # Expect WriteFile permissions to be 0600 or less
- G115 # Integer overflow conversion, no solution to check the overflow in time of convert, so linter shouldn't check the overflow.
stylecheck:
checks: [ "all", "-ST1022", "-ST1003" ]
errorlint:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
working-directory: ${{ inputs.modulepath }}
args:
--config=${{ github.workspace }}/.github/golangci.yml
version: v1.59 # sync with misc/devdeps
version: v1.62 # sync with misc/devdeps
72 changes: 35 additions & 37 deletions examples/gno.land/p/demo/btree/btree_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"sort"
"testing"

"gno.land/p/demo/btree"
)

// Content represents a key-value pair where the Key can be either an int or string
Expand Down Expand Up @@ -74,7 +72,7 @@ var _ Record = Content{}
// Test helpers
// ****************************************************************************

func genericSeeding(tree *btree.BTree, size int) *btree.BTree {
func genericSeeding(tree *BTree, size int) *BTree {
for i := 0; i < size; i++ {
tree.Insert(Content{Key: i, Value: fmt.Sprintf("Value_%d", i)})
}
Expand Down Expand Up @@ -108,25 +106,25 @@ func intSlicesCompare(left, right []int) int {
// ****************************************************************************

func TestLen(t *testing.T) {
length := genericSeeding(btree.New(WithDegree(10)), 7).Len()
length := genericSeeding(New(WithDegree(10)), 7).Len()
if length != 7 {
t.Errorf("Length is incorrect. Expected 7, but got %d.", length)
}

length = genericSeeding(btree.New(WithDegree(5)), 111).Len()
length = genericSeeding(New(WithDegree(5)), 111).Len()
if length != 111 {
t.Errorf("Length is incorrect. Expected 111, but got %d.", length)
}

length = genericSeeding(btree.New(WithDegree(30)), 123).Len()
length = genericSeeding(New(WithDegree(30)), 123).Len()
if length != 123 {
t.Errorf("Length is incorrect. Expected 123, but got %d.", length)
}

}

func TestHas(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(10)), 40)
tree := genericSeeding(New(WithDegree(10)), 40)

if tree.Has(Content{Key: 7}) != true {
t.Errorf("Has(7) reported false, but it should be true.")
Expand All @@ -140,23 +138,23 @@ func TestHas(t *testing.T) {
}

func TestMin(t *testing.T) {
min := Content(genericSeeding(btree.New(WithDegree(10)), 53).Min())
min := Content(genericSeeding(New(WithDegree(10)), 53).Min())

if min.Key != 0 {
t.Errorf("Minimum should have been 0, but it was reported as %d.", min)
}
}

func TestMax(t *testing.T) {
max := Content(genericSeeding(btree.New(WithDegree(10)), 53).Min())
max := Content(genericSeeding(New(WithDegree(10)), 53).Min())

if max.Key != 0 {
t.Errorf("Minimum should have been 0, but it was reported as %d.", max)
}
}

func TestGet(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(10)), 40)
tree := genericSeeding(New(WithDegree(10)), 40)

if Content(tree.Get(Content{Key: 7})).Value != "Value_7" {
t.Errorf("Get(7) should have returned 'Value_7', but it returned %v.", tree.Get(Content{Key: 7}))
Expand All @@ -170,12 +168,12 @@ func TestGet(t *testing.T) {
}

func TestDescend(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(10)), 5)
tree := genericSeeding(New(WithDegree(10)), 5)

expected := []int{4, 3, 2, 1, 0}
found := []int{}

tree.Descend(func(_record btree.Record) bool {
tree.Descend(func(_record Record) bool {
record := Content(_record)
found = append(found, int(record.Key))
return true
Expand All @@ -187,12 +185,12 @@ func TestDescend(t *testing.T) {
}

func TestDescendGreaterThan(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(10)), 10)
tree := genericSeeding(New(WithDegree(10)), 10)

expected := []int{9, 8, 7, 6, 5}
found := []int{}

tree.DescendGreaterThan(Content{Key: 4}, func(_record btree.Record) bool {
tree.DescendGreaterThan(Content{Key: 4}, func(_record Record) bool {
record := Content(_record)
found = append(found, int(record.Key))
return true
Expand All @@ -204,12 +202,12 @@ func TestDescendGreaterThan(t *testing.T) {
}

func TestDescendLessOrEqual(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(10)), 10)
tree := genericSeeding(New(WithDegree(10)), 10)

expected := []int{4, 3, 2, 1, 0}
found := []int{}

tree.DescendLessOrEqual(Content{Key: 4}, func(_record btree.Record) bool {
tree.DescendLessOrEqual(Content{Key: 4}, func(_record Record) bool {
record := Content(_record)
found = append(found, int(record.Key))
return true
Expand All @@ -221,12 +219,12 @@ func TestDescendLessOrEqual(t *testing.T) {
}

func TestDescendRange(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(10)), 10)
tree := genericSeeding(New(WithDegree(10)), 10)

expected := []int{6, 5, 4, 3, 2}
found := []int{}

tree.DescendRange(Content{Key: 6}, Content{Key: 1}, func(_record btree.Record) bool {
tree.DescendRange(Content{Key: 6}, Content{Key: 1}, func(_record Record) bool {
record := Content(_record)
found = append(found, int(record.Key))
return true
Expand All @@ -238,12 +236,12 @@ func TestDescendRange(t *testing.T) {
}

func TestAscend(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(10)), 5)
tree := genericSeeding(New(WithDegree(10)), 5)

expected := []int{0, 1, 2, 3, 4}
found := []int{}

tree.Ascend(func(_record btree.Record) bool {
tree.Ascend(func(_record Record) bool {
record := Content(_record)
found = append(found, int(record.Key))
return true
Expand All @@ -255,12 +253,12 @@ func TestAscend(t *testing.T) {
}

func TestAscendGreaterOrEqual(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(10)), 10)
tree := genericSeeding(New(WithDegree(10)), 10)

expected := []int{5, 6, 7, 8, 9}
found := []int{}

tree.AscendGreaterOrEqual(Content{Key: 5}, func(_record btree.Record) bool {
tree.AscendGreaterOrEqual(Content{Key: 5}, func(_record Record) bool {
record := Content(_record)
found = append(found, int(record.Key))
return true
Expand All @@ -272,12 +270,12 @@ func TestAscendGreaterOrEqual(t *testing.T) {
}

func TestAscendLessThan(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(10)), 10)
tree := genericSeeding(New(WithDegree(10)), 10)

expected := []int{0, 1, 2, 3, 4}
found := []int{}

tree.AscendLessThan(Content{Key: 5}, func(_record btree.Record) bool {
tree.AscendLessThan(Content{Key: 5}, func(_record Record) bool {
record := Content(_record)
found = append(found, int(record.Key))
return true
Expand All @@ -289,12 +287,12 @@ func TestAscendLessThan(t *testing.T) {
}

func TestAscendRange(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(10)), 10)
tree := genericSeeding(New(WithDegree(10)), 10)

expected := []int{2, 3, 4, 5, 6}
found := []int{}

tree.AscendRange(Content{Key: 2}, Content{Key: 7}, func(_record btree.Record) bool {
tree.AscendRange(Content{Key: 2}, Content{Key: 7}, func(_record Record) bool {
record := Content(_record)
found = append(found, int(record.Key))
return true
Expand All @@ -306,7 +304,7 @@ func TestAscendRange(t *testing.T) {
}

func TestDeleteMin(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(3)), 100)
tree := genericSeeding(New(WithDegree(3)), 100)

expected := []int{0, 1, 2, 3, 4}
found := []int{}
Expand All @@ -323,7 +321,7 @@ func TestDeleteMin(t *testing.T) {
}

func TestShift(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(3)), 100)
tree := genericSeeding(New(WithDegree(3)), 100)

expected := []int{0, 1, 2, 3, 4}
found := []int{}
Expand All @@ -340,7 +338,7 @@ func TestShift(t *testing.T) {
}

func TestDeleteMax(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(3)), 100)
tree := genericSeeding(New(WithDegree(3)), 100)

expected := []int{99, 98, 97, 96, 95}
found := []int{}
Expand All @@ -357,7 +355,7 @@ func TestDeleteMax(t *testing.T) {
}

func TestPop(t *testing.T) {
tree := genericSeeding(btree.New(WithDegree(3)), 100)
tree := genericSeeding(New(WithDegree(3)), 100)

expected := []int{99, 98, 97, 96, 95}
found := []int{}
Expand All @@ -374,7 +372,7 @@ func TestPop(t *testing.T) {
}

func TestInsertGet(t *testing.T) {
tree := btree.New(WithDegree(4))
tree := New(WithDegree(4))

expected := []Content{}

Expand All @@ -398,7 +396,7 @@ func TestClone(t *testing.T) {

func TestBTree(t *testing.T) {
// Create a B-Tree of degree 3
tree := btree.New(WithDegree(3))
tree := New(WithDegree(3))

//insertData := []Content{}
var insertData ContentSlice
Expand Down Expand Up @@ -475,7 +473,7 @@ func TestBTree(t *testing.T) {
t.Logf("Sorted Data Length: %d", len(sortedInsertData))
t.Logf("Tree Length: %d", tree.Len())

tree.Ascend(func(_record btree.Record) bool {
tree.Ascend(func(_record Record) bool {
record := Content(_record)
t.Logf("Key:Value == %v:%v", record.Key, record.Value)
if record.Key != sortedInsertData[pos].Key {
Expand All @@ -488,7 +486,7 @@ func TestBTree(t *testing.T) {
t.Logf("\nReverse-order Iteration:\n")
pos = len(sortedInsertData) - 1

tree.Descend(func(_record btree.Record) bool {
tree.Descend(func(_record Record) bool {
record := Content(_record)
t.Logf("Key:Value == %v:%v", record.Key, record.Value)
if record.Key != sortedInsertData[pos].Key {
Expand Down Expand Up @@ -530,7 +528,7 @@ func TestStress(t *testing.T) {

for degree := 3; degree <= 12; degree += 3 {
t.Logf("Testing B-Tree of degree %d\n", degree)
tree := btree.New(WithDegree(degree))
tree := New(WithDegree(degree))

// Insert 1000 records
t.Logf("Inserting 1000 records\n")
Expand Down Expand Up @@ -576,7 +574,7 @@ func TestStress(t *testing.T) {
// Print a few lines using Logf to let the user know what's happening.

t.Logf("Testing B-Tree of degree 10 with 100000 records\n")
tree := btree.New(WithDegree(10))
tree := New(WithDegree(10))

// Insert 100000 records
t.Logf("Inserting 100000 records\n")
Expand Down Expand Up @@ -607,7 +605,7 @@ func TestStress(t *testing.T) {

func TestBTreeCloneIsolation(t *testing.T) {
t.Logf("Creating B-Tree of degree 10 with 10000 records\n")
tree := genericSeeding(btree.New(WithDegree(10)), 10000)
tree := genericSeeding(New(WithDegree(10)), 10000)

// Clone the tree
t.Logf("Cloning the tree\n")
Expand Down
6 changes: 3 additions & 3 deletions gno.land/pkg/gnoclient/client_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}

if qres.Response.Error != nil {
return qres, errors.Wrap(qres.Response.Error, "deliver transaction failed: log:%s", qres.Response.Log)
return qres, errors.Wrapf(qres.Response.Error, "deliver transaction failed: log:%s", qres.Response.Log)

Check warning on line 34 in gno.land/pkg/gnoclient/client_queries.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoclient/client_queries.go#L34

Added line #L34 was not covered by tests
}

return qres, nil
Expand Down Expand Up @@ -97,7 +97,7 @@
return "", nil, errors.Wrap(err, "query render")
}
if qres.Response.Error != nil {
return "", nil, errors.Wrap(qres.Response.Error, "Render failed: log:%s", qres.Response.Log)
return "", nil, errors.Wrapf(qres.Response.Error, "Render failed: log:%s", qres.Response.Log)

Check warning on line 100 in gno.land/pkg/gnoclient/client_queries.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoclient/client_queries.go#L100

Added line #L100 was not covered by tests
}

return string(qres.Response.Data), qres, nil
Expand All @@ -120,7 +120,7 @@
return "", nil, errors.Wrap(err, "query qeval")
}
if qres.Response.Error != nil {
return "", nil, errors.Wrap(qres.Response.Error, "QEval failed: log:%s", qres.Response.Log)
return "", nil, errors.Wrapf(qres.Response.Error, "QEval failed: log:%s", qres.Response.Log)

Check warning on line 123 in gno.land/pkg/gnoclient/client_queries.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoclient/client_queries.go#L123

Added line #L123 was not covered by tests
}

return string(qres.Response.Data), qres, nil
Expand Down
4 changes: 2 additions & 2 deletions gno.land/pkg/gnoclient/client_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@
}

if bres.CheckTx.IsErr() {
return bres, errors.Wrap(bres.CheckTx.Error, "check transaction failed: log:%s", bres.CheckTx.Log)
return bres, errors.Wrapf(bres.CheckTx.Error, "check transaction failed: log:%s", bres.CheckTx.Log)

Check warning on line 286 in gno.land/pkg/gnoclient/client_txs.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoclient/client_txs.go#L286

Added line #L286 was not covered by tests
}
if bres.DeliverTx.IsErr() {
return bres, errors.Wrap(bres.DeliverTx.Error, "deliver transaction failed: log:%s", bres.DeliverTx.Log)
return bres, errors.Wrapf(bres.DeliverTx.Error, "deliver transaction failed: log:%s", bres.DeliverTx.Log)

Check warning on line 289 in gno.land/pkg/gnoclient/client_txs.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoclient/client_txs.go#L289

Added line #L289 was not covered by tests
}

return bres, nil
Expand Down
Loading
Loading