From 6f4bff502836f9f8bc90d2b90d78d973add0c708 Mon Sep 17 00:00:00 2001 From: Kairo Araujo Date: Thu, 22 Aug 2024 14:58:15 +0200 Subject: [PATCH] fix: golangci-lint failing due nil check (#333) Added the fix and introduced `make lint` for local tests dsse/verify.go:98:6: S1009: should omit nil check; len() for []byte is defined as zero (gosimple) if sig.Certificate != nil && len(sig.Certificate) > 0 { ^ Signed-off-by: Kairo Araujo --- Makefile | 5 +++++ dsse/verify.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1b61e8ac..f779a336 100644 --- a/Makefile +++ b/Makefile @@ -29,3 +29,8 @@ schema: ## Generate the attestor schema json files help: ## Display this help screen @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +lint: ## Run the linter + @golangci-lint run + @go fmt ./... + @go vet ./... diff --git a/dsse/verify.go b/dsse/verify.go index 796039bd..d77e83c5 100644 --- a/dsse/verify.go +++ b/dsse/verify.go @@ -95,7 +95,7 @@ func (e Envelope) Verify(opts ...VerificationOption) ([]CheckedVerifier, error) checkedVerifiers := make([]CheckedVerifier, 0) verified := 0 for _, sig := range e.Signatures { - if sig.Certificate != nil && len(sig.Certificate) > 0 { + if len(sig.Certificate) > 0 { cert, err := cryptoutil.TryParseCertificate(sig.Certificate) if err != nil { continue