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
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/morph/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func invokeFunction(c Client, h util.Uint160, method string, parameters []any, s

script, err := b.Script()
if err != nil {
return nil, fmt.Errorf("BUG: invalid parameters for '%s': %v", method, err)
return nil, fmt.Errorf("BUG: invalid parameters for '%s': %w", method, err)
}

return c.InvokeScript(script, signers)
Expand Down
8 changes: 4 additions & 4 deletions cmd/neofs-adm/internal/modules/morph/notary.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func depositNotary(cmd *cobra.Command, _ []string) error {

w, err := wallet.NewWalletFromFile(p)
if err != nil {
return fmt.Errorf("can't open wallet: %v", err)
return fmt.Errorf("can't open wallet: %w", err)
}

accHash := w.GetChangeAddress()
Expand All @@ -50,12 +50,12 @@ func depositNotary(cmd *cobra.Command, _ []string) error {
prompt := fmt.Sprintf("Enter password for %s >", address.Uint160ToString(accHash))
pass, err := input.ReadPassword(prompt)
if err != nil {
return fmt.Errorf("can't get password: %v", err)
return fmt.Errorf("can't get password: %w", err)
}

err = acc.Decrypt(pass, keys.NEP2ScryptParams())
if err != nil {
return fmt.Errorf("can't unlock account: %v", err)
return fmt.Errorf("can't unlock account: %w", err)
}

gasStr, err := cmd.Flags().GetString(refillGasAmountFlag)
Expand Down Expand Up @@ -86,7 +86,7 @@ func depositNotary(cmd *cobra.Command, _ []string) error {

height, err := c.GetBlockCount()
if err != nil {
return fmt.Errorf("can't get current height: %v", err)
return fmt.Errorf("can't get current height: %w", err)
}

act, err := actor.New(c, []actor.SignerAccount{{
Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-adm/internal/modules/morph/verified_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func verifiedNodesDomainSetAccessList(cmd *cobra.Command, _ []string) error {

w, err := wallet.NewWalletFromFile(viper.GetString(walletFlag))
if err != nil {
return fmt.Errorf("decode Neo wallet from file: %v", err)
return fmt.Errorf("decode Neo wallet from file: %w", err)
}

var accAddr util.Uint160
Expand All @@ -141,12 +141,12 @@ func verifiedNodesDomainSetAccessList(cmd *cobra.Command, _ []string) error {
prompt := fmt.Sprintf("Enter password for %s >", address.Uint160ToString(accAddr))
pass, err := input.ReadPassword(prompt)
if err != nil {
return fmt.Errorf("failed to read account password: %v", err)
return fmt.Errorf("failed to read account password: %w", err)
}

err = acc.Decrypt(pass, keys.NEP2ScryptParams())
if err != nil {
return fmt.Errorf("failed to unlock the account with password: %v", err)
return fmt.Errorf("failed to unlock the account with password: %w", err)
}

n3Client, err := getN3Client(vpr)
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-cli/modules/util/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func ParseEACLRules(table *eacl.Table, rules []string) error {
for _, ruleStr := range rules {
err := ParseEACLRule(table, ruleStr)
if err != nil {
return fmt.Errorf("can't create extended acl record from rule '%s': %v", ruleStr, err)
return fmt.Errorf("can't create extended acl record from rule '%s': %w", ruleStr, err)
}
}
return nil
Expand All @@ -199,7 +199,7 @@ func ParseEACLRules(table *eacl.Table, rules []string) error {
func ParseEACLRule(table *eacl.Table, rule string) error {
r, err := shlex.Split(rule)
if err != nil {
return fmt.Errorf("can't parse rule '%s': %v", rule, err)
return fmt.Errorf("can't parse rule '%s': %w", rule, err)
}
return parseEACLTable(table, r)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/object/replicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func EncodeReplicationMetaInfo(cID cid.ID, oID oid.ID, pSize uint64,
// all the errors in the stackitem relate only cases when it is
// impossible to use serialized values (too many values, unsupported
// types, etc.), unexpected errors at all
panic(fmt.Errorf("unexpected stackitem map serialization failure: %v", err))
panic(fmt.Errorf("unexpected stackitem map serialization failure: %w", err))
}

return result
Expand Down
4 changes: 2 additions & 2 deletions pkg/innerring/internal/blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func New(cfg Config) (res *Blockchain, err error) {
if err != nil {
closeErr := bcStorage.Close()
if closeErr != nil {
err = fmt.Errorf("%w; also failed to close blockchain storage: %v", err, closeErr)
err = fmt.Errorf("%w; also failed to close blockchain storage: %w", err, closeErr)
}
}
}()
Expand Down Expand Up @@ -518,7 +518,7 @@ func (x *Blockchain) Run(ctx context.Context) (err error) {
if err != nil {
closeErr := x.storage.Close()
if closeErr != nil {
err = fmt.Errorf("%w; also failed to close blockchain storage: %v", err, closeErr)
err = fmt.Errorf("%w; also failed to close blockchain storage: %w", err, closeErr)
}
}
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Member

Choose a reason for hiding this comment

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

Bug.

return err
}
}
Expand All @@ -75,11 +75,11 @@ func (w *genericWriter) writeAndRename(tmpPath, p string, data []byte) error {
if err != nil {
var pe *fs.PathError
if errors.As(err, &pe) {
switch pe.Err {
case syscall.ENOSPC:
switch {
case errors.Is(pe.Err, syscall.ENOSPC):
err = common.ErrNoSpace
_ = os.RemoveAll(tmpPath)
case syscall.EEXIST:
case errors.Is(pe.Err, syscall.EEXIST):
return syscall.EEXIST
}
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/local_object_storage/engine/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (e *StorageEngine) TreeMove(d pilorama.CIDDescriptor, treeID string, m *pil

lm, err := lst[index].TreeMove(d, treeID, m)
if err != nil {
if !errors.Is(err, shard.ErrReadOnlyMode) && err != shard.ErrPiloramaDisabled {
if !errors.Is(err, shard.ErrReadOnlyMode) && !errors.Is(err, shard.ErrPiloramaDisabled) {
e.reportShardError(lst[index], "can't perform `TreeMove`", err,
zap.Stringer("cid", d.CID),
zap.String("tree", treeID))
Expand All @@ -40,7 +40,7 @@ func (e *StorageEngine) TreeAddByPath(d pilorama.CIDDescriptor, treeID string, a

lm, err := lst[index].TreeAddByPath(d, treeID, attr, path, m)
if err != nil {
if !errors.Is(err, shard.ErrReadOnlyMode) && err != shard.ErrPiloramaDisabled {
if !errors.Is(err, shard.ErrReadOnlyMode) && !errors.Is(err, shard.ErrPiloramaDisabled) {
e.reportShardError(lst[index], "can't perform `TreeAddByPath`", err,
zap.Stringer("cid", d.CID),
zap.String("tree", treeID))
Expand All @@ -59,7 +59,7 @@ func (e *StorageEngine) TreeApply(d pilorama.CIDDescriptor, treeID string, m *pi

err = lst[index].TreeApply(d, treeID, m, backgroundSync)
if err != nil {
if !errors.Is(err, shard.ErrReadOnlyMode) && err != shard.ErrPiloramaDisabled {
if !errors.Is(err, shard.ErrReadOnlyMode) && !errors.Is(err, shard.ErrPiloramaDisabled) {
e.reportShardError(lst[index], "can't perform `TreeApply`", err,
zap.Stringer("cid", d.CID),
zap.String("tree", treeID))
Expand All @@ -76,7 +76,7 @@ func (e *StorageEngine) TreeGetByPath(cid cidSDK.ID, treeID string, attr string,
for _, sh := range e.sortShardsByWeight(cid) {
nodes, err = sh.TreeGetByPath(cid, treeID, attr, path, latest)
if err != nil {
if err == shard.ErrPiloramaDisabled {
if errors.Is(err, shard.ErrPiloramaDisabled) {
break
}
if !errors.Is(err, pilorama.ErrTreeNotFound) {
Expand All @@ -99,7 +99,7 @@ func (e *StorageEngine) TreeGetMeta(cid cidSDK.ID, treeID string, nodeID piloram
for _, sh := range e.sortShardsByWeight(cid) {
m, p, err = sh.TreeGetMeta(cid, treeID, nodeID)
if err != nil {
if err == shard.ErrPiloramaDisabled {
if errors.Is(err, shard.ErrPiloramaDisabled) {
break
}
if !errors.Is(err, pilorama.ErrTreeNotFound) {
Expand All @@ -121,7 +121,7 @@ func (e *StorageEngine) TreeGetChildren(cid cidSDK.ID, treeID string, nodeID pil
for _, sh := range e.sortShardsByWeight(cid) {
nodes, err = sh.TreeGetChildren(cid, treeID, nodeID)
if err != nil {
if err == shard.ErrPiloramaDisabled {
if errors.Is(err, shard.ErrPiloramaDisabled) {
break
}
if !errors.Is(err, pilorama.ErrTreeNotFound) {
Expand All @@ -143,7 +143,7 @@ func (e *StorageEngine) TreeGetOpLog(cid cidSDK.ID, treeID string, height uint64
for _, sh := range e.sortShardsByWeight(cid) {
lm, err = sh.TreeGetOpLog(cid, treeID, height)
if err != nil {
if err == shard.ErrPiloramaDisabled {
if errors.Is(err, shard.ErrPiloramaDisabled) {
break
}
if !errors.Is(err, pilorama.ErrTreeNotFound) {
Expand All @@ -164,7 +164,7 @@ func (e *StorageEngine) TreeDrop(cid cidSDK.ID, treeID string) error {
for _, sh := range e.sortShardsByWeight(cid) {
err = sh.TreeDrop(cid, treeID)
if err != nil {
if err == shard.ErrPiloramaDisabled {
if errors.Is(err, shard.ErrPiloramaDisabled) {
break
}
if !errors.Is(err, pilorama.ErrTreeNotFound) && !errors.Is(err, shard.ErrReadOnlyMode) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/metabase/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (db *DB) openBolt() error {
return nil
})

if err == errBreakBucketForEach {
if errors.Is(err, errBreakBucketForEach) {
db.initialized = true
err = nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/metabase/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) {
for range b.N {
res, err := db.ListWithCursor(prm)
if err != nil {
if err != meta.ErrEndOfListing {
if !errors.Is(err, meta.ErrEndOfListing) {
b.Fatalf("error: %v", err)
}
prm.SetCursor(nil)
Expand Down
2 changes: 1 addition & 1 deletion pkg/morph/client/netmap/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (c *Client) ReadNetworkConfiguration() (NetworkConfiguration, error) {
case EigenTrustAlphaConfig:
res.EigenTrustAlpha, err = strconv.ParseFloat(string(value), 64)
if err != nil {
return fmt.Errorf("invalid prm %s: %v", EigenTrustAlphaConfig, err)
return fmt.Errorf("invalid prm %s: %w", EigenTrustAlphaConfig, err)
}
case InnerRingCandidateFeeConfig:
res.IRCandidateFee = bytesToUint64(value)
Expand Down