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

Org-wide linter #2943

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
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
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 @@ -60,11 +60,11 @@ func TestDB_Delete(t *testing.T) {

// check if they marked as already removed

ok, err := metaExists(db, object.AddressOf(child))
ok, _ := metaExists(db, object.AddressOf(child))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. It looks like a test bug in fact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I added err to require.Error and everything all right.

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

But there is err == nil and ok is false, i think it is wrong.
ok, err = metaExists(db, object.AddressOf(parent))
require.Error(t, apistatus.ObjectAlreadyRemoved{})
require.False(t, ok)

require.Error(t, 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
2 changes: 1 addition & 1 deletion pkg/local_object_storage/metabase/exists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func TestDB_Exists(t *testing.T) {
require.False(t, gotObj)
require.ErrorIs(t, err, meta.ErrObjectIsExpired)

gotObj, err = metaExists(db, object.AddressOf(nonExp))
gotObj, _ = metaExists(db, object.AddressOf(nonExp))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This better be checked for nil.

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
2 changes: 1 addition & 1 deletion pkg/local_object_storage/pilorama/forest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func testForestTreeDrop(t *testing.T, s Forest) {
require.NoError(t, err)
}
}
list, err := s.TreeList(cid)
list, _ := s.TreeList(cid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require.NoError(t, err)?

require.NotEmpty(t, list)

require.NoError(t, s.TreeDrop(cid, ""))
Expand Down
4 changes: 0 additions & 4 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)
prm.SetObject(o1)
_, err := sh.Put(prm)
require.NoError(t, err)
objs = append(objs, o1)

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

o3 := generateObjectWithCID(t, 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
1 change: 0 additions & 1 deletion pkg/local_object_storage/shard/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (m *metricsStore) AddToPayloadSize(size int64) {

const physical = "phy"
const logical = "logic"
const readonly = "readonly"

func TestCounters(t *testing.T) {
dir := t.TempDir()
Expand Down
4 changes: 2 additions & 2 deletions pkg/local_object_storage/shard/shutdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func TestWriteCacheObjectLoss(t *testing.T) {

objects := make([]*objectSDK.Object, objCount)
for i := range objects {
size := smallSize
size := smallSize / 2
// if i%2 == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop commented out code? Why is it here?

size = smallSize / 2
//size = smallSize / 2
// }
data := make([]byte, size)
//nolint:staticcheck
Expand Down
11 changes: 0 additions & 11 deletions pkg/services/object/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ type testClient struct {
}
}

type testEpochReceiver uint64

func (e testEpochReceiver) currentEpoch() (uint64, error) {
return uint64(e), nil
}

func newTestStorage() *testStorage {
return &testStorage{
inhumed: make(map[string]struct{}),
Expand Down Expand Up @@ -195,11 +189,6 @@ func (s *testStorage) inhume(addr oid.Address) {
s.inhumed[addr.EncodeToString()] = struct{}{}
}

const (
splitV1 = iota
splitV2
)

func generateObject(addr oid.Address, prev *oid.ID, payload []byte, children ...oid.ID) *objectSDK.Object {
obj := objectSDK.New()
obj.SetContainerID(addr.Container())
Expand Down
16 changes: 8 additions & 8 deletions pkg/services/object_manager/placement/traverser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func copyVectors(v [][]netmap.NodeInfo) [][]netmap.NodeInfo {
return vc
}

func testPlacement(t *testing.T, ss, rs []int) ([][]netmap.NodeInfo, container.Container) {
func testPlacement(ss, rs []int) ([][]netmap.NodeInfo, container.Container) {
nodes := make([][]netmap.NodeInfo, 0, len(rs))
replicas := make([]netmap.ReplicaDescriptor, 0, len(rs))
num := uint32(0)
Expand Down Expand Up @@ -83,7 +83,7 @@ func TestTraverserObjectScenarios(t *testing.T) {
selectors := []int{2, 3}
replicas := []int{1, 2}

nodes, cnr := testPlacement(t, selectors, replicas)
nodes, cnr := testPlacement(selectors, replicas)

nodesCopy := copyVectors(nodes)

Expand Down Expand Up @@ -112,7 +112,7 @@ func TestTraverserObjectScenarios(t *testing.T) {
selectors := []int{5, 3}
replicas := []int{2, 2}

nodes, cnr := testPlacement(t, selectors, replicas)
nodes, cnr := testPlacement(selectors, replicas)

nodesCopy := copyVectors(nodes)

Expand Down Expand Up @@ -141,7 +141,7 @@ func TestTraverserObjectScenarios(t *testing.T) {
selectors := []int{5, 3}
replicas := []int{2, 2}

nodes, cnr := testPlacement(t, selectors, replicas)
nodes, cnr := testPlacement(selectors, replicas)

nodesCopy := copyVectors(nodes)

Expand Down Expand Up @@ -184,7 +184,7 @@ func TestTraverserObjectScenarios(t *testing.T) {
selectors := []int{2, 3}
replicas := []int{1, 2}

nodes, cnr := testPlacement(t, selectors, replicas)
nodes, cnr := testPlacement(selectors, replicas)

tr, err := NewTraverser(
ForContainer(cnr),
Expand Down Expand Up @@ -214,7 +214,7 @@ func TestCopiesNumber(t *testing.T) {
selectors := []int{1, 2, 3} // 3 vectors with 1, 2, 3 lengths
replicas := []int{0, 2, 3} // REP 0 ... REP 2 ... REP 3

nodes, cnr := testPlacement(t, selectors, replicas)
nodes, cnr := testPlacement(selectors, replicas)
nodesCopy := copyVectors(nodes)

tr, err := NewTraverser(
Expand All @@ -241,7 +241,7 @@ func TestCopiesNumber(t *testing.T) {
selectors := []int{1, 1, 1} // 3 vectors with 1, 1, 1 lengths
replicas := []int{1, 1, 1} // REP 1 ... REP 1 ... REP 1

nodes, cnr := testPlacement(t, selectors, replicas)
nodes, cnr := testPlacement(selectors, replicas)
nodesCopy := copyVectors(nodes)

tr, err := NewTraverser(
Expand All @@ -265,7 +265,7 @@ func TestCopiesNumber(t *testing.T) {
selectors := []int{10, 10, 10} // 3 vectors with 10, 10, 10 lengths
replicas := []int{1, 2, 3} // REP 1 ... REP 2 ... REP 3

nodes, cnr := testPlacement(t, selectors, replicas)
nodes, cnr := testPlacement(selectors, replicas)
nodesCopy := copyVectors(nodes)

tr, err := NewTraverser(
Expand Down