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 <[email protected]>
  • Loading branch information
End-rey committed Sep 23, 2024
1 parent 8d46bbe commit e51fecb
Show file tree
Hide file tree
Showing 33 changed files with 96 additions and 117 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
14 changes: 7 additions & 7 deletions pkg/local_object_storage/engine/lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestLockUserScenario(t *testing.T) {
const lockerExpiresAfter = 13

cnr := cidtest.ID()
tombObj := generateObjectWithCID(t, cnr)
tombObj := generateObjectWithCID(cnr)
tombForLockID := oidtest.ID()
tombObj.SetID(tombForLockID)

Expand Down Expand Up @@ -76,7 +76,7 @@ func TestLockUserScenario(t *testing.T) {
a.SetKey(object.AttributeExpirationEpoch)
a.SetValue(strconv.Itoa(lockerExpiresAfter))

lockerObj := generateObjectWithCID(t, cnr)
lockerObj := generateObjectWithCID(cnr)
lockerObj.SetID(lockerID)
lockerObj.SetAttributes(a)

Expand All @@ -85,7 +85,7 @@ func TestLockUserScenario(t *testing.T) {
tombForLockAddr.SetObject(tombForLockID)

// 1.
obj := generateObjectWithCID(t, cnr)
obj := generateObjectWithCID(cnr)

id, _ := obj.ID()
objAddr.SetObject(id)
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestLockExpiration(t *testing.T) {
var err error

// 1.
obj := generateObjectWithCID(t, cnr)
obj := generateObjectWithCID(cnr)

err = Put(e, obj)
require.NoError(t, err)
Expand All @@ -173,7 +173,7 @@ func TestLockExpiration(t *testing.T) {
a.SetKey(object.AttributeExpirationEpoch)
a.SetValue(strconv.Itoa(lockerExpiresAfter))

lock := generateObjectWithCID(t, cnr)
lock := generateObjectWithCID(cnr)
lock.SetType(object.TypeLock)
lock.SetAttributes(a)

Expand Down Expand Up @@ -234,13 +234,13 @@ func TestLockForceRemoval(t *testing.T) {
var err error

// 1.
obj := generateObjectWithCID(t, cnr)
obj := generateObjectWithCID(cnr)

err = Put(e, obj)
require.NoError(t, err)

// 2.
lock := generateObjectWithCID(t, cnr)
lock := generateObjectWithCID(cnr)
lock.SetType(object.TypeLock)

err = Put(e, lock)
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,11 +61,11 @@ 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.ErrorIs(t, err, apistatus.ObjectAlreadyRemoved{})
require.False(t, ok)

ok, err = metaExists(db, object.AddressOf(parent))
require.Error(t, apistatus.ObjectAlreadyRemoved{})
require.NoError(t, err)
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 @@ -9,7 +9,6 @@ import (
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
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 @@ -391,15 +390,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 @@ -409,7 +406,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
Loading

0 comments on commit e51fecb

Please sign in to comment.