From 4972a69c86e181bb639a2687837a89a97ba7432c Mon Sep 17 00:00:00 2001 From: David Christofas Date: Thu, 24 Feb 2022 11:58:33 +0100 Subject: [PATCH] replace deprecated linter modules --- .golangci.yaml | 5 ++--- changelog/unreleased/update-linter-config.md | 5 +++++ .../ocmshareprovider/ocmshareprovider.go | 2 +- internal/http/services/ocmd/shares.go | 2 +- pkg/ocm/invite/manager/json/json.go | 2 +- pkg/ocm/share/sender/sender.go | 2 +- .../utils/decomposedfs/xattrs/xattrs.go | 20 ++++++++++++------- pkg/sysinfo/sysinfo.go | 2 +- 8 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 changelog/unreleased/update-linter-config.md diff --git a/.golangci.yaml b/.golangci.yaml index 6c9559020e..46904acca7 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -14,7 +14,6 @@ issues: - scopelint linters: enable: - - maligned - bodyclose - deadcode - errcheck @@ -27,10 +26,10 @@ linters: - unused - varcheck - depguard - - golint + - revive - goimports - unconvert - - scopelint + - exportloopref - misspell - gocritic - prealloc diff --git a/changelog/unreleased/update-linter-config.md b/changelog/unreleased/update-linter-config.md new file mode 100644 index 0000000000..58fad503ba --- /dev/null +++ b/changelog/unreleased/update-linter-config.md @@ -0,0 +1,5 @@ +Change: Remove deprecated linter modules + +Replaced the deprecated linter modules with the recommended ones. + +https://github.com/cs3org/reva/pull/2589 diff --git a/internal/grpc/services/ocmshareprovider/ocmshareprovider.go b/internal/grpc/services/ocmshareprovider/ocmshareprovider.go index 5fb48f6b55..d850933d41 100644 --- a/internal/grpc/services/ocmshareprovider/ocmshareprovider.go +++ b/internal/grpc/services/ocmshareprovider/ocmshareprovider.go @@ -172,7 +172,7 @@ func (s *service) CreateOCMShare(ctx context.Context, req *ocm.CreateOCMShareReq // token = protocol FIXME! } - var sharedSecret string = "" + var sharedSecret string share, err := s.sm.Share(ctx, req.ResourceId, req.Grant, name, req.RecipientMeshProvider, permissions, nil, sharedSecret, sharetype) if err != nil { diff --git a/internal/http/services/ocmd/shares.go b/internal/http/services/ocmd/shares.go index b501fec36f..c9d625b68d 100644 --- a/internal/http/services/ocmd/shares.go +++ b/internal/http/services/ocmd/shares.go @@ -141,7 +141,7 @@ func (h *sharesHandler) createShare(w http.ResponseWriter, r *http.Request) { return } - var shareWithParts []string = strings.Split(shareWith, "@") + shareWithParts := strings.Split(shareWith, "@") userRes, err := gatewayClient.GetUser(ctx, &userpb.GetUserRequest{ UserId: &userpb.UserId{OpaqueId: shareWithParts[0]}, }) diff --git a/pkg/ocm/invite/manager/json/json.go b/pkg/ocm/invite/manager/json/json.go index 6a9b6d483f..1223670c96 100644 --- a/pkg/ocm/invite/manager/json/json.go +++ b/pkg/ocm/invite/manager/json/json.go @@ -246,7 +246,7 @@ func (m *manager) ForwardInvite(ctx context.Context, invite *invitepb.InviteToke if e != nil { return errors.Wrap(e, "json: error reading request body") } - return errors.Wrap(errors.New(fmt.Sprintf("%s: %s", resp.Status, string(respBody))), "json: error sending accept post request") + return errors.Wrap(fmt.Errorf("%s: %s", resp.Status, string(respBody)), "json: error sending accept post request") } return nil diff --git a/pkg/ocm/share/sender/sender.go b/pkg/ocm/share/sender/sender.go index 19d9f97042..5cee734bad 100644 --- a/pkg/ocm/share/sender/sender.go +++ b/pkg/ocm/share/sender/sender.go @@ -86,7 +86,7 @@ func Send(requestBodyMap map[string]interface{}, pi *ocmprovider.ProviderInfo) e e = errors.Wrap(e, "sender: error reading request body") return e } - err = errors.Wrap(errors.New(fmt.Sprintf("%s: %s", resp.Status, string(respBody))), "sender: error sending create ocm core share post request") + err = errors.Wrap(fmt.Errorf("%s: %s", resp.Status, string(respBody)), "sender: error sending create ocm core share post request") return err } return nil diff --git a/pkg/storage/utils/decomposedfs/xattrs/xattrs.go b/pkg/storage/utils/decomposedfs/xattrs/xattrs.go index 4168d80ff0..49f8e86fa0 100644 --- a/pkg/storage/utils/decomposedfs/xattrs/xattrs.go +++ b/pkg/storage/utils/decomposedfs/xattrs/xattrs.go @@ -158,8 +158,10 @@ func CopyMetadata(src, target string, filter func(attributeName string) bool) (e // error handling: We count errors of reads or writes of xattrs. // if there were any read or write errors an error is returned. - var xerrs int = 0 - var xerr error + var ( + xerrs = 0 + xerr error + ) for idx := range attrNameList { attrName := attrNameList[idx] if filter == nil || filter(attrName) { @@ -173,7 +175,7 @@ func CopyMetadata(src, target string, filter func(attributeName string) bool) (e } } if xerrs > 0 { - err = errors.Wrap(xerr, "Failed to copy all xattrs, last error returned.") + err = errors.Wrap(xerr, "failed to copy all xattrs, last error returned") } return err @@ -215,8 +217,10 @@ func SetMultiple(filePath string, attribs map[string]string) (err error) { // error handling: Count if there are errors while setting the attribs. // if there were any, return an error. - var xerrs int = 0 - var xerr error + var ( + xerrs = 0 + xerr error + ) for key, val := range attribs { if xerr = xattr.Set(filePath, key, []byte(val)); xerr != nil { // log @@ -278,8 +282,10 @@ func All(filePath string) (attribs map[string]string, err error) { return nil, err } - var xerrs int = 0 - var xerr error + var ( + xerrs = 0 + xerr error + ) // error handling: Count if there are errors while reading all attribs. // if there were any, return an error. attribs = make(map[string]string, len(attrNames)) diff --git a/pkg/sysinfo/sysinfo.go b/pkg/sysinfo/sysinfo.go index fc19764e20..c74156a4aa 100644 --- a/pkg/sysinfo/sysinfo.go +++ b/pkg/sysinfo/sysinfo.go @@ -34,7 +34,7 @@ type SystemInformation struct { var ( // SysInfo provides global system information. - SysInfo *SystemInformation = &SystemInformation{} + SysInfo = &SystemInformation{} ) // ToJSON converts the system information to JSON.