From 722c904f4bec7eb4550ca5b68ae7e8863192bcdc Mon Sep 17 00:00:00 2001 From: Marina Biryukova Date: Fri, 4 Aug 2023 15:04:20 +0300 Subject: [PATCH] [#3] Add linters Signed-off-by: Marina Biryukova --- .forgejo/workflows/linters.yml | 20 ++++++++++++++++++++ .golangci.yml | 29 +++++++++++++++++++++++++++++ Makefile | 3 +++ ca/renew.go | 2 +- cmd/step-ca/main.go | 1 - go.mod | 1 - go.sum | 2 -- scripts/badger-migration/main.go | 4 ++-- 8 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 .forgejo/workflows/linters.yml create mode 100644 .golangci.yml diff --git a/.forgejo/workflows/linters.yml b/.forgejo/workflows/linters.yml new file mode 100644 index 00000000..96b729b5 --- /dev/null +++ b/.forgejo/workflows/linters.yml @@ -0,0 +1,20 @@ +name: Linters +on: [pull_request] + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.19' + cache: true + + - name: golangci-lint + uses: https://github.com/golangci/golangci-lint-action@v3 + with: + version: latest \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..18a881d9 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,29 @@ +# This file contains all available configuration options +# with their default values. + +# options for analysis running +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m + + # include test files or not, default is true + tests: false + +# output configuration options +output: + # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" + format: tab + +# all available settings of specific linters +linters-settings: + govet: + # report about shadowed variables + check-shadowing: false + +linters: + enable: + # mandatory linters + - govet + - revive + disable-all: true + fast: false \ No newline at end of file diff --git a/Makefile b/Makefile index 630b54b9..9d81d11d 100644 --- a/Makefile +++ b/Makefile @@ -177,3 +177,6 @@ run: .PHONY: run +# Run linters. Override old command +lint: + @golangci-lint --timeout=5m run diff --git a/ca/renew.go b/ca/renew.go index 9385e1df..823a02b1 100644 --- a/ca/renew.go +++ b/ca/renew.go @@ -65,7 +65,7 @@ func NewTLSRenewer(cert *tls.Certificate, fn RenewFunc, opts ...tlsRenewerOption // renewals due to the negative values in nextRenewDuration. period := cert.Leaf.NotAfter.Sub(time.Now().Truncate(time.Second)) if period < minCertDuration { - return nil, errors.Errorf("period must be greater than or equal to %s, but got %v.", minCertDuration, period) + return nil, errors.Errorf("period must be greater than or equal to %s, but got %v", minCertDuration, period) } // By default we will try to renew the cert before 2/3 of the validity // period have expired. diff --git a/cmd/step-ca/main.go b/cmd/step-ca/main.go index 11756b93..fc38d7d9 100644 --- a/cmd/step-ca/main.go +++ b/cmd/step-ca/main.go @@ -34,7 +34,6 @@ import ( _ "go.step.sm/crypto/kms/pkcs11" _ "go.step.sm/crypto/kms/softkms" _ "go.step.sm/crypto/kms/sshagentkms" - _ "go.step.sm/crypto/kms/yubikey" // Enabled cas interfaces. _ "github.com/smallstep/certificates/cas/cloudcas" diff --git a/go.mod b/go.mod index 2b043225..99f0e722 100644 --- a/go.mod +++ b/go.mod @@ -75,7 +75,6 @@ require ( github.com/go-jose/go-jose/v3 v3.0.0 // indirect github.com/go-kit/kit v0.10.0 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect - github.com/go-piv/piv-go v1.11.0 // indirect github.com/go-sql-driver/mysql v1.7.0 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang/glog v1.1.0 // indirect diff --git a/go.sum b/go.sum index a1cb4872..81c5a98f 100644 --- a/go.sum +++ b/go.sum @@ -363,8 +363,6 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-piv/piv-go v1.11.0 h1:5vAaCdRTFSIW4PeqMbnsDlUZ7odMYWnHBDGdmtU/Zhg= -github.com/go-piv/piv-go v1.11.0/go.mod h1:NZ2zmjVkfFaL/CF8cVQ/pXdXtuj110zEKGdJM6fJZZM= github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= github.com/go-redis/redis v6.10.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= diff --git a/scripts/badger-migration/main.go b/scripts/badger-migration/main.go index 89fb8e7d..7ebfc035 100644 --- a/scripts/badger-migration/main.go +++ b/scripts/badger-migration/main.go @@ -57,8 +57,8 @@ type DB interface { type dryRunDB struct{} -func (*dryRunDB) CreateTable([]byte) error { return nil } -func (*dryRunDB) Set(bucket, key, value []byte) error { return nil } +func (*dryRunDB) CreateTable([]byte) error { return nil } +func (*dryRunDB) Set(_, _, _ []byte) error { return nil } func usage(fs *flag.FlagSet) { name := filepath.Base(os.Args[0])