From e88c1f750d54b76d562ff4063eb58ec77e93fd85 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Mon, 11 Jan 2021 18:21:06 +0300 Subject: [PATCH] [#302] Fix golint else/return linter errors Signed-off-by: Alex Vanin --- cmd/neofs-node/attributes.go | 4 ++-- pkg/local_object_storage/blobstor/put.go | 24 +++++++++---------- pkg/morph/client/audit/wrapper/result.go | 14 ++++++----- .../client/container/wrapper/container.go | 14 ++++++----- pkg/morph/client/container/wrapper/eacl.go | 7 +++--- pkg/services/object/acl/acl.go | 12 +++++----- pkg/services/object/get/util.go | 10 ++++---- pkg/services/object/put/streamer.go | 18 +++++++------- pkg/services/object/util/chain.go | 6 ++--- 9 files changed, 57 insertions(+), 52 deletions(-) diff --git a/cmd/neofs-node/attributes.go b/cmd/neofs-node/attributes.go index 47db20606..a07b1be3f 100644 --- a/cmd/neofs-node/attributes.go +++ b/cmd/neofs-node/attributes.go @@ -32,9 +32,9 @@ func readAttributes(v *viper.Viper) (attrs []string) { attr := v.GetString(cfgNodeAttributePrefix + "_" + strconv.Itoa(i)) if attr == "" { return - } else { - attrs = append(attrs, attr) } + + attrs = append(attrs, attr) } return attrs diff --git a/pkg/local_object_storage/blobstor/put.go b/pkg/local_object_storage/blobstor/put.go index 53e801872..4d83e8972 100644 --- a/pkg/local_object_storage/blobstor/put.go +++ b/pkg/local_object_storage/blobstor/put.go @@ -42,19 +42,19 @@ func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) { if big { // save object in shallow dir return new(PutRes), b.fsTree.put(prm.obj.Address(), data) - } else { - // save object in blobovnicza - res, err := b.blobovniczas.put(prm.obj.Address(), data) - if err != nil { - return nil, err - } - - return &PutRes{ - roBlobovniczaID: roBlobovniczaID{ - blobovniczaID: res, - }, - }, nil } + + // save object in blobovnicza + res, err := b.blobovniczas.put(prm.obj.Address(), data) + if err != nil { + return nil, err + } + + return &PutRes{ + roBlobovniczaID: roBlobovniczaID{ + blobovniczaID: res, + }, + }, nil } func (t *fsTree) put(addr *objectSDK.Address, data []byte) error { diff --git a/pkg/morph/client/audit/wrapper/result.go b/pkg/morph/client/audit/wrapper/result.go index 820c65f21..cb8c71660 100644 --- a/pkg/morph/client/audit/wrapper/result.go +++ b/pkg/morph/client/audit/wrapper/result.go @@ -62,12 +62,13 @@ func (w *ClientWrapper) ListAuditResultIDByCID(epoch uint64, cid *container.ID) args := audit.ListResultsByCIDArgs{} args.SetEpoch(int64(epoch)) - if v2 := cid.ToV2(); v2 == nil { + v2 := cid.ToV2() + if v2 == nil { return nil, errUnsupported // use other major version if there any - } else { - args.SetCID(v2.GetValue()) } + args.SetCID(v2.GetValue()) + values, err := (*audit.Client)(w).ListAuditResultsByCID(args) if err != nil { return nil, err @@ -83,12 +84,13 @@ func (w *ClientWrapper) ListAuditResultIDByNode(epoch uint64, cid *container.ID, args.SetEpoch(int64(epoch)) args.SetNodeKey(key) - if v2 := cid.ToV2(); v2 == nil { + v2 := cid.ToV2() + if v2 == nil { return nil, errUnsupported // use other major version if there any - } else { - args.SetCID(v2.GetValue()) } + args.SetCID(v2.GetValue()) + values, err := (*audit.Client)(w).ListAuditResultsByNode(args) if err != nil { return nil, err diff --git a/pkg/morph/client/container/wrapper/container.go b/pkg/morph/client/container/wrapper/container.go index 46f2ee013..d05f7cc5e 100644 --- a/pkg/morph/client/container/wrapper/container.go +++ b/pkg/morph/client/container/wrapper/container.go @@ -55,12 +55,13 @@ func (w *Wrapper) Get(cid *container.ID) (*container.Container, error) { args := client.GetArgs{} - if v2 := cid.ToV2(); v2 == nil { + v2 := cid.ToV2() + if v2 == nil { return nil, errUnsupported // use other major version if there any - } else { - args.SetCID(v2.GetValue()) } + args.SetCID(v2.GetValue()) + // ask RPC neo node to get serialized container rpcAnswer, err := w.client.Get(args) if err != nil { @@ -97,12 +98,13 @@ func (w *Wrapper) Delete(cid *container.ID, signature []byte) error { args := client.DeleteArgs{} args.SetSignature(signature) - if v2 := cid.ToV2(); v2 == nil { + v2 := cid.ToV2() + if v2 == nil { return errUnsupported // use other major version if there any - } else { - args.SetCID(v2.GetValue()) } + args.SetCID(v2.GetValue()) + return w.client.Delete(args) } diff --git a/pkg/morph/client/container/wrapper/eacl.go b/pkg/morph/client/container/wrapper/eacl.go index 40c5a31c5..2b966cbbd 100644 --- a/pkg/morph/client/container/wrapper/eacl.go +++ b/pkg/morph/client/container/wrapper/eacl.go @@ -17,12 +17,13 @@ func (w *Wrapper) GetEACL(cid *containerSDK.ID) (*eacl.Table, []byte, error) { args := client.EACLArgs{} - if v2 := cid.ToV2(); v2 == nil { + v2 := cid.ToV2() + if v2 == nil { return nil, nil, errUnsupported // use other major version if there any - } else { - args.SetCID(v2.GetValue()) } + args.SetCID(v2.GetValue()) + rpcAnswer, err := w.client.EACL(args) if err != nil { return nil, nil, err diff --git a/pkg/services/object/acl/acl.go b/pkg/services/object/acl/acl.go index 91452fcfb..85330753d 100644 --- a/pkg/services/object/acl/acl.go +++ b/pkg/services/object/acl/acl.go @@ -489,9 +489,9 @@ func getContainerIDFromRequest(req interface{}) (id *container.ID, err error) { objPart := v.GetBody().GetObjectPart() if part, ok := objPart.(*object.PutObjectPartInit); ok { return container.NewIDFromV2(part.GetHeader().GetContainerID()), nil - } else { - return nil, errors.New("can't get cid in chunk") } + + return nil, errors.New("can't get cid in chunk") case *object.HeadRequest: return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil case *object.SearchRequest: @@ -543,16 +543,16 @@ func getObjectOwnerFromMessage(req interface{}) (id *owner.ID, err error) { objPart := v.GetBody().GetObjectPart() if part, ok := objPart.(*object.PutObjectPartInit); ok { return owner.NewIDFromV2(part.GetHeader().GetOwnerID()), nil - } else { - return nil, errors.New("can't get cid in chunk") } + + return nil, errors.New("can't get cid in chunk") case *object.GetResponse: objPart := v.GetBody().GetObjectPart() if part, ok := objPart.(*object.GetObjectPartInit); ok { return owner.NewIDFromV2(part.GetHeader().GetOwnerID()), nil - } else { - return nil, errors.New("can't get cid in chunk") } + + return nil, errors.New("can't get cid in chunk") default: return nil, errors.New("unsupported request type") } diff --git a/pkg/services/object/get/util.go b/pkg/services/object/get/util.go index 4c6a63593..26ea4f4f6 100644 --- a/pkg/services/object/get/util.go +++ b/pkg/services/object/get/util.go @@ -102,12 +102,12 @@ func (c *clientWrapper) getObject(exec *execCtx) (*objectSDK.Object, error) { } return payloadOnlyObject(data), nil - } else { - return c.client.GetObject(exec.context(), - exec.remotePrm(), - exec.callOptions()..., - ) } + + return c.client.GetObject(exec.context(), + exec.remotePrm(), + exec.callOptions()..., + ) } func (e *storageEngineWrapper) get(exec *execCtx) (*object.Object, error) { diff --git a/pkg/services/object/put/streamer.go b/pkg/services/object/put/streamer.go index a9287eea1..abc58bcf5 100644 --- a/pkg/services/object/put/streamer.go +++ b/pkg/services/object/put/streamer.go @@ -136,15 +136,15 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget { return &localTarget{ storage: p.localStore, } - } else { - return &remoteTarget{ - ctx: p.ctx, - keyStorage: p.keyStorage, - commonPrm: prm.common, - addr: addr, - clientCache: p.clientCache, - clientOpts: p.clientOpts, - } + } + + return &remoteTarget{ + ctx: p.ctx, + keyStorage: p.keyStorage, + commonPrm: prm.common, + addr: addr, + clientCache: p.clientCache, + clientOpts: p.clientOpts, } }, fmt: p.fmtValidator, diff --git a/pkg/services/object/util/chain.go b/pkg/services/object/util/chain.go index ffa3a0428..ff9280562 100644 --- a/pkg/services/object/util/chain.go +++ b/pkg/services/object/util/chain.go @@ -119,10 +119,10 @@ func traverseSplitChain(r HeadReceiver, addr *objectSDK.Address, h SplitMemberHa if stop, err := traverseSplitChain(r, addr, func(member *object.Object, reverseDirection bool) (stop bool) { if !reverseDirection { return h(member, false) - } else { - reverseChain = append(reverseChain, member) - return false } + + reverseChain = append(reverseChain, member) + return false }); err != nil || stop { return stop, err }