Skip to content

Commit

Permalink
*: fix unused and ineffassign lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Butusov <andrey@nspcc.io>
  • Loading branch information
End-rey committed Sep 23, 2024
1 parent b8bbb7b commit 511c96f
Show file tree
Hide file tree
Showing 32 changed files with 88 additions and 109 deletions.
4 changes: 2 additions & 2 deletions pkg/innerring/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func TestIsAutoDeploymentMode(t *testing.T) {
err = os.Setenv(envKey, "not a boolean")
require.NoError(t, err)

b, err = isAutoDeploymentMode(v)
_, err = isAutoDeploymentMode(v)
require.Error(t, err)

err = os.Setenv(envKey, "false")
Expand Down Expand Up @@ -571,7 +571,7 @@ fschain_autodeploy: true

v.Set("fschain_autodeploy", "not a boolean")

b, err = isAutoDeploymentMode(v)
_, err = isAutoDeploymentMode(v)
require.Error(t, err)

v.Set("fschain_autodeploy", "false")
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/engine/control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestExecBlocks(t *testing.T) {
})

// put some object
obj := generateObjectWithCID(t, cidtest.ID())
obj := generateObjectWithCID(cidtest.ID())

addr := object.AddressOf(obj)

Expand Down
6 changes: 3 additions & 3 deletions pkg/local_object_storage/engine/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func TestDeleteBigObject(t *testing.T) {
parentID := oidtest.ID()
splitID := objectSDK.NewSplitID()

parent := generateObjectWithCID(t, cnr)
parent := generateObjectWithCID(cnr)
parent.SetID(parentID)
parent.SetPayload(nil)

const childCount = 10
children := make([]*objectSDK.Object, childCount)
childIDs := make([]oid.ID, childCount)
for i := range children {
children[i] = generateObjectWithCID(t, cnr)
children[i] = generateObjectWithCID(cnr)
if i != 0 {
children[i].SetPreviousID(childIDs[i-1])
}
Expand All @@ -41,7 +41,7 @@ func TestDeleteBigObject(t *testing.T) {
childIDs[i], _ = children[i].ID()
}

link := generateObjectWithCID(t, cnr)
link := generateObjectWithCID(cnr)
link.SetParent(parent)
link.SetParentID(parentID)
link.SetSplitID(splitID)
Expand Down
4 changes: 2 additions & 2 deletions pkg/local_object_storage/engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func benchmarkExists(b *testing.B, shardNum int) {

addr := oidtest.Address()
for range 100 {
obj := generateObjectWithCID(b, cidtest.ID())
obj := generateObjectWithCID(cidtest.ID())
err := Put(e, obj)
if err != nil {
b.Fatal(err)
Expand Down Expand Up @@ -174,7 +174,7 @@ func testEngineFromShardOpts(t *testing.T, num int, extraOpts []shard.Option) *S
return engine
}

func generateObjectWithCID(t testing.TB, cnr cid.ID) *object.Object {
func generateObjectWithCID(cnr cid.ID) *object.Object {
var ver version.Version
ver.SetMajor(2)
ver.SetMinor(1)
Expand Down
6 changes: 3 additions & 3 deletions pkg/local_object_storage/engine/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestErrorReporting(t *testing.T) {
t.Run("ignore errors by default", func(t *testing.T) {
e, dir, id := newEngineWithErrorThreshold(t, "", 0)

obj := generateObjectWithCID(t, cidtest.ID())
obj := generateObjectWithCID(cidtest.ID())
obj.SetPayload(make([]byte, errSmallSize))

var prm shard.PutPrm
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestErrorReporting(t *testing.T) {

e, dir, id := newEngineWithErrorThreshold(t, "", errThreshold)

obj := generateObjectWithCID(t, cidtest.ID())
obj := generateObjectWithCID(cidtest.ID())
obj.SetPayload(make([]byte, errSmallSize))

var prm shard.PutPrm
Expand Down Expand Up @@ -145,7 +145,7 @@ func TestBlobstorFailback(t *testing.T) {

objs := make([]*objectSDK.Object, 0, 2)
for _, size := range []int{15, errSmallSize + 1} {
obj := generateObjectWithCID(t, cidtest.ID())
obj := generateObjectWithCID(cidtest.ID())
obj.SetPayload(make([]byte, size))

var prm shard.PutPrm
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/engine/evacuate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func newEngineEvacuate(t *testing.T, shardNum int, objPerShard int) (*StorageEng

objects := make([]*objectSDK.Object, 0, objPerShard*len(ids))
for i := 0; ; i++ {
objects = append(objects, generateObjectWithCID(t, cidtest.ID()))
objects = append(objects, generateObjectWithCID(cidtest.ID()))

var putPrm PutPrm
putPrm.WithObject(objects[i])
Expand Down
18 changes: 9 additions & 9 deletions pkg/local_object_storage/engine/gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,27 @@ func TestChildrenExpiration(t *testing.T) {
cnr := cidtest.ID()
splitID := objectSDK.NewSplitID()

parent := generateObjectWithCID(t, cnr)
parent := generateObjectWithCID(cnr)
parentID, _ := parent.ID()
parent.SetAttributes(expAttr)

child1 := generateObjectWithCID(t, cnr)
child1 := generateObjectWithCID(cnr)
child1ID, _ := child1.ID()
child1.SetSplitID(splitID)

child2 := generateObjectWithCID(t, cnr)
child2 := generateObjectWithCID(cnr)
child2ID, _ := child2.ID()
child2.SetSplitID(splitID)
child2.SetPreviousID(child1ID)

child3 := generateObjectWithCID(t, cnr)
child3 := generateObjectWithCID(cnr)
child3ID, _ := child3.ID()
child3.SetSplitID(splitID)
child3.SetPreviousID(child2ID)
child3.SetParent(parent)
child3.SetParentID(parentID)

link := generateObjectWithCID(t, cnr)
link := generateObjectWithCID(cnr)
link.SetParent(parent)
link.SetParentID(parentID)
link.SetChildren(child1ID, child2ID, child3ID)
Expand All @@ -106,20 +106,20 @@ func TestChildrenExpiration(t *testing.T) {
t.Run("V2", func(t *testing.T) {
cnr := cidtest.ID()

parent := generateObjectWithCID(t, cnr)
parent := generateObjectWithCID(cnr)
parentID, _ := parent.ID()
parent.SetAttributes(expAttr)

child1 := generateObjectWithCID(t, cnr)
child1 := generateObjectWithCID(cnr)
child1ID, _ := child1.ID()
child1.SetParent(parent)

child2 := generateObjectWithCID(t, cnr)
child2 := generateObjectWithCID(cnr)
child2ID, _ := child2.ID()
child2.SetFirstID(child1ID)
child2.SetPreviousID(child1ID)

child3 := generateObjectWithCID(t, cnr)
child3 := generateObjectWithCID(cnr)
child3ID, _ := child3.ID()
child3.SetFirstID(child1ID)
child3.SetPreviousID(child2ID)
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/engine/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func TestStorageEngine_GetBytes(t *testing.T) {
e, _, _ := newEngine(t, t.TempDir())
obj := generateObjectWithCID(t, cidtest.ID())
obj := generateObjectWithCID(cidtest.ID())
addr := object.AddressOf(obj)

objBin := obj.Marshal()
Expand Down
6 changes: 3 additions & 3 deletions pkg/local_object_storage/engine/head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestHeadRaw(t *testing.T) {
cnr := cidtest.ID()
splitID := object.NewSplitID()

parent := generateObjectWithCID(t, cnr)
parent := generateObjectWithCID(cnr)
addAttribute(parent, "foo", "bar")

var parentAddr oid.Address
Expand All @@ -26,12 +26,12 @@ func TestHeadRaw(t *testing.T) {
idParent, _ := parent.ID()
parentAddr.SetObject(idParent)

child := generateObjectWithCID(t, cnr)
child := generateObjectWithCID(cnr)
child.SetParent(parent)
child.SetParentID(idParent)
child.SetSplitID(splitID)

link := generateObjectWithCID(t, cnr)
link := generateObjectWithCID(cnr)
link.SetParent(parent)
link.SetParentID(idParent)

Expand Down
10 changes: 5 additions & 5 deletions pkg/local_object_storage/engine/inhume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ func TestStorageEngine_Inhume(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddRootFilter()

tombstoneID := object.AddressOf(generateObjectWithCID(t, cnr))
parent := generateObjectWithCID(t, cnr)
tombstoneID := object.AddressOf(generateObjectWithCID(cnr))
parent := generateObjectWithCID(cnr)

child := generateObjectWithCID(t, cnr)
child := generateObjectWithCID(cnr)
child.SetParent(parent)
idParent, _ := parent.ID()
child.SetParentID(idParent)
child.SetSplitID(splitID)

link := generateObjectWithCID(t, cnr)
link := generateObjectWithCID(cnr)
link.SetParent(parent)
link.SetParentID(idParent)
idChild, _ := child.ID()
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestStorageEngine_Inhume(t *testing.T) {
})

t.Run("object is on wrong shard", func(t *testing.T) {
obj := generateObjectWithCID(t, cnr)
obj := generateObjectWithCID(cnr)
addr := object.AddressOf(obj)

e := testNewEngineWithShardNum(t, 2)
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/engine/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestListWithCursor(t *testing.T) {

for range total {
containerID := cidtest.ID()
obj := generateObjectWithCID(t, containerID)
obj := generateObjectWithCID(containerID)

var prm PutPrm
prm.WithObject(obj)
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/engine/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func benchmarkTreeVsSearch(b *testing.B, objCount int) {
treeID := "someTree"

for i := range objCount {
obj := generateObjectWithCID(b, cid)
obj := generateObjectWithCID(cid)
addAttribute(obj, pilorama.AttributeFilename, strconv.Itoa(i))
err := Put(e, obj)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/local_object_storage/metabase/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ func TestDB_Delete(t *testing.T) {
// check if they marked as already removed

ok, err := metaExists(db, object.AddressOf(child))
require.Error(t, apistatus.ObjectAlreadyRemoved{})
require.Error(t, err, apistatus.ObjectAlreadyRemoved{})
require.False(t, ok)

ok, err = metaExists(db, object.AddressOf(parent))
ok, _ = metaExists(db, object.AddressOf(parent))
require.Error(t, apistatus.ObjectAlreadyRemoved{})
require.False(t, ok)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/local_object_storage/metabase/exists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func TestDB_Exists(t *testing.T) {
require.ErrorIs(t, err, meta.ErrObjectIsExpired)

gotObj, err = metaExists(db, object.AddressOf(nonExp))
require.NoError(t, err)
require.True(t, gotObj)
})
})
Expand Down
4 changes: 0 additions & 4 deletions pkg/local_object_storage/metabase/graveyard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectsdk "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -442,15 +441,13 @@ func TestDB_GetGarbage(t *testing.T) {

const numOfObjs = 5
cID := cidtest.ID()
var oo []*objectsdk.Object
var size uint64

for i := range numOfObjs {
raw := generateObjectWithCID(t, cID)
addAttribute(raw, "foo"+strconv.Itoa(i), "bar"+strconv.Itoa(i))

size += raw.PayloadSize()
oo = append(oo, raw)

err := putBig(db, raw)
require.NoError(t, err)
Expand All @@ -460,7 +457,6 @@ func TestDB_GetGarbage(t *testing.T) {
anotherObj := generateObjectWithCID(t, cidtest.ID())
err := putBig(db, anotherObj)
require.NoError(t, err)
oo = append(oo, anotherObj)

_, err = db.InhumeContainer(cID)
require.NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions pkg/local_object_storage/pilorama/forest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func testForestTreeDrop(t *testing.T, s Forest) {
}
}
list, err := s.TreeList(cid)
require.NoError(t, err)
require.NotEmpty(t, list)

require.NoError(t, s.TreeDrop(cid, ""))
Expand Down
10 changes: 3 additions & 7 deletions pkg/local_object_storage/shard/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,24 @@ func TestShard_DeleteContainer(t *testing.T) {
defer releaseShard(sh, t)

cID := cidtest.ID()
var objs []*objectSDK.Object
var prm shard.PutPrm

o1 := generateObjectWithCID(t, cID)
o1 := generateObjectWithCID(cID)
prm.SetObject(o1)
_, err := sh.Put(prm)
require.NoError(t, err)
objs = append(objs, o1)

o2 := generateObjectWithCID(t, cID)
o2 := generateObjectWithCID(cID)
o2.SetType(objectSDK.TypeStorageGroup)
prm.SetObject(o2)
_, err = sh.Put(prm)
require.NoError(t, err)
objs = append(objs, o2)

o3 := generateObjectWithCID(t, cID)
o3 := generateObjectWithCID(cID)
prm.SetObject(o3)
o3.SetType(objectSDK.TypeLock)
_, err = sh.Put(prm)
require.NoError(t, err)
objs = append(objs, o3)

err = sh.DeleteContainer(context.Background(), cID)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/local_object_storage/shard/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {

cnr := cidtest.ID()

obj := generateObjectWithCID(t, cnr)
obj := generateObjectWithCID(cnr)
addAttribute(obj, "foo", "bar")

var putPrm shard.PutPrm
Expand Down Expand Up @@ -55,7 +55,7 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
})

t.Run("small object", func(t *testing.T) {
obj := generateObjectWithCID(t, cnr)
obj := generateObjectWithCID(cnr)
addAttribute(obj, "foo", "bar")
addPayload(obj, 1<<5)

Expand Down
6 changes: 3 additions & 3 deletions pkg/local_object_storage/shard/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func testDump(t *testing.T, objCount int, hasWriteCache bool) {
}
data := make([]byte, size)
_, _ = rand.Read(data)
obj := generateObjectWithPayload(t, cnr, data)
obj := generateObjectWithPayload(cnr, data)
objects[i] = obj

var prm shard.PutPrm
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestStream(t *testing.T) {
objects := make([]*objectSDK.Object, objCount)
for i := range objCount {
cnr := cidtest.ID()
obj := generateObjectWithCID(t, cnr)
obj := generateObjectWithCID(cnr)
objects[i] = obj

var prm shard.PutPrm
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestDumpIgnoreErrors(t *testing.T) {
objects := make([]*objectSDK.Object, objCount)
for i := range objCount {
size := (wcSmallObjectSize << (i % 4)) - headerSize
obj := generateObjectWithPayload(t, cidtest.ID(), make([]byte, size))
obj := generateObjectWithPayload(cidtest.ID(), make([]byte, size))
objects[i] = obj

var prm shard.PutPrm
Expand Down
Loading

0 comments on commit 511c96f

Please sign in to comment.