[#302] Fix golint else/return linter errors

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-01-11 18:21:06 +03:00 committed by Alex Vanin
parent 0f3570bdeb
commit e88c1f750d
9 changed files with 57 additions and 52 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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

View file

@ -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)
}

View file

@ -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

View file

@ -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")
}

View file

@ -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) {

View file

@ -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,

View file

@ -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
}