Skip to content

Commit

Permalink
*: fix lint errors
Browse files Browse the repository at this point in the history
- `unused`
- `errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format
errors`
- `variable collides with imported package name`

Signed-off-by: Andrey Butusov <[email protected]>
  • Loading branch information
End-rey committed Oct 1, 2024
1 parent c2fb605 commit 7a048fe
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion cmd/neofs-cli/internal/common/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func ReadBearerToken(cmd *cobra.Command, flagname string) (*bearer.Token, error)

err = ReadBinaryOrJSON(cmd, &tok, path)
if err != nil {
return nil, fmt.Errorf("invalid bearer token: %v", err)
return nil, fmt.Errorf("invalid bearer token: %w", err)

Check warning on line 30 in cmd/neofs-cli/internal/common/token.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/internal/common/token.go#L30

Added line #L30 was not covered by tests
}

return &tok, nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-cli/modules/acl/extended/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ func createEACL(cmd *cobra.Command, _ []string) error {
var containerID cid.ID
if cidArg != "" {
if err := containerID.DecodeString(cidArg); err != nil {
return fmt.Errorf("invalid container ID: %v\n", err)
return fmt.Errorf("invalid container ID: %w\n", err)

Check warning on line 75 in cmd/neofs-cli/modules/acl/extended/create.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/acl/extended/create.go#L75

Added line #L75 was not covered by tests
}
}

rulesFile, err := getRulesFromFile(fileArg)
if err != nil {
return fmt.Errorf("can't read rules from file: %v\n", err)
return fmt.Errorf("can't read rules from file: %w\n", err)

Check warning on line 81 in cmd/neofs-cli/modules/acl/extended/create.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/acl/extended/create.go#L81

Added line #L81 was not covered by tests
}

rules = append(rules, rulesFile...)
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/container/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
for ; ; t.Reset(waitInterval) {
select {
case <-ctx.Done():
return fmt.Errorf("container creation: %s", common.ErrAwaitTimeout)
return fmt.Errorf("container creation: %w", common.ErrAwaitTimeout)

Check warning on line 160 in cmd/neofs-cli/modules/container/create.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/create.go#L160

Added line #L160 was not covered by tests
case <-t.C:
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/container/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Only owner of the container has a permission to remove container.`,
for ; ; t.Reset(waitInterval) {
select {
case <-ctx.Done():
return fmt.Errorf("container deletion: %s", common.ErrAwaitTimeout)
return fmt.Errorf("container deletion: %w", common.ErrAwaitTimeout)

Check warning on line 135 in cmd/neofs-cli/modules/container/delete.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/delete.go#L135

Added line #L135 was not covered by tests
case <-t.C:
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/container/set_eacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
for ; ; t.Reset(waitInterval) {
select {
case <-ctx.Done():
return fmt.Errorf("eACL setting: %s", common.ErrAwaitTimeout)
return fmt.Errorf("eACL setting: %w", common.ErrAwaitTimeout)

Check warning on line 139 in cmd/neofs-cli/modules/container/set_eacl.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/set_eacl.go#L139

Added line #L139 was not covered by tests
case <-t.C:
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/container/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func getSession(cmd *cobra.Command) (*session.Container, error) {

err := common.ReadBinaryOrJSON(cmd, &res, path)
if err != nil {
return nil, fmt.Errorf("read container session: %v", err)
return nil, fmt.Errorf("read container session: %w", err)

Check warning on line 52 in cmd/neofs-cli/modules/container/util.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/container/util.go#L52

Added line #L52 was not covered by tests
}

common.PrintVerbose(cmd, "Session successfully read.")
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/object/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var objectLockCmd = &cobra.Command{
var cnr cid.ID
err := cnr.DecodeString(cidRaw)
if err != nil {
return fmt.Errorf("Incorrect container arg: %v", err)
return fmt.Errorf("Incorrect container arg: %w", err)

Check warning on line 35 in cmd/neofs-cli/modules/object/lock.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/lock.go#L35

Added line #L35 was not covered by tests
}

oidsRaw, _ := cmd.Flags().GetStringSlice(commonflags.OIDFlag)
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/object/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func getSession(cmd *cobra.Command) (*session.Object, error) {

err := common.ReadBinaryOrJSON(cmd, &tok, path)
if err != nil {
return nil, fmt.Errorf("read session: %v", err)
return nil, fmt.Errorf("read session: %w", err)

Check warning on line 165 in cmd/neofs-cli/modules/object/util.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/util.go#L165

Added line #L165 was not covered by tests
}

return &tok, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/util/sign_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func signSessionToken(cmd *cobra.Command, _ []string) error {
}

if errLast != nil {
return fmt.Errorf("decode session: %v", errLast)
return fmt.Errorf("decode session: %w", errLast)

Check warning on line 66 in cmd/neofs-cli/modules/util/sign_session.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/util/sign_session.go#L66

Added line #L66 was not covered by tests
}

pk, err := key.GetOrGenerate(cmd)
Expand Down
6 changes: 3 additions & 3 deletions pkg/innerring/processors/neofs/process_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ func (np *Processor) processDeposit(deposit *neofsEvent.Deposit) {

// get gas balance of the node
// before gas transfer check if the balance is greater than the threshold
balance, err := np.morphClient.GasBalance()
gasBalance, err := np.morphClient.GasBalance()

Check warning on line 56 in pkg/innerring/processors/neofs/process_assets.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/neofs/process_assets.go#L56

Added line #L56 was not covered by tests
if err != nil {
np.log.Error("can't get gas balance of the node", zap.Error(err))
return
}

if balance < np.gasBalanceThreshold {
if gasBalance < np.gasBalanceThreshold {

Check warning on line 62 in pkg/innerring/processors/neofs/process_assets.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/neofs/process_assets.go#L62

Added line #L62 was not covered by tests
np.log.Warn("gas balance threshold has been reached",
zap.Int64("balance", balance),
zap.Int64("balance", gasBalance),

Check warning on line 64 in pkg/innerring/processors/neofs/process_assets.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/neofs/process_assets.go#L64

Added line #L64 was not covered by tests
zap.Int64("threshold", np.gasBalanceThreshold))

return
Expand Down
9 changes: 0 additions & 9 deletions pkg/local_object_storage/engine/lock_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package engine

import (
"context"
"os"
"strconv"
"testing"
Expand All @@ -20,14 +19,6 @@ import (
"github.com/stretchr/testify/require"
)

type tss struct {
expEpoch uint64
}

func (t tss) IsTombstoneAvailable(ctx context.Context, _ oid.Address, epoch uint64) bool {
return t.expEpoch >= epoch
}

func TestLockUserScenario(t *testing.T) {
// Tested user actions:
// 1. stores some object
Expand Down
4 changes: 2 additions & 2 deletions pkg/services/object/get/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ func (exec *execCtx) processNode(info client.NodeInfo) bool {

l.Debug("processing node...")

client, ok := exec.remoteClient(info)
remoteClient, ok := exec.remoteClient(info)
if !ok {
return true
}

obj, err := client.getObject(exec, info)
obj, err := remoteClient.getObject(exec, info)

var errSplitInfo *objectSDK.SplitInfoError

Expand Down

0 comments on commit 7a048fe

Please sign in to comment.