From b461aa64b86770f6e378da92bae99ce8f7a878cb Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 3 Mar 2023 12:44:36 +0300 Subject: [PATCH] [#23] pre-commit: Add golangci-lint hook Also, fix minor issues. Skip deprecated warning for now. Signed-off-by: Evgenii Stratonikov --- .golangci.yml | 3 +++ .pre-commit-config.yaml | 5 +++++ object/object.go | 8 ++++---- storagegroup/storagegroup.go | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 67f93e7..eda5e5f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,6 +24,9 @@ linters-settings: govet: # report about shadowed variables check-shadowing: false + staticcheck: + checks: ["all", "-SA1019"] # TODO Enable SA1019 after deprecated warning are fixed. + linters: enable: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c6f604..46c9c89 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,3 +17,8 @@ repos: args: [--markdown-linebreak-ext=md] - id: end-of-file-fixer exclude: ".key$" + + - repo: https://github.com/golangci/golangci-lint + rev: v1.51.2 + hooks: + - id: golangci-lint diff --git a/object/object.go b/object/object.go index b564f5a..b21cd69 100644 --- a/object/object.go +++ b/object/object.go @@ -117,7 +117,7 @@ func (o *Object) Signature() *frostfscrypto.Signature { } var sig frostfscrypto.Signature - sig.ReadFromV2(*sigv2) // FIXME(@cthulhu-rider): #226 handle error + _ = sig.ReadFromV2(*sigv2) // FIXME(@cthulhu-rider): #226 handle error return &sig } @@ -149,7 +149,7 @@ func (o *Object) SetPayload(v []byte) { func (o *Object) Version() *version.Version { var ver version.Version if verV2 := (*object.Object)(o).GetHeader().GetVersion(); verV2 != nil { - ver.ReadFromV2(*verV2) // FIXME(@cthulhu-rider): #226 handle error + _ = ver.ReadFromV2(*verV2) // FIXME(@cthulhu-rider): #226 handle error } return &ver } @@ -248,7 +248,7 @@ func (o *Object) PayloadChecksum() (checksum.Checksum, bool) { v2 := (*object.Object)(o) if hash := v2.GetHeader().GetPayloadHash(); hash != nil { - v.ReadFromV2(*hash) // FIXME(@cthulhu-rider): #226 handle error + _ = v.ReadFromV2(*hash) // FIXME(@cthulhu-rider): #226 handle error return v, true } @@ -278,7 +278,7 @@ func (o *Object) PayloadHomomorphicHash() (checksum.Checksum, bool) { v2 := (*object.Object)(o) if hash := v2.GetHeader().GetHomomorphicHash(); hash != nil { - v.ReadFromV2(*hash) // FIXME(@cthulhu-rider): #226 handle error + _ = v.ReadFromV2(*hash) // FIXME(@cthulhu-rider): #226 handle error return v, true } diff --git a/storagegroup/storagegroup.go b/storagegroup/storagegroup.go index 8722f51..5b358c3 100644 --- a/storagegroup/storagegroup.go +++ b/storagegroup/storagegroup.go @@ -114,7 +114,7 @@ func (sg *StorageGroup) SetValidationDataSize(epoch uint64) { func (sg StorageGroup) ValidationDataHash() (v checksum.Checksum, isSet bool) { v2 := (storagegroup.StorageGroup)(sg) if checksumV2 := v2.GetValidationHash(); checksumV2 != nil { - v.ReadFromV2(*checksumV2) // FIXME(@cthulhu-rider): #226 handle error + _ = v.ReadFromV2(*checksumV2) // FIXME(@cthulhu-rider): #226 handle error isSet = true }