From d35e8f1adbb733ba6a81a4ee3e739fb2e92b8dcc Mon Sep 17 00:00:00 2001 From: Aleksey Bakin Date: Wed, 7 Feb 2024 22:41:16 +0300 Subject: [PATCH] chore: upgrade go and golangci-lint versions --- .github/workflows/ci.yml | 8 +++--- .golangci.yml | 46 +++++++++++++++++++++------------- pkg/analyzer/analyzer.go | 8 +++--- scripts/generator/generator.go | 1 + 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa0c4be..dd37e53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,11 +14,11 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: ^1.18 + go-version: ^1.21 - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.45.2 + version: v1.56.0 tests: runs-on: ubuntu-18.04 @@ -27,7 +27,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: ^1.18 + go-version: ^1.21 id: go - name: Check out code into the Go module directory uses: actions/checkout@v2 @@ -45,7 +45,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: ^1.18 + go-version: ^1.21 id: go - name: Check out code into the Go module directory uses: actions/checkout@v2 diff --git a/.golangci.yml b/.golangci.yml index 5ba2423..bbd536f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,25 +12,35 @@ linters-settings: locale: US gci: local-prefixes: github.com/kulti/thelper + nolintlint: + require-explanation: true + require-specific: true linters: enable-all: true disable: - - lll - - prealloc - - dupl - - wsl - - nlreturn - - goerr113 - - exhaustivestruct - - paralleltest - - gomnd - - gocognit - - nestif - - varnamelen - - interfacer - - maligned - - scopelint - - golint - - cyclop - - nilnil + - cyclop + - deadcode # deprecated + - depguard # Not looks useful for this project + - dupl + - exhaustivestruct # deprecated + - exhaustruct # Make use of zero-values and partial initialization. + - gocognit + - goerr113 + - golint + - gomnd + - ifshort # deprecated + - interfacer + - lll + - maligned + - nestif + - nilnil + - nlreturn + - nosnakecase # deprecated + - paralleltest + - prealloc + - scopelint + - structcheck # deprecated + - varcheck # deprecated + - varnamelen + - wsl diff --git a/pkg/analyzer/analyzer.go b/pkg/analyzer/analyzer.go index a22fd6a..d24fef4 100644 --- a/pkg/analyzer/analyzer.go +++ b/pkg/analyzer/analyzer.go @@ -16,7 +16,9 @@ import ( ) const ( - doc = "thelper detects tests helpers which is not start with t.Helper() method." + doc = "thelper detects tests helpers which is not start with t.Helper() method." + + //nolint:goconst // Just a repeated coma, cannot be write better. checksDoc = `coma separated list of enabled checks Available checks @@ -254,7 +256,7 @@ func (t thelper) buildTestCheckFuncOpts(pass *analysis.Pass, ctxType types.Type) fnHelper: tHelper, subRun: tRun, hpType: tType, - subTestFuncType: types.NewSignature(nil, types.NewTuple(tVar), nil, false), + subTestFuncType: types.NewSignatureType(nil, nil, nil, types.NewTuple(tVar), nil, false), ctxType: ctxType, checkBegin: t.enabledChecks.Enabled(checkTBegin), checkFirst: t.enabledChecks.Enabled(checkTFirst), @@ -315,7 +317,7 @@ func (t thelper) buildBenchmarkCheckFuncOpts(pass *analysis.Pass, ctxType types. fnHelper: bHelper, subRun: bRun, hpType: types.NewPointer(bObj.Type()), - subTestFuncType: types.NewSignature(nil, types.NewTuple(bVar), nil, false), + subTestFuncType: types.NewSignatureType(nil, nil, nil, types.NewTuple(bVar), nil, false), ctxType: ctxType, checkBegin: t.enabledChecks.Enabled(checkBBegin), checkFirst: t.enabledChecks.Enabled(checkBFirst), diff --git a/scripts/generator/generator.go b/scripts/generator/generator.go index dc997be..b1a0bf2 100644 --- a/scripts/generator/generator.go +++ b/scripts/generator/generator.go @@ -9,6 +9,7 @@ import ( "text/template" ) +//nolint:dupword // false positive about double `type` const tTmpl = `// Code generated by generator. DO NOT EDIT. package {{$.Name}}