From 81e860481d54100a31cb71e34fc2f8b1f57d69a4 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 31 May 2023 19:39:35 +0300 Subject: [PATCH] [#122] Fix linter warnings Signed-off-by: Alex Vanin --- api/auth/signer/v4/v4.go | 2 ++ api/layer/frostfs_mock.go | 2 +- api/layer/tree_mock.go | 22 +++++++++++----------- api/layer/util.go | 2 +- api/notifications/controller.go | 2 +- cmd/s3-gw/app_settings.go | 12 ++---------- pkg/service/tree/tree_client_in_memory.go | 12 ++++++------ 7 files changed, 24 insertions(+), 30 deletions(-) diff --git a/api/auth/signer/v4/v4.go b/api/auth/signer/v4/v4.go index 4680cc8..94afc34 100644 --- a/api/auth/signer/v4/v4.go +++ b/api/auth/signer/v4/v4.go @@ -790,6 +790,8 @@ const doubleSpace = " " // stripExcessSpaces will rewrite the passed in slice's string values to not // contain multiple side-by-side spaces. +// +//nolint:revive func stripExcessSpaces(vals []string) { var j, k, l, m, spaces int for i, str := range vals { diff --git a/api/layer/frostfs_mock.go b/api/layer/frostfs_mock.go index 1b1c57c..36277ef 100644 --- a/api/layer/frostfs_mock.go +++ b/api/layer/frostfs_mock.go @@ -189,7 +189,7 @@ func (t *TestFrostFS) ReadObject(ctx context.Context, prm PrmObjectRead) (*Objec return nil, fmt.Errorf("%w: %s", apistatus.ObjectNotFound{}, addr) } -func (t *TestFrostFS) CreateObject(ctx context.Context, prm PrmObjectCreate) (oid.ID, error) { +func (t *TestFrostFS) CreateObject(_ context.Context, prm PrmObjectCreate) (oid.ID, error) { b := make([]byte, 32) if _, err := io.ReadFull(rand.Reader, b); err != nil { return oid.ID{}, err diff --git a/api/layer/tree_mock.go b/api/layer/tree_mock.go index aa42833..ffdedc2 100644 --- a/api/layer/tree_mock.go +++ b/api/layer/tree_mock.go @@ -59,17 +59,17 @@ func (t *TreeServiceMock) DeleteObjectTagging(_ context.Context, bktInfo *data.B return nil } -func (t *TreeServiceMock) GetBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) (map[string]string, error) { +func (t *TreeServiceMock) GetBucketTagging(context.Context, *data.BucketInfo) (map[string]string, error) { // TODO implement me panic("implement me") } -func (t *TreeServiceMock) PutBucketTagging(ctx context.Context, bktInfo *data.BucketInfo, tagSet map[string]string) error { +func (t *TreeServiceMock) PutBucketTagging(context.Context, *data.BucketInfo, map[string]string) error { // TODO implement me panic("implement me") } -func (t *TreeServiceMock) DeleteBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) error { +func (t *TreeServiceMock) DeleteBucketTagging(context.Context, *data.BucketInfo) error { // TODO implement me panic("implement me") } @@ -100,15 +100,15 @@ func (t *TreeServiceMock) GetSettingsNode(_ context.Context, bktInfo *data.Bucke return settings, nil } -func (t *TreeServiceMock) GetNotificationConfigurationNode(ctx context.Context, bktInfo *data.BucketInfo) (oid.ID, error) { +func (t *TreeServiceMock) GetNotificationConfigurationNode(context.Context, *data.BucketInfo) (oid.ID, error) { panic("implement me") } -func (t *TreeServiceMock) PutNotificationConfigurationNode(ctx context.Context, bktInfo *data.BucketInfo, objID oid.ID) (oid.ID, error) { +func (t *TreeServiceMock) PutNotificationConfigurationNode(context.Context, *data.BucketInfo, oid.ID) (oid.ID, error) { panic("implement me") } -func (t *TreeServiceMock) GetBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) (oid.ID, error) { +func (t *TreeServiceMock) GetBucketCORS(_ context.Context, bktInfo *data.BucketInfo) (oid.ID, error) { systemMap, ok := t.system[bktInfo.CID.EncodeToString()] if !ok { return oid.ID{}, nil @@ -122,7 +122,7 @@ func (t *TreeServiceMock) GetBucketCORS(ctx context.Context, bktInfo *data.Bucke return node.OID, nil } -func (t *TreeServiceMock) PutBucketCORS(ctx context.Context, bktInfo *data.BucketInfo, objID oid.ID) (oid.ID, error) { +func (t *TreeServiceMock) PutBucketCORS(_ context.Context, bktInfo *data.BucketInfo, objID oid.ID) (oid.ID, error) { systemMap, ok := t.system[bktInfo.CID.EncodeToString()] if !ok { systemMap = make(map[string]*data.BaseNodeVersion) @@ -137,7 +137,7 @@ func (t *TreeServiceMock) PutBucketCORS(ctx context.Context, bktInfo *data.Bucke return oid.ID{}, ErrNoNodeToRemove } -func (t *TreeServiceMock) DeleteBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) (oid.ID, error) { +func (t *TreeServiceMock) DeleteBucketCORS(context.Context, *data.BucketInfo) (oid.ID, error) { panic("implement me") } @@ -314,7 +314,7 @@ func (t *TreeServiceMock) CreateMultipartUpload(_ context.Context, bktInfo *data return nil } -func (t *TreeServiceMock) GetMultipartUploadsByPrefix(ctx context.Context, bktInfo *data.BucketInfo, prefix string) ([]*data.MultipartInfo, error) { +func (t *TreeServiceMock) GetMultipartUploadsByPrefix(context.Context, *data.BucketInfo, string) ([]*data.MultipartInfo, error) { panic("implement me") } @@ -407,7 +407,7 @@ LOOP: return nil } -func (t *TreeServiceMock) PutLock(ctx context.Context, bktInfo *data.BucketInfo, nodeID uint64, lock *data.LockInfo) error { +func (t *TreeServiceMock) PutLock(_ context.Context, bktInfo *data.BucketInfo, nodeID uint64, lock *data.LockInfo) error { cnrLockMap, ok := t.locks[bktInfo.CID.EncodeToString()] if !ok { t.locks[bktInfo.CID.EncodeToString()] = map[uint64]*data.LockInfo{ @@ -421,7 +421,7 @@ func (t *TreeServiceMock) PutLock(ctx context.Context, bktInfo *data.BucketInfo, return nil } -func (t *TreeServiceMock) GetLock(ctx context.Context, bktInfo *data.BucketInfo, nodeID uint64) (*data.LockInfo, error) { +func (t *TreeServiceMock) GetLock(_ context.Context, bktInfo *data.BucketInfo, nodeID uint64) (*data.LockInfo, error) { cnrLockMap, ok := t.locks[bktInfo.CID.EncodeToString()] if !ok { return nil, nil diff --git a/api/layer/util.go b/api/layer/util.go index 4b37c3a..a0370e0 100644 --- a/api/layer/util.go +++ b/api/layer/util.go @@ -74,7 +74,7 @@ func objectInfoFromMeta(bkt *data.BucketInfo, meta *object.Object) *data.ObjectI mimeType = contentType delete(headers, object.AttributeContentType) } - if val, ok := headers[object.AttributeTimestamp]; !ok { + if val, ok := headers[object.AttributeTimestamp]; !ok { //nolint:revive // ignore empty value } else if dt, err := strconv.ParseInt(val, 10, 64); err == nil { creation = time.Unix(dt, 0) diff --git a/api/notifications/controller.go b/api/notifications/controller.go index 68b913c..dca6acf 100644 --- a/api/notifications/controller.go +++ b/api/notifications/controller.go @@ -131,7 +131,7 @@ func NewController(p *Options, l *zap.Logger) (*Controller, error) { }, nil } -func (c *Controller) Subscribe(ctx context.Context, topic string, handler layer.MsgHandler) error { +func (c *Controller) Subscribe(_ context.Context, topic string, handler layer.MsgHandler) error { ch := make(chan *nats.Msg, 1) c.mu.RLock() diff --git a/cmd/s3-gw/app_settings.go b/cmd/s3-gw/app_settings.go index 25a33d2..ab0b544 100644 --- a/cmd/s3-gw/app_settings.go +++ b/cmd/s3-gw/app_settings.go @@ -421,11 +421,7 @@ func bindFlags(v *viper.Viper, flags *pflag.FlagSet) error { if err := v.BindPFlag(cfgServer+".0."+cfgTLSKeyFile, flags.Lookup(cfgTLSKeyFile)); err != nil { return err } - if err := v.BindPFlag(cfgServer+".0."+cfgTLSCertFile, flags.Lookup(cfgTLSCertFile)); err != nil { - return err - } - - return nil + return v.BindPFlag(cfgServer+".0."+cfgTLSCertFile, flags.Lookup(cfgTLSCertFile)) } func readInConfig(v *viper.Viper) error { @@ -489,11 +485,7 @@ func mergeConfig(v *viper.Viper, fileName string) error { } }() - if err = v.MergeConfig(cfgFile); err != nil { - return err - } - - return nil + return v.MergeConfig(cfgFile) } // newLogger constructs a Logger instance for the current application. diff --git a/pkg/service/tree/tree_client_in_memory.go b/pkg/service/tree/tree_client_in_memory.go index 740c482..3c3128b 100644 --- a/pkg/service/tree/tree_client_in_memory.go +++ b/pkg/service/tree/tree_client_in_memory.go @@ -183,7 +183,7 @@ func NewTreeServiceClientMemory() (*ServiceClientMemory, error) { }, nil } -func (c *ServiceClientMemory) GetNodes(ctx context.Context, p *GetNodesParams) ([]NodeResponse, error) { +func (c *ServiceClientMemory) GetNodes(_ context.Context, p *GetNodesParams) ([]NodeResponse, error) { cnr, ok := c.containers[p.BktInfo.CID.EncodeToString()] if !ok { return nil, nil @@ -211,7 +211,7 @@ func (c *ServiceClientMemory) GetNodes(ctx context.Context, p *GetNodesParams) ( return res2, nil } -func (c *ServiceClientMemory) GetSubTree(ctx context.Context, bktInfo *data.BucketInfo, treeID string, rootID uint64, depth uint32) ([]NodeResponse, error) { +func (c *ServiceClientMemory) GetSubTree(_ context.Context, bktInfo *data.BucketInfo, treeID string, rootID uint64, depth uint32) ([]NodeResponse, error) { cnr, ok := c.containers[bktInfo.CID.EncodeToString()] if !ok { return nil, nil @@ -257,7 +257,7 @@ func newMemoryTree() memoryTree { } } -func (c *ServiceClientMemory) AddNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, parent uint64, meta map[string]string) (uint64, error) { +func (c *ServiceClientMemory) AddNode(_ context.Context, bktInfo *data.BucketInfo, treeID string, parent uint64, meta map[string]string) (uint64, error) { cnr, ok := c.containers[bktInfo.CID.EncodeToString()] if !ok { cnr = newContainerInfo(bktInfo, treeID) @@ -294,7 +294,7 @@ func (c *ServiceClientMemory) AddNode(ctx context.Context, bktInfo *data.BucketI return newID, nil } -func (c *ServiceClientMemory) AddNodeByPath(ctx context.Context, bktInfo *data.BucketInfo, treeID string, path []string, meta map[string]string) (uint64, error) { +func (c *ServiceClientMemory) AddNodeByPath(_ context.Context, bktInfo *data.BucketInfo, treeID string, path []string, meta map[string]string) (uint64, error) { cnr, ok := c.containers[bktInfo.CID.EncodeToString()] if !ok { cnr = newContainerInfo(bktInfo, treeID) @@ -331,7 +331,7 @@ func (c *ServiceClientMemory) AddNodeByPath(ctx context.Context, bktInfo *data.B return newID, nil } -func (c *ServiceClientMemory) MoveNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, nodeID, parentID uint64, meta map[string]string) error { +func (c *ServiceClientMemory) MoveNode(_ context.Context, bktInfo *data.BucketInfo, treeID string, nodeID, parentID uint64, meta map[string]string) error { cnr, ok := c.containers[bktInfo.CID.EncodeToString()] if !ok { return ErrNodeNotFound @@ -361,7 +361,7 @@ func (c *ServiceClientMemory) MoveNode(ctx context.Context, bktInfo *data.Bucket return nil } -func (c *ServiceClientMemory) RemoveNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, nodeID uint64) error { +func (c *ServiceClientMemory) RemoveNode(_ context.Context, bktInfo *data.BucketInfo, treeID string, nodeID uint64) error { cnr, ok := c.containers[bktInfo.CID.EncodeToString()] if !ok { return ErrNodeNotFound