From a8de37c8a279a1a086ff02e49187f4d31475c76b Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 14 Aug 2023 14:06:17 +0300 Subject: [PATCH] [#607] *: Remove redundant if on error returns Semantic patch: ``` @@ @@ -if err != nil { return err } -return nil +return err ``` Signed-off-by: Evgenii Stratonikov --- pkg/innerring/initialization.go | 12 ++---------- .../blobstor/compression/compress.go | 6 +----- pkg/local_object_storage/pilorama/boltdb.go | 5 +---- pkg/morph/client/notifications.go | 6 +----- pkg/morph/event/notary_preparator.go | 6 +----- pkg/services/notificator/nats/service.go | 6 +----- pkg/services/session/storage/persistent/storage.go | 6 +----- 7 files changed, 8 insertions(+), 39 deletions(-) diff --git a/pkg/innerring/initialization.go b/pkg/innerring/initialization.go index 52ffb10a..84112d12 100644 --- a/pkg/innerring/initialization.go +++ b/pkg/innerring/initialization.go @@ -246,11 +246,7 @@ func (s *Server) initAlphabetProcessor(cfg *viper.Viper) error { } err = bindMorphProcessor(s.alphabetProcessor, s) - if err != nil { - return err - } - - return nil + return err } func (s *Server) initContainerProcessor(cfg *viper.Viper, cnrClient *container.Client, @@ -454,11 +450,7 @@ func (s *Server) initProcessors(cfg *viper.Viper, morphClients *serverMorphClien } err = s.initAlphabetProcessor(cfg) - if err != nil { - return err - } - - return nil + return err } func (s *Server) initMorph(ctx context.Context, cfg *viper.Viper, errChan chan<- error) (*chainParams, error) { diff --git a/pkg/local_object_storage/blobstor/compression/compress.go b/pkg/local_object_storage/blobstor/compression/compress.go index 4ebf057d..270c2b18 100644 --- a/pkg/local_object_storage/blobstor/compression/compress.go +++ b/pkg/local_object_storage/blobstor/compression/compress.go @@ -33,11 +33,7 @@ func (c *Config) Init() error { } c.decoder, err = zstd.NewReader(nil) - if err != nil { - return err - } - - return nil + return err } // NeedsCompression returns true if the object should be compressed. diff --git a/pkg/local_object_storage/pilorama/boltdb.go b/pkg/local_object_storage/pilorama/boltdb.go index a729e2a2..33d2b687 100644 --- a/pkg/local_object_storage/pilorama/boltdb.go +++ b/pkg/local_object_storage/pilorama/boltdb.go @@ -146,10 +146,7 @@ func (t *boltForest) Init() error { return err } _, err = tx.CreateBucketIfNotExists(logBucket) - if err != nil { - return err - } - return nil + return err }) } func (t *boltForest) Close() error { diff --git a/pkg/morph/client/notifications.go b/pkg/morph/client/notifications.go index dbca00d7..121dccfb 100644 --- a/pkg/morph/client/notifications.go +++ b/pkg/morph/client/notifications.go @@ -101,9 +101,5 @@ func (c *Client) UnsubscribeAll() error { } err := c.client.UnsubscribeAll() - if err != nil { - return err - } - - return nil + return err } diff --git a/pkg/morph/event/notary_preparator.go b/pkg/morph/event/notary_preparator.go index 298a6d57..37091f76 100644 --- a/pkg/morph/event/notary_preparator.go +++ b/pkg/morph/event/notary_preparator.go @@ -243,11 +243,7 @@ func (p Preparator) validateParameterOpcodes(ops []Op) error { } err = validateNestedArgs(argsLen, ops[:l-2]) - if err != nil { - return err - } - - return nil + return err } func validateNestedArgs(expArgLen int64, ops []Op) error { diff --git a/pkg/services/notificator/nats/service.go b/pkg/services/notificator/nats/service.go index 19f0cbde..7f525df9 100644 --- a/pkg/services/notificator/nats/service.go +++ b/pkg/services/notificator/nats/service.go @@ -74,11 +74,7 @@ func (n *Writer) Notify(topic string, address oid.Address) error { } _, err := n.js.Publish(topic, []byte(address.EncodeToString()), nats.MsgId(messageID)) - if err != nil { - return err - } - - return nil + return err } // New creates new Writer. diff --git a/pkg/services/session/storage/persistent/storage.go b/pkg/services/session/storage/persistent/storage.go index 25f067d6..e4c2091c 100644 --- a/pkg/services/session/storage/persistent/storage.go +++ b/pkg/services/session/storage/persistent/storage.go @@ -102,11 +102,7 @@ func (s *TokenStore) Get(ownerID user.ID, tokenID []byte) (t *storage.PrivateTok var err error t, err = s.unpackToken(rawToken) - if err != nil { - return err - } - - return nil + return err }) if err != nil { s.l.Error(logs.PersistentCouldNotGetSessionFromPersistentStorage,