-
Notifications
You must be signed in to change notification settings - Fork 38
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
base: master
Are you sure you want to change the base?
Org-wide linter #2943
Conversation
Signed-off-by: Andrey Butusov <[email protected]>
Error: `Non-wrapping format verb for fmt.Errorf. Use `%w` to format errors` and `comparing with != || == will fail on wrapped errors. Use errors.Is to check for a specific error`. Signed-off-by: Andrey Butusov <[email protected]>
Error: `Error return value is not checked`. Signed-off-by: Andrey Butusov <[email protected]>
Error: `for loop can be changed to use an integer range (Go 1.22+)`. Signed-off-by: Andrey Butusov <[email protected]>
Errors: `unnecessary leading newline` and `unnecessary trailing newline`. Signed-off-by: Andrey Butusov <[email protected]>
Signed-off-by: Andrey Butusov <[email protected]>
Error: `SA4004: the surrounding loop is unconditionally terminated`. Signed-off-by: Andrey Butusov <[email protected]>
Error in `cmd/neofs-node/config.go`: `Function `Reload->Init->init->listenEvents` should pass the context parameter`. Signed-off-by: Andrey Butusov <[email protected]>
Error: `Comment should end in a period`. Signed-off-by: Andrey Butusov <[email protected]>
Signed-off-by: Andrey Butusov <[email protected]>
Error: `duplicated-imports`. Signed-off-by: Andrey Butusov <[email protected]>
Errors: `S1023: redundant `return` statement` and `S1019: should use make(chan *Move) instead`. Signed-off-by: Andrey Butusov <[email protected]>
Use: - `eacl.Target.RawSubjects` instead of `eacl.Target.BinaryKeys` - `eacl.NewTargetByRole` with `eacl.Target.SetRawSubjects` for targets with public keys - `eacl.ConstructTable` instead of `eacl.NewTable` - `eacl.ConstructRecord` instead of `eacl.NewRecord` - `object.Object.GetID` instead of `object.Object.ID` - `object.Object.GetContainerID` instead of `object.Object.ContainerID` - comparing with == instead of `ID.Equals` - `cid.NewFromMarshalledContainer(cnr.Marshal())` instead of `cid.ID .CalculateID` - `user.NewFromECDSAPublicKey` instead of `user.ResolveFromECDSAPublicKey` - direct copy instead of `ID.Encode` - direct assign instead of `ID.SetSHA256` Signed-off-by: Andrey Butusov <[email protected]>
Error: `struct literal uses unkeyed fields`. Signed-off-by: Andrey Butusov <[email protected]>
Signed-off-by: Andrey Butusov <[email protected]>
Update to `math/rand/v2` and use `crypto/rand` for `rand.Read`. Signed-off-by: Andrey Butusov <[email protected]>
Signed-off-by: Andrey Butusov <[email protected]>
Closes #2940. Signed-off-by: Andrey Butusov <[email protected]>
@@ -60,7 +60,7 @@ func (w *genericWriter) writeData(_ oid.ID, p string, data []byte) error { | |||
for i := range retryCount { | |||
tmpPath := p + "#" + strconv.FormatUint(uint64(i), 10) | |||
err := w.writeAndRename(tmpPath, p, data) | |||
if err != syscall.EEXIST || i == retryCount-1 { | |||
if errors.Is(err, syscall.EEXIST) || i == retryCount-1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug.
@@ -74,9 +74,9 @@ func TestCounters(t *testing.T) { | |||
dir := t.TempDir() | |||
sh, mm := shardWithMetrics(t, dir) | |||
|
|||
sh.SetMode(mode.ReadOnly) | |||
_ = sh.SetMode(mode.ReadOnly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be checked with require.NoError()
key := "credentials." + glagolitsa.LetterByIndex(i) | ||
require.Equal(t, "password", v.GetString(key)) | ||
} | ||
|
||
key := "credentials." + glagolitsa.LetterByIndex(i) | ||
key := "credentials." + glagolitsa.LetterByIndex(i+1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use n
here?
@@ -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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
neofs-node/pkg/local_object_storage/metabase/delete_test.go
Lines 63 to 65 in b135a0e
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.neofs-node/pkg/local_object_storage/metabase/delete_test.go
Lines 67 to 69 in b135a0e
ok, err = metaExists(db, object.AddressOf(parent)) | |
require.Error(t, apistatus.ObjectAlreadyRemoved{}) | |
require.False(t, ok) |
@@ -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)) |
There was a problem hiding this comment.
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
.
@@ -224,7 +224,7 @@ func testForestTreeDrop(t *testing.T, s Forest) { | |||
require.NoError(t, err) | |||
} | |||
} | |||
list, err := s.TreeList(cid) | |||
list, _ := s.TreeList(cid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require.NoError(t, err)
?
@@ -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 { |
There was a problem hiding this comment.
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?
@@ -101,6 +101,7 @@ func equalListShardResponseBodies(b1, b2 *control.ListShardsResponse_Body) bool | |||
|
|||
return true | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace change.
@@ -684,7 +685,7 @@ func prepareRandomTree(nodeCount, opCount int) []Move { | |||
Child: uint64(i) + 1, | |||
} | |||
//nolint:staticcheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop these comments then?
Closes #2940.