aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/golangci
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2024-09-10 12:16:33 +0200
committerTaras Madan <tarasmadan@google.com>2024-09-10 14:05:26 +0000
commitc97c816133b42257d0bcf1ee4bd178bb2a7a2b9e (patch)
tree0bcbc2e540bbf8f62f6c17887cdd53b8c2cee637 /vendor/github.com/golangci
parent54e657429ab892ad06c90cd7c1a4eb33ba93a3dc (diff)
vendor: update
Diffstat (limited to 'vendor/github.com/golangci')
-rw-r--r--vendor/github.com/golangci/gofmt/gofmt/gofmt.go134
-rw-r--r--vendor/github.com/golangci/gofmt/gofmt/internal.go4
-rw-r--r--vendor/github.com/golangci/gofmt/gofmt/internal/diff/diff.go4
-rw-r--r--vendor/github.com/golangci/gofmt/gofmt/readme.md17
-rw-r--r--vendor/github.com/golangci/gofmt/gofmt/rewrite.go6
-rw-r--r--vendor/github.com/golangci/gofmt/goimports/goimports.go5
-rw-r--r--vendor/github.com/golangci/gofmt/goimports/readme.md10
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/commands/cache.go4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/commands/config.go16
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/commands/config_verify.go9
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/commands/flagsets.go29
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/commands/help.go26
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/commands/internal/builder.go63
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/commands/internal/configuration.go2
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/commands/linters.go14
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/commands/run.go15
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/commands/version.go8
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/config/config.go30
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/config/issues.go73
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/config/linters_settings.go93
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/config/loader.go207
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/config/output.go6
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/goanalysis/linter.go4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/goanalysis/metalinter.go8
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/errors.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/goanalysis/errors.go)28
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/extract.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/packages/util.go)6
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/parse.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/packages/errors.go)21
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go3
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners.go9
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/asasalint/asasalint.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/asasalint.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/asciicheck/asciicheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/asciicheck.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/bidichk/bidichk.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/bidichk.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/bodyclose/bodyclose.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/bodyclose.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/canonicalheader/canonicalheader.go19
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/containedctx/containedctx.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/containedctx.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/contextcheck/contextcheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/contextcheck.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/copyloopvar/copyloopvar.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/copyloopvar.go)6
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/cyclop/cyclop.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/cyclop.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/decorder/decorder.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/decorder.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/depguard/depguard.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/depguard.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/dogsled/dogsled.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/dogsled.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl/dupl.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/dupword/dupword.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/dupword.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/durationcheck/durationcheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/durationcheck.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/err113/err113.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/goerr113.go)10
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/errcheck/errcheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/errcheck.go)13
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/errchkjson/errchkjson.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/errchkjson.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/errname/errname.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/errname.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/errorlint/errorlint.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/errorlint.go)28
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/execinquery/execinquery.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/execinquery.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustive/exhaustive.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustive.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustruct/exhaustruct.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustruct.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/exportloopref/exportloopref.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/exportloopref.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/fatcontext/fatcontext.go19
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/forbidigo/forbidigo.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/forbidigo.go)14
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert/forcetypeassert.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/funlen/funlen.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/funlen.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gci/gci.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gci.go)138
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter/ginkgolinter.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals/gochecknoglobals.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits/gochecknoinits.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits.go)18
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype/gochecksumtype.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gocognit/gocognit.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gocognit.go)10
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/goconst/goconst.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/goconst.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gocritic/gocritic.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gocritic.go)115
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gocyclo/gocyclo.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gocyclo.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/godot/godot.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/godot.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/godox/godox.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/godox.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gofmt/gofmt.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gofmt.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gofumpt.go)20
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/goheader/goheader.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/goheader.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/goimports/goimports.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/goimports.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gomnd.go45
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives/gomoddirectives.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives.go)13
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gomodguard/gomodguard.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gomodguard.go)15
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname/goprintffuncname.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gosec/gosec.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gosec.go)48
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gosimple/gosimple.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gosimple.go)6
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan/gosmopolitan.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/govet/govet.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/govet.go)20
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/grouper/grouper.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/grouper.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/importas/importas.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/importas.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/inamedparam/inamedparam.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/inamedparam.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/ineffassign/ineffassign.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/ineffassign.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/interfacebloat/interfacebloat.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/interfacebloat.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go1
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/staticcheck_common.go16
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/intrange/intrange.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/intrange.go)6
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/ireturn/ireturn.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/ireturn.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/lll/lll.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/lll.go)16
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/loggercheck/loggercheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/loggercheck.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/maintidx/maintidx.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/maintidx.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/makezero/makezero.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/makezero.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/mirror/mirror.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/mirror.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/misspell/misspell.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/misspell.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/mnd/mnd.go63
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/musttag/musttag.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/musttag.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nakedret/nakedret.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/nakedret.go)8
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nestif/nestif.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/nestif.go)10
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nilerr/nilerr.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/nilerr.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnil/nilnil.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnil.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nlreturn/nlreturn.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/nlreturn.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/noctx/noctx.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/noctx.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint.go104
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/README.md (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/README.md)6
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/nolintlint.go311
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/nolintlint.go346
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns/nonamedreturns.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport/nosprintfhostport.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/paralleltest/paralleltest.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/paralleltest.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/perfsprint/perfsprint.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/perfsprint.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/prealloc/prealloc.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/prealloc.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/predeclared/predeclared.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/predeclared.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/promlinter/promlinter.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/promlinter.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/protogetter/protogetter.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/protogetter.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/reassign/reassign.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/reassign.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/revive/revive.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/revive.go)75
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck/rowserrcheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/sloglint/sloglint.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/sloglint.go)9
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/spancheck/spancheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/spancheck.go)8
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck/sqlclosecheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/staticcheck/staticcheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/staticcheck.go)6
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/stylecheck/stylecheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/stylecheck.go)6
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/tagalign/tagalign.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/tagalign.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/tagliatelle/tagliatelle.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/tagliatelle.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/tenv/tenv.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/tenv.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/testableexamples/testableexamples.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/testableexamples.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/testifylint/testifylint.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/testifylint.go)9
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/testpackage/testpackage.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/testpackage.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/thelper/thelper.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/thelper.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/tparallel/tparallel.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/tparallel.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/typecheck.go2
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/unconvert/unconvert.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/unconvert.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/unparam/unparam.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/unparam.go)12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/unused/unused.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/unused.go)27
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars/usestdlibvars.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/varnamelen/varnamelen.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/varnamelen.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/wastedassign/wastedassign.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/wastedassign.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/whitespace/whitespace.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/whitespace.go)8
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/wrapcheck/wrapcheck.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/wrapcheck.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/wsl/wsl.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/wsl.go)5
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/golinters/zerologlint/zerologlint.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/golinters/zerologlint.go)4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/goutil/version.go75
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/lint/linter/config.go20
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/lint/linter/linter.go14
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_linter.go395
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_plugin_go.go7
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/manager.go39
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/validator.go63
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/lint/package.go42
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/lint/runner.go92
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/logutils/mock.go55
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/packages/exclude.go25
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/printers/githubaction.go (renamed from vendor/github.com/golangci/golangci-lint/pkg/printers/github.go)34
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/printers/junitxml.go17
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/printers/printer.go10
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/printers/sarif.go117
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/printers/teamcity.go12
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/autogenerated_exclude.go44
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/base_rule.go8
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/cgo.go56
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/diff.go22
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclude.go25
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclude_rules.go40
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/filename_unadjuster.go94
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/fixer.go66
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/identifier_marker.go21
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/invalid_issue.go28
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/issues.go23
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_from_linter.go31
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_per_file_from_linter.go48
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_same_issues.go30
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/nolint.go194
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prefixer.go4
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prettifier.go20
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_shortener.go13
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/processor.go2
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/severity.go32
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_dirs.go76
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_files.go11
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/sort_results.go25
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/source_code.go43
-rw-r--r--vendor/github.com/golangci/golangci-lint/pkg/result/processors/uniq_by_line.go79
-rw-r--r--vendor/github.com/golangci/misspell/.golangci.yml4
-rw-r--r--vendor/github.com/golangci/misspell/.pre-commit-hooks.yaml8
-rw-r--r--vendor/github.com/golangci/misspell/Dockerfile2
-rw-r--r--vendor/github.com/golangci/misspell/Makefile2
-rw-r--r--vendor/github.com/golangci/misspell/README.md253
-rw-r--r--vendor/github.com/golangci/misspell/goreleaser.yml15
-rw-r--r--vendor/github.com/golangci/misspell/install-misspell.sh244
-rw-r--r--vendor/github.com/golangci/misspell/mime.go15
-rw-r--r--vendor/github.com/golangci/misspell/notwords.go27
-rw-r--r--vendor/github.com/golangci/misspell/replace.go12
-rw-r--r--vendor/github.com/golangci/misspell/stringreplacer.go23
-rw-r--r--vendor/github.com/golangci/misspell/url.go2
-rw-r--r--vendor/github.com/golangci/modinfo/.gitignore1
-rw-r--r--vendor/github.com/golangci/modinfo/.golangci.yml157
-rw-r--r--vendor/github.com/golangci/modinfo/LICENSE674
-rw-r--r--vendor/github.com/golangci/modinfo/Makefile12
-rw-r--r--vendor/github.com/golangci/modinfo/module.go157
-rw-r--r--vendor/github.com/golangci/modinfo/readme.md73
-rw-r--r--vendor/github.com/golangci/revgrep/.golangci.yml4
-rw-r--r--vendor/github.com/golangci/revgrep/revgrep.go82
205 files changed, 4360 insertions, 2360 deletions
diff --git a/vendor/github.com/golangci/gofmt/gofmt/gofmt.go b/vendor/github.com/golangci/gofmt/gofmt/gofmt.go
index be046f34c..909d37657 100644
--- a/vendor/github.com/golangci/gofmt/gofmt/gofmt.go
+++ b/vendor/github.com/golangci/gofmt/gofmt/gofmt.go
@@ -16,10 +16,12 @@ import (
"go/token"
"io"
"io/fs"
+ "math/rand"
"os"
"path/filepath"
"runtime"
"runtime/pprof"
+ "strconv"
"strings"
"github.com/golangci/gofmt/gofmt/internal/diff"
@@ -233,12 +235,9 @@ func processFile(filename string, info fs.FileInfo, in io.Reader, r *reporter) e
}
fileSet := token.NewFileSet()
- fragmentOk := false
- if info == nil {
- // If we are formatting stdin, we accept a program fragment in lieu of a
- // complete source file.
- fragmentOk = true
- }
+ // If we are formatting stdin, we accept a program fragment in lieu of a
+ // complete source file.
+ fragmentOk := info == nil
file, sourceAdj, indentAdj, err := parse(fileSet, filename, src, fragmentOk)
if err != nil {
return err
@@ -272,21 +271,9 @@ func processFile(filename string, info fs.FileInfo, in io.Reader, r *reporter) e
if info == nil {
panic("-w should not have been allowed with stdin")
}
- // make a temporary backup before overwriting original
+
perm := info.Mode().Perm()
- bakname, err := backupFile(filename+".", src, perm)
- if err != nil {
- return err
- }
- fdSem <- true
- err = os.WriteFile(filename, res, perm)
- <-fdSem
- if err != nil {
- os.Rename(bakname, filename)
- return err
- }
- err = os.Remove(bakname)
- if err != nil {
+ if err := writeFile(filename, src, res, perm, info.Size()); err != nil {
return err
}
}
@@ -470,32 +457,111 @@ func fileWeight(path string, info fs.FileInfo) int64 {
return info.Size()
}
-const chmodSupported = runtime.GOOS != "windows"
+// writeFile updates a file with the new formatted data.
+func writeFile(filename string, orig, formatted []byte, perm fs.FileMode, size int64) error {
+ // Make a temporary backup file before rewriting the original file.
+ bakname, err := backupFile(filename, orig, perm)
+ if err != nil {
+ return err
+ }
+
+ fdSem <- true
+ defer func() { <-fdSem }()
+
+ fout, err := os.OpenFile(filename, os.O_WRONLY, perm)
+ if err != nil {
+ // We couldn't even open the file, so it should
+ // not have changed.
+ os.Remove(bakname)
+ return err
+ }
+ defer fout.Close() // for error paths
+
+ restoreFail := func(err error) {
+ fmt.Fprintf(os.Stderr, "gofmt: %s: error restoring file to original: %v; backup in %s\n", filename, err, bakname)
+ }
+
+ n, err := fout.Write(formatted)
+ if err == nil && int64(n) < size {
+ err = fout.Truncate(int64(n))
+ }
+
+ if err != nil {
+ // Rewriting the file failed.
+
+ if n == 0 {
+ // Original file unchanged.
+ os.Remove(bakname)
+ return err
+ }
+
+ // Try to restore the original contents.
+
+ no, erro := fout.WriteAt(orig, 0)
+ if erro != nil {
+ // That failed too.
+ restoreFail(erro)
+ return err
+ }
+
+ if no < n {
+ // Original file is shorter. Truncate.
+ if erro = fout.Truncate(int64(no)); erro != nil {
+ restoreFail(erro)
+ return err
+ }
+ }
+
+ if erro := fout.Close(); erro != nil {
+ restoreFail(erro)
+ return err
+ }
+
+ // Original contents restored.
+ os.Remove(bakname)
+ return err
+ }
+
+ if err := fout.Close(); err != nil {
+ restoreFail(err)
+ return err
+ }
+
+ // File updated.
+ os.Remove(bakname)
+ return nil
+}
// backupFile writes data to a new file named filename<number> with permissions perm,
-// with <number randomly chosen such that the file name is unique. backupFile returns
+// with <number> randomly chosen such that the file name is unique. backupFile returns
// the chosen file name.
func backupFile(filename string, data []byte, perm fs.FileMode) (string, error) {
fdSem <- true
defer func() { <-fdSem }()
- // create backup file
- f, err := os.CreateTemp(filepath.Dir(filename), filepath.Base(filename))
- if err != nil {
- return "", err
+ nextRandom := func() string {
+ return strconv.Itoa(rand.Int())
}
- bakname := f.Name()
- if chmodSupported {
- err = f.Chmod(perm)
- if err != nil {
- f.Close()
- os.Remove(bakname)
- return bakname, err
+
+ dir, base := filepath.Split(filename)
+ var (
+ bakname string
+ f *os.File
+ )
+ for {
+ bakname = filepath.Join(dir, base+"."+nextRandom())
+ var err error
+ f, err = os.OpenFile(bakname, os.O_RDWR|os.O_CREATE|os.O_EXCL, perm)
+ if err == nil {
+ break
+ }
+ if err != nil && !os.IsExist(err) {
+ return "", err
}
}
// write data to backup file
- _, err = f.Write(data)
+ _, err := f.Write(data)
if err1 := f.Close(); err == nil {
err = err1
}
diff --git a/vendor/github.com/golangci/gofmt/gofmt/internal.go b/vendor/github.com/golangci/gofmt/gofmt/internal.go
index 31a825bf8..231a25091 100644
--- a/vendor/github.com/golangci/gofmt/gofmt/internal.go
+++ b/vendor/github.com/golangci/gofmt/gofmt/internal.go
@@ -27,11 +27,11 @@ func parse(fset *token.FileSet, filename string, src []byte, fragmentOk bool) (
err error,
) {
- // START - Change related to usgae inside golangci-lint
+ // START - Change related to usage inside golangci-lint
parserModeMu.Lock()
parserMode := parserMode
parserModeMu.Unlock()
- // END - Change related to usgae inside golangci-lint
+ // END - Change related to usage inside golangci-lint
// Try as whole source file.
file, err = parser.ParseFile(fset, filename, src, parserMode)
diff --git a/vendor/github.com/golangci/gofmt/gofmt/internal/diff/diff.go b/vendor/github.com/golangci/gofmt/gofmt/internal/diff/diff.go
index 47b285671..6a40b23fc 100644
--- a/vendor/github.com/golangci/gofmt/gofmt/internal/diff/diff.go
+++ b/vendor/github.com/golangci/gofmt/gofmt/internal/diff/diff.go
@@ -74,9 +74,9 @@ func Diff(oldName string, old []byte, newName string, new []byte) []byte {
continue
}
- // Expand matching lines as far possible,
+ // Expand matching lines as far as possible,
// establishing that x[start.x:end.x] == y[start.y:end.y].
- // Note that on the first (or last) iteration we may (or definitey do)
+ // Note that on the first (or last) iteration we may (or definitely do)
// have an empty match: start.x==end.x and start.y==end.y.
start := m
for start.x > done.x && start.y > done.y && x[start.x-1] == y[start.y-1] {
diff --git a/vendor/github.com/golangci/gofmt/gofmt/readme.md b/vendor/github.com/golangci/gofmt/gofmt/readme.md
index c2faaab82..be08179e6 100644
--- a/vendor/github.com/golangci/gofmt/gofmt/readme.md
+++ b/vendor/github.com/golangci/gofmt/gofmt/readme.md
@@ -1,5 +1,16 @@
# Hard Fork of gofmt
-2022-08-31: Sync with go1.18.5
-2023-10-04: Sync with go1.19.13
-2023-10-04: Sync with go1.20.8
+- https://github.com/golang/go/blob/master/src/cmd/gofmt/
+- https://github.com/golang/go/blob/master/src/internal/testenv
+- https://github.com/golang/go/blob/master/src/internal/platform
+- https://github.com/golang/go/blob/master/src/internal/txtar
+- https://github.com/golang/go/blob/master/src/internal/diff
+- https://github.com/golang/go/blob/master/src/internal/cfg
+
+## Updates
+
+- 2024-08-17: Sync with go1.22.6
+- 2023-02-28: Sync with go1.21.7
+- 2023-10-04: Sync with go1.20.8
+- 2023-10-04: Sync with go1.19.13
+- 2022-08-31: Sync with go1.18.5
diff --git a/vendor/github.com/golangci/gofmt/gofmt/rewrite.go b/vendor/github.com/golangci/gofmt/gofmt/rewrite.go
index f1299a42b..c95d44f61 100644
--- a/vendor/github.com/golangci/gofmt/gofmt/rewrite.go
+++ b/vendor/github.com/golangci/gofmt/gofmt/rewrite.go
@@ -69,9 +69,7 @@ func rewriteFile(fileSet *token.FileSet, pattern, replace ast.Expr, p *ast.File)
return reflect.Value{}
}
val = apply(rewriteVal, val)
- for k := range m {
- delete(m, k)
- }
+ clear(m)
if match(m, pat, val) {
val = subst(m, repl, reflect.ValueOf(val.Interface().(ast.Node).Pos()))
}
@@ -199,7 +197,7 @@ func match(m map[string]reflect.Value, pattern, val reflect.Value) bool {
// object pointers and token positions always match
return true
case callExprType:
- // For calls, the Ellipsis fields (token.Position) must
+ // For calls, the Ellipsis fields (token.Pos) must
// match since that is how f(x) and f(x...) are different.
// Check them here but fall through for the remaining fields.
p := pattern.Interface().(*ast.CallExpr)
diff --git a/vendor/github.com/golangci/gofmt/goimports/goimports.go b/vendor/github.com/golangci/gofmt/goimports/goimports.go
index 20d92e119..556f2bd7e 100644
--- a/vendor/github.com/golangci/gofmt/goimports/goimports.go
+++ b/vendor/github.com/golangci/gofmt/goimports/goimports.go
@@ -7,17 +7,16 @@ package goimports
import (
"bytes"
"fmt"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
)
-// Extracted from golang.org/x/tools@v0.13.0/cmd/goimports/goimports.go
+// Extracted from golang.org/x/tools@v0.24.0/cmd/goimports/goimports.go
func writeTempFile(dir, prefix string, data []byte) (string, error) {
- file, err := ioutil.TempFile(dir, prefix)
+ file, err := os.CreateTemp(dir, prefix)
if err != nil {
return "", err
}
diff --git a/vendor/github.com/golangci/gofmt/goimports/readme.md b/vendor/github.com/golangci/gofmt/goimports/readme.md
index e57ed550b..23eecf82f 100644
--- a/vendor/github.com/golangci/gofmt/goimports/readme.md
+++ b/vendor/github.com/golangci/gofmt/goimports/readme.md
@@ -1,4 +1,10 @@
# Hard Fork of goimports
-2022-08-31: Sync with golang.org/x/tools v0.1.12
-2023-10-04: Sync with golang.org/x/tools v0.13.0
+- https://github.com/golang/tools/tree/master/cmd/goimports
+
+## Updates
+
+- 2024-08-17: Sync with golang.org/x/tools v0.24.0
+- 2024-02-28: Sync with golang.org/x/tools v0.18.0
+- 2023-10-04: Sync with golang.org/x/tools v0.13.0
+- 2022-08-31: Sync with golang.org/x/tools v0.1.12
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/cache.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/cache.go
index 4aa813051..cc6c0eacd 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/cache.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/commands/cache.go
@@ -50,7 +50,7 @@ func newCacheCommand() *cacheCommand {
return c
}
-func (c *cacheCommand) executeClean(_ *cobra.Command, _ []string) error {
+func (*cacheCommand) executeClean(_ *cobra.Command, _ []string) error {
cacheDir := cache.DefaultDir()
if err := os.RemoveAll(cacheDir); err != nil {
@@ -60,7 +60,7 @@ func (c *cacheCommand) executeClean(_ *cobra.Command, _ []string) error {
return nil
}
-func (c *cacheCommand) executeStatus(_ *cobra.Command, _ []string) {
+func (*cacheCommand) executeStatus(_ *cobra.Command, _ []string) {
cacheDir := cache.DefaultDir()
_, _ = fmt.Fprintf(logutils.StdOut, "Dir: %s\n", cacheDir)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/config.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/config.go
index cfb7d67ac..935ec5e86 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/config.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/commands/config.go
@@ -49,6 +49,8 @@ func newConfigCommand(log logutils.Log, info BuildInfo) *configCommand {
Args: cobra.NoArgs,
ValidArgsFunction: cobra.NoFileCompletions,
RunE: c.executeVerify,
+ SilenceUsage: true,
+ SilenceErrors: true,
}
configCmd.AddCommand(
@@ -77,21 +79,15 @@ func newConfigCommand(log logutils.Log, info BuildInfo) *configCommand {
return c
}
-func (c *configCommand) preRunE(cmd *cobra.Command, _ []string) error {
+func (c *configCommand) preRunE(cmd *cobra.Command, args []string) error {
// The command doesn't depend on the real configuration.
// It only needs to know the path of the configuration file.
cfg := config.NewDefault()
- // Hack to hide deprecation messages related to `--skip-dirs-use-default`:
- // Flags are not bound then the default values, defined only through flags, are not applied.
- // In this command, file path and file information are the only requirements, i.e. it don't need flag values.
- //
- // TODO(ldez) add an option (check deprecation) to `Loader.Load()` but this require a dedicated PR.
- cfg.Run.UseDefaultSkipDirs = true
+ loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts, cfg, args)
- loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts, cfg)
-
- if err := loader.Load(); err != nil {
+ err := loader.Load(config.LoadOptions{})
+ if err != nil {
return fmt.Errorf("can't load config: %w", err)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/config_verify.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/config_verify.go
index 291c99a02..89017e9bf 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/config_verify.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/commands/config_verify.go
@@ -3,14 +3,16 @@ package commands
import (
"errors"
"fmt"
+ "net/http"
"os"
"path/filepath"
"strings"
+ "time"
hcversion "github.com/hashicorp/go-version"
"github.com/pelletier/go-toml/v2"
"github.com/santhosh-tekuri/jsonschema/v5"
- _ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
+ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"gopkg.in/yaml.v3"
@@ -45,7 +47,7 @@ func (c *configCommand) executeVerify(cmd *cobra.Command, _ []string) error {
printValidationDetail(cmd, &detail)
- return fmt.Errorf("the configuration contains invalid elements")
+ return errors.New("the configuration contains invalid elements")
}
return nil
@@ -98,6 +100,8 @@ func createSchemaURL(flags *pflag.FlagSet, buildInfo BuildInfo) (string, error)
}
func validateConfiguration(schemaPath, targetFile string) error {
+ httploader.Client = &http.Client{Timeout: 2 * time.Second}
+
compiler := jsonschema.NewCompiler()
compiler.Draft = jsonschema.Draft7
@@ -136,7 +140,6 @@ func printValidationDetail(cmd *cobra.Command, detail *jsonschema.Detailed) {
}
for _, d := range detail.Errors {
- d := d
printValidationDetail(cmd, &d)
}
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/flagsets.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/flagsets.go
index af5c351c5..608f6b9de 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/flagsets.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/commands/flagsets.go
@@ -12,9 +12,11 @@ import (
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/exitcodes"
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
- "github.com/golangci/golangci-lint/pkg/packages"
+ "github.com/golangci/golangci-lint/pkg/result/processors"
)
+const defaultMaxIssuesPerLinter = 50
+
func setupLintersFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
internal.AddHackedStringSliceP(fs, "disable", "D", color.GreenString("Disable specific linter"))
internal.AddFlagAndBind(v, fs, fs.Bool, "disable-all", "linters.disable-all", false, color.GreenString("Disable all linters"))
@@ -26,8 +28,11 @@ func setupLintersFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
color.GreenString("Enable only fast linters from enabled linters set (first run won't be fast)"))
internal.AddHackedStringSliceP(fs, "presets", "p",
- color.GreenString(fmt.Sprintf("Enable presets (%s) of linters. Run 'golangci-lint help linters' to see them. "+
- "This option implies option --disable-all", strings.Join(lintersdb.AllPresets(), "|"))))
+ color.GreenString(fmt.Sprintf("Enable presets (%s) of linters.\n"+
+ "Run 'golangci-lint help linters' to see them.\n"+
+ "This option implies option --disable-all",
+ strings.Join(lintersdb.AllPresets(), "|"),
+ )))
fs.StringSlice("enable-only", nil,
color.GreenString("Override linters configuration section to only run the specific linter(s)")) // Flags only.
@@ -53,11 +58,11 @@ func setupRunFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
internal.AddDeprecatedFlagAndBind(v, fs, fs.Bool, "skip-dirs-use-default", "run.skip-dirs-use-default", true,
getDefaultDirectoryExcludeHelp())
- const allowParallelDesc = "Allow multiple parallel golangci-lint instances running. " +
+ const allowParallelDesc = "Allow multiple parallel golangci-lint instances running.\n" +
"If false (default) - golangci-lint acquires file lock on start."
internal.AddFlagAndBind(v, fs, fs.Bool, "allow-parallel-runners", "run.allow-parallel-runners", false,
color.GreenString(allowParallelDesc))
- const allowSerialDesc = "Allow multiple golangci-lint instances running, but serialize them around a lock. " +
+ const allowSerialDesc = "Allow multiple golangci-lint instances running, but serialize them around a lock.\n" +
"If false (default) - golangci-lint exits with an error if it fails to acquire file lock on start."
internal.AddFlagAndBind(v, fs, fs.Bool, "allow-serial-runners", "run.allow-serial-runners", false, color.GreenString(allowSerialDesc))
}
@@ -88,7 +93,7 @@ func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
internal.AddFlagAndBind(v, fs, fs.Bool, "exclude-case-sensitive", "issues.exclude-case-sensitive", false,
color.GreenString("If set to true exclude and exclude rules regular expressions are case-sensitive"))
- internal.AddFlagAndBind(v, fs, fs.Int, "max-issues-per-linter", "issues.max-issues-per-linter", 50,
+ internal.AddFlagAndBind(v, fs, fs.Int, "max-issues-per-linter", "issues.max-issues-per-linter", defaultMaxIssuesPerLinter,
color.GreenString("Maximum issues count per one linter. Set to 0 to disable"))
internal.AddFlagAndBind(v, fs, fs.Int, "max-same-issues", "issues.max-same-issues", 3,
color.GreenString("Maximum count of issues with the same text. Set to 0 to disable"))
@@ -98,6 +103,9 @@ func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
internal.AddFlagAndBind(v, fs, fs.Bool, "exclude-dirs-use-default", "issues.exclude-dirs-use-default", true,
getDefaultDirectoryExcludeHelp())
+ internal.AddFlagAndBind(v, fs, fs.String, "exclude-generated", "issues.exclude-generated", processors.AutogeneratedModeLax,
+ color.GreenString("Mode of the generated files analysis"))
+
const newDesc = "Show only new issues: if there are unstaged changes or untracked files, only those changes " +
"are analyzed, else only changes in HEAD~ are analyzed.\nIt's a super-useful option for integration " +
"of golangci-lint into existing large codebase.\nIt's not practical to fix all existing issues at " +
@@ -117,19 +125,20 @@ func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
func getDefaultIssueExcludeHelp() string {
parts := []string{color.GreenString("Use or not use default excludes:")}
+
for _, ep := range config.DefaultExcludePatterns {
parts = append(parts,
- fmt.Sprintf(" # %s %s: %s", ep.ID, ep.Linter, ep.Why),
- fmt.Sprintf(" - %s", color.YellowString(ep.Pattern)),
- "",
+ fmt.Sprintf(" - %s (%s): %s", color.BlueString(ep.ID), color.CyanString(ep.Linter), ep.Why),
+ fmt.Sprintf(` Pattern: %s`, color.YellowString(`'`+ep.Pattern+`'`)),
)
}
+
return strings.Join(parts, "\n")
}
func getDefaultDirectoryExcludeHelp() string {
parts := []string{color.GreenString("Use or not use default excluded directories:")}
- for _, dir := range packages.StdExcludeDirRegexps {
+ for _, dir := range processors.StdExcludeDirRegexps {
parts = append(parts, fmt.Sprintf(" - %s", color.YellowString(dir)))
}
parts = append(parts, "")
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/help.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/help.go
index 42da4a3dc..094e5d190 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/help.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/commands/help.go
@@ -2,6 +2,7 @@ package commands
import (
"fmt"
+ "slices"
"sort"
"strings"
@@ -106,16 +107,23 @@ func (c *helpCommand) printPresets() {
}
func printLinters(lcs []*linter.Config) {
- sort.Slice(lcs, func(i, j int) bool {
- return lcs[i].Name() < lcs[j].Name()
- })
+ slices.SortFunc(lcs, func(a, b *linter.Config) int {
+ if a.IsDeprecated() && b.IsDeprecated() {
+ return strings.Compare(a.Name(), b.Name())
+ }
- for _, lc := range lcs {
- altNamesStr := ""
- if len(lc.AlternativeNames) != 0 {
- altNamesStr = fmt.Sprintf(" (%s)", strings.Join(lc.AlternativeNames, ", "))
+ if a.IsDeprecated() {
+ return 1
+ }
+
+ if b.IsDeprecated() {
+ return -1
}
+ return strings.Compare(a.Name(), b.Name())
+ })
+
+ for _, lc := range lcs {
// If the linter description spans multiple lines, truncate everything following the first newline
linterDescription := lc.Linter.Desc()
firstNewline := strings.IndexRune(linterDescription, '\n')
@@ -128,7 +136,7 @@ func printLinters(lcs []*linter.Config) {
deprecatedMark = " [" + color.RedString("deprecated") + "]"
}
- _, _ = fmt.Fprintf(logutils.StdOut, "%s%s%s: %s [fast: %t, auto-fix: %t]\n",
- color.YellowString(lc.Name()), altNamesStr, deprecatedMark, linterDescription, !lc.IsSlowLinter(), lc.CanAutoFix)
+ _, _ = fmt.Fprintf(logutils.StdOut, "%s%s: %s [fast: %t, auto-fix: %t]\n",
+ color.YellowString(lc.Name()), deprecatedMark, linterDescription, !lc.IsSlowLinter(), lc.CanAutoFix)
}
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/builder.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/builder.go
index 39ec2a251..f0e259fb0 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/builder.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/builder.go
@@ -53,9 +53,9 @@ func (b Builder) Build(ctx context.Context) error {
b.log.Infof("Adding replace directives")
- err = b.addReplaceDirectives(ctx)
+ err = b.addToGoMod(ctx)
if err != nil {
- return fmt.Errorf("add replace directives: %w", err)
+ return fmt.Errorf("add to go.mod: %w", err)
}
b.log.Infof("Running go mod tidy")
@@ -95,7 +95,7 @@ func (b Builder) clone(ctx context.Context) error {
output, err := cmd.CombinedOutput()
if err != nil {
- b.log.Infof(string(output))
+ b.log.Infof("%s", string(output))
return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
}
@@ -103,25 +103,56 @@ func (b Builder) clone(ctx context.Context) error {
return nil
}
-func (b Builder) addReplaceDirectives(ctx context.Context) error {
+func (b Builder) addToGoMod(ctx context.Context) error {
for _, plugin := range b.cfg.Plugins {
- if plugin.Path == "" {
+ if plugin.Path != "" {
+ err := b.addReplaceDirective(ctx, plugin)
+ if err != nil {
+ return err
+ }
+
continue
}
- replace := fmt.Sprintf("%s=%s", plugin.Module, plugin.Path)
+ err := b.goGet(ctx, plugin)
+ if err != nil {
+ return err
+ }
+ }
- cmd := exec.CommandContext(ctx, "go", "mod", "edit", "-replace", replace)
- cmd.Dir = b.repo
+ return nil
+}
- b.log.Infof("run: %s", strings.Join(cmd.Args, " "))
+func (b Builder) goGet(ctx context.Context, plugin *Plugin) error {
+ //nolint:gosec // the variables are user related.
+ cmd := exec.CommandContext(ctx, "go", "get", plugin.Module+"@"+plugin.Version)
+ cmd.Dir = b.repo
- output, err := cmd.CombinedOutput()
- if err != nil {
- b.log.Warnf(string(output))
+ b.log.Infof("run: %s", strings.Join(cmd.Args, " "))
- return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
- }
+ output, err := cmd.CombinedOutput()
+ if err != nil {
+ b.log.Warnf("%s", string(output))
+
+ return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
+ }
+
+ return nil
+}
+
+func (b Builder) addReplaceDirective(ctx context.Context, plugin *Plugin) error {
+ replace := fmt.Sprintf("%s=%s", plugin.Module, plugin.Path)
+
+ cmd := exec.CommandContext(ctx, "go", "mod", "edit", "-replace", replace)
+ cmd.Dir = b.repo
+
+ b.log.Infof("run: %s", strings.Join(cmd.Args, " "))
+
+ output, err := cmd.CombinedOutput()
+ if err != nil {
+ b.log.Warnf("%s", string(output))
+
+ return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
}
return nil
@@ -133,7 +164,7 @@ func (b Builder) goModTidy(ctx context.Context) error {
output, err := cmd.CombinedOutput()
if err != nil {
- b.log.Warnf(string(output))
+ b.log.Warnf("%s", string(output))
return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
}
@@ -156,7 +187,7 @@ func (b Builder) goBuild(ctx context.Context, binaryName string) error {
output, err := cmd.CombinedOutput()
if err != nil {
- b.log.Warnf(string(output))
+ b.log.Warnf("%s", string(output))
return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/configuration.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/configuration.go
index 532702594..f9de4c47a 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/configuration.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/commands/internal/configuration.go
@@ -103,6 +103,8 @@ func LoadConfiguration() (*Configuration, error) {
return nil, fmt.Errorf("file %s open: %w", configFilePath, err)
}
+ defer func() { _ = file.Close() }()
+
var cfg Configuration
err = yaml.NewDecoder(file).Decode(&cfg)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/linters.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/linters.go
index e9c155186..a93814f0f 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/linters.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/commands/linters.go
@@ -58,17 +58,11 @@ func newLintersCommand(logger logutils.Log) *lintersCommand {
return c
}
-func (c *lintersCommand) preRunE(cmd *cobra.Command, _ []string) error {
- // Hack to hide deprecation messages related to `--skip-dirs-use-default`:
- // Flags are not bound then the default values, defined only through flags, are not applied.
- // In this command, linters information are the only requirements, i.e. it don't need flag values.
- //
- // TODO(ldez) add an option (check deprecation) to `Loader.Load()` but this require a dedicated PR.
- c.cfg.Run.UseDefaultSkipDirs = true
+func (c *lintersCommand) preRunE(cmd *cobra.Command, args []string) error {
+ loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts.LoaderOptions, c.cfg, args)
- loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts.LoaderOptions, c.cfg)
-
- if err := loader.Load(); err != nil {
+ err := loader.Load(config.LoadOptions{Validation: true})
+ if err != nil {
return fmt.Errorf("can't load config: %w", err)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go
index 4240af217..f289bfdd7 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go
@@ -147,14 +147,17 @@ func newRunCommand(logger logutils.Log, info BuildInfo) *runCommand {
return c
}
-func (c *runCommand) persistentPreRunE(cmd *cobra.Command, _ []string) error {
+func (c *runCommand) persistentPreRunE(cmd *cobra.Command, args []string) error {
if err := c.startTracing(); err != nil {
return err
}
- loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts.LoaderOptions, c.cfg)
+ c.log.Infof("%s", c.buildInfo.String())
- if err := loader.Load(); err != nil {
+ loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts.LoaderOptions, c.cfg, args)
+
+ err := loader.Load(config.LoadOptions{CheckDeprecation: true, Validation: true})
+ if err != nil {
return fmt.Errorf("can't load config: %w", err)
}
@@ -170,7 +173,7 @@ func (c *runCommand) persistentPreRunE(cmd *cobra.Command, _ []string) error {
runtime.GOMAXPROCS(c.cfg.Run.Concurrency)
}
- return c.startTracing()
+ return nil
}
func (c *runCommand) persistentPostRunE(_ *cobra.Command, _ []string) error {
@@ -408,7 +411,7 @@ func (c *runCommand) setExitCodeIfIssuesFound(issues []result.Issue) {
}
func (c *runCommand) printDeprecatedLinterMessages(enabledLinters map[string]*linter.Config) {
- if c.cfg.InternalCmdTest {
+ if c.cfg.InternalCmdTest || os.Getenv(logutils.EnvTestRun) == "1" {
return
}
@@ -673,7 +676,7 @@ func computeBinarySalt(version string) ([]byte, error) {
func computeConfigSalt(cfg *config.Config) ([]byte, error) {
lintersSettingsBytes, err := yaml.Marshal(cfg.LintersSettings)
if err != nil {
- return nil, fmt.Errorf("failed to json marshal config linter settings: %w", err)
+ return nil, fmt.Errorf("failed to JSON marshal config linter settings: %w", err)
}
configData := bytes.NewBufferString("linters-settings=")
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/commands/version.go b/vendor/github.com/golangci/golangci-lint/pkg/commands/version.go
index a03e46e22..ac665f4c5 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/commands/version.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/commands/version.go
@@ -19,6 +19,11 @@ type BuildInfo struct {
Date string `json:"date"`
}
+func (b BuildInfo) String() string {
+ return fmt.Sprintf("golangci-lint has version %s built with %s from %s on %s",
+ b.Version, b.GoVersion, b.Commit, b.Date)
+}
+
type versionInfo struct {
Info BuildInfo
BuildInfo *debug.BuildInfo
@@ -92,7 +97,6 @@ func (c *versionCommand) execute(_ *cobra.Command, _ []string) error {
}
func printVersion(w io.Writer, info BuildInfo) error {
- _, err := fmt.Fprintf(w, "golangci-lint has version %s built with %s from %s on %s\n",
- info.Version, info.GoVersion, info.Commit, info.Date)
+ _, err := fmt.Fprintln(w, info.String())
return err
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/config.go b/vendor/github.com/golangci/golangci-lint/pkg/config/config.go
index af27a91b5..93b331bec 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/config.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/config/config.go
@@ -2,14 +2,13 @@ package config
import (
"os"
- "regexp"
"strings"
hcversion "github.com/hashicorp/go-version"
"github.com/ldez/gomoddirectives"
)
-// Config encapsulates the config data specified in the golangci-lint yaml config file.
+// Config encapsulates the config data specified in the golangci-lint YAML config file.
type Config struct {
cfgDir string // The directory containing the golangci-lint config file.
@@ -33,12 +32,12 @@ func (c *Config) GetConfigDir() string {
func (c *Config) Validate() error {
validators := []func() error{
- c.Issues.Validate,
- c.Severity.Validate,
+ c.Run.Validate,
+ c.Output.Validate,
c.LintersSettings.Validate,
c.Linters.Validate,
- c.Output.Validate,
- c.Run.Validate,
+ c.Issues.Validate,
+ c.Severity.Validate,
}
for _, v := range validators {
@@ -89,22 +88,3 @@ func detectGoVersion() string {
return "1.17"
}
-
-// Trims the Go version to keep only M.m.
-// Since Go 1.21 the version inside the go.mod can be a patched version (ex: 1.21.0).
-// The version can also include information which we want to remove (ex: 1.21alpha1)
-// https://go.dev/doc/toolchain#versions
-// This a problem with staticcheck and gocritic.
-func trimGoVersion(v string) string {
- if v == "" {
- return ""
- }
-
- exp := regexp.MustCompile(`(\d\.\d+)(?:\.\d+|[a-z]+\d)`)
-
- if exp.MatchString(v) {
- return exp.FindStringSubmatch(v)[1]
- }
-
- return v
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/issues.go b/vendor/github.com/golangci/golangci-lint/pkg/config/issues.go
index 45424b179..2ee9364aa 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/issues.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/config/issues.go
@@ -14,93 +14,92 @@ var DefaultExcludePatterns = []ExcludePattern{
Pattern: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close" +
"|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked",
Linter: "errcheck",
- Why: "Almost all programs ignore errors on these functions and in most cases it's ok",
+ Why: "Almost all programs ignore errors on these functions and in most cases it's ok.",
},
{
- ID: "EXC0002",
+ ID: "EXC0002", // TODO(ldez): should be remove in v2
Pattern: "(comment on exported (method|function|type|const)|" +
"should have( a package)? comment|comment should be of the form)",
Linter: "golint",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments",
+ Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
},
{
- ID: "EXC0003",
+ ID: "EXC0003", // TODO(ldez): should be remove in v2
Pattern: "func name will be used as test\\.Test.* by other packages, and that stutters; consider calling this",
Linter: "golint",
- Why: "False positive when tests are defined in package 'test'",
+ Why: "False positive when tests are defined in package 'test'.",
},
{
ID: "EXC0004",
Pattern: "(possible misuse of unsafe.Pointer|should have signature)",
Linter: "govet",
- Why: "Common false positives",
+ Why: "Common false positives.",
},
{
ID: "EXC0005",
- Pattern: "ineffective break statement. Did you mean to break out of the outer loop",
+ Pattern: "SA4011", // CheckScopedBreak
Linter: "staticcheck",
- Why: "Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore",
+ Why: "Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore.",
},
{
ID: "EXC0006",
- Pattern: "Use of unsafe calls should be audited",
+ Pattern: "G103: Use of unsafe calls should be audited",
Linter: "gosec",
- Why: "Too many false-positives on 'unsafe' usage",
+ Why: "Too many false-positives on 'unsafe' usage.",
},
{
ID: "EXC0007",
- Pattern: "Subprocess launch(ed with variable|ing should be audited)",
+ Pattern: "G204: Subprocess launched with variable",
Linter: "gosec",
- Why: "Too many false-positives for parametrized shell calls",
+ Why: "Too many false-positives for parametrized shell calls.",
},
{
ID: "EXC0008",
- Pattern: "(G104)",
+ Pattern: "G104", // Errors unhandled.
Linter: "gosec",
- Why: "Duplicated errcheck checks",
+ Why: "Duplicated errcheck checks.",
},
{
ID: "EXC0009",
- Pattern: "(Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)",
+ Pattern: "(G301|G302|G307): Expect (directory permissions to be 0750|file permissions to be 0600) or less",
Linter: "gosec",
- Why: "Too many issues in popular repos",
+ Why: "Too many issues in popular repos.",
},
{
ID: "EXC0010",
- Pattern: "Potential file inclusion via variable",
+ Pattern: "G304: Potential file inclusion via variable",
Linter: "gosec",
- Why: "False positive is triggered by 'src, err := ioutil.ReadFile(filename)'",
+ Why: "False positive is triggered by 'src, err := ioutil.ReadFile(filename)'.",
},
{
- ID: "EXC0011",
- Pattern: "(comment on exported (method|function|type|const)|" +
- "should have( a package)? comment|comment should be of the form)",
- Linter: "stylecheck",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments",
+ ID: "EXC0011",
+ Pattern: "(ST1000|ST1020|ST1021|ST1022)", // CheckPackageComment, CheckExportedFunctionDocs, CheckExportedTypeDocs, CheckExportedVarDocs
+ Linter: "stylecheck",
+ Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
},
{
ID: "EXC0012",
- Pattern: `exported (.+) should have comment( \(or a comment on this block\))? or be unexported`,
+ Pattern: `exported (.+) should have comment( \(or a comment on this block\))? or be unexported`, // rule: exported
Linter: "revive",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments",
+ Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
},
{
ID: "EXC0013",
- Pattern: `package comment should be of the form "(.+)...`,
+ Pattern: `package comment should be of the form "(.+)..."`, // rule: package-comments
Linter: "revive",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments",
+ Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
},
{
ID: "EXC0014",
- Pattern: `comment on exported (.+) should be of the form "(.+)..."`,
+ Pattern: `comment on exported (.+) should be of the form "(.+)..."`, // rule: exported
Linter: "revive",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments",
+ Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
},
{
ID: "EXC0015",
- Pattern: `should have a package comment`,
+ Pattern: `should have a package comment`, // rule: package-comments
Linter: "revive",
- Why: "Annoying issue about not having a comment. The rare codebase has such comments",
+ Why: "Annoying issue about not having a comment. The rare codebase has such comments.",
},
}
@@ -109,12 +108,14 @@ type Issues struct {
ExcludeCaseSensitive bool `mapstructure:"exclude-case-sensitive"`
ExcludePatterns []string `mapstructure:"exclude"`
ExcludeRules []ExcludeRule `mapstructure:"exclude-rules"`
- ExcludeGeneratedStrict bool `mapstructure:"exclude-generated-strict"`
UseDefaultExcludes bool `mapstructure:"exclude-use-default"`
- ExcludeFiles []string `mapstructure:"exclude-files"`
- ExcludeDirs []string `mapstructure:"exclude-dirs"`
- UseDefaultExcludeDirs bool `mapstructure:"exclude-dirs-use-default"`
+ ExcludeGenerated string `mapstructure:"exclude-generated"`
+
+ ExcludeFiles []string `mapstructure:"exclude-files"`
+ ExcludeDirs []string `mapstructure:"exclude-dirs"`
+
+ UseDefaultExcludeDirs bool `mapstructure:"exclude-dirs-use-default"`
MaxIssuesPerLinter int `mapstructure:"max-issues-per-linter"`
MaxSameIssues int `mapstructure:"max-same-issues"`
@@ -125,6 +126,8 @@ type Issues struct {
Diff bool `mapstructure:"new"`
NeedFix bool `mapstructure:"fix"`
+
+ ExcludeGeneratedStrict bool `mapstructure:"exclude-generated-strict"` // Deprecated: use ExcludeGenerated instead.
}
func (i *Issues) Validate() error {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/linters_settings.go b/vendor/github.com/golangci/golangci-lint/pkg/config/linters_settings.go
index 1ac90be1d..109de4243 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/linters_settings.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/config/linters_settings.go
@@ -25,9 +25,6 @@ var defaultLintersSettings = LintersSettings{
Dupl: DuplSettings{
Threshold: 150,
},
- Errcheck: ErrcheckSettings{
- Ignore: "fmt:.*",
- },
ErrorLint: ErrorLintSettings{
Errorf: true,
ErrorfMulti: true,
@@ -144,10 +141,12 @@ var defaultLintersSettings = LintersSettings{
NoMixedArgs: true,
KVOnly: false,
AttrOnly: false,
- ContextOnly: false,
+ NoGlobal: "",
+ Context: "",
StaticMsg: false,
NoRawKeys: false,
KeyNamingCase: "",
+ ForbiddenKeys: nil,
ArgsOnSepLines: false,
},
TagAlign: TagAlignSettings{
@@ -243,6 +242,7 @@ type LintersSettings struct {
MaintIdx MaintIdxSettings
Makezero MakezeroSettings
Misspell MisspellSettings
+ Mnd MndSettings
MustTag MustTagSettings
Nakedret NakedretSettings
Nestif NestifSettings
@@ -314,7 +314,8 @@ type BiDiChkSettings struct {
}
type CopyLoopVarSettings struct {
- IgnoreAlias bool `mapstructure:"ignore-alias"`
+ IgnoreAlias bool `mapstructure:"ignore-alias"` // Deprecated: use CheckAlias
+ CheckAlias bool `mapstructure:"check-alias"`
}
type Cyclop struct {
@@ -367,11 +368,13 @@ type ErrcheckSettings struct {
DisableDefaultExclusions bool `mapstructure:"disable-default-exclusions"`
CheckTypeAssertions bool `mapstructure:"check-type-assertions"`
CheckAssignToBlank bool `mapstructure:"check-blank"`
- Ignore string `mapstructure:"ignore"`
ExcludeFunctions []string `mapstructure:"exclude-functions"`
// Deprecated: use ExcludeFunctions instead
Exclude string `mapstructure:"exclude"`
+
+ // Deprecated: use ExcludeFunctions instead
+ Ignore string `mapstructure:"ignore"`
}
type ErrChkJSONSettings struct {
@@ -380,10 +383,17 @@ type ErrChkJSONSettings struct {
}
type ErrorLintSettings struct {
- Errorf bool `mapstructure:"errorf"`
- ErrorfMulti bool `mapstructure:"errorf-multi"`
- Asserts bool `mapstructure:"asserts"`
- Comparison bool `mapstructure:"comparison"`
+ Errorf bool `mapstructure:"errorf"`
+ ErrorfMulti bool `mapstructure:"errorf-multi"`
+ Asserts bool `mapstructure:"asserts"`
+ Comparison bool `mapstructure:"comparison"`
+ AllowedErrors []ErrorLintAllowPair `mapstructure:"allowed-errors"`
+ AllowedErrorsWildcard []ErrorLintAllowPair `mapstructure:"allowed-errors-wildcard"`
+}
+
+type ErrorLintAllowPair struct {
+ Err string `mapstructure:"err"`
+ Fun string `mapstructure:"fun"`
}
type ExhaustiveSettings struct {
@@ -455,6 +465,7 @@ type GciSettings struct {
Sections []string `mapstructure:"sections"`
SkipGenerated bool `mapstructure:"skip-generated"`
CustomOrder bool `mapstructure:"custom-order"`
+ NoLexOrder bool `mapstructure:"no-lex-order"`
// Deprecated: use Sections instead.
LocalPrefixes string `mapstructure:"local-prefixes"`
@@ -549,11 +560,9 @@ type GoImportsSettings struct {
LocalPrefixes string `mapstructure:"local-prefixes"`
}
+// Deprecated: use MndSettings.
type GoMndSettings struct {
- Checks []string `mapstructure:"checks"`
- IgnoredNumbers []string `mapstructure:"ignored-numbers"`
- IgnoredFiles []string `mapstructure:"ignored-files"`
- IgnoredFunctions []string `mapstructure:"ignored-functions"`
+ MndSettings `mapstructure:",squash"`
// Deprecated: use root level settings instead.
Settings map[string]map[string]any
@@ -708,7 +717,7 @@ type MustTagSettings struct {
}
type NakedretSettings struct {
- MaxFuncLines int `mapstructure:"max-func-lines"`
+ MaxFuncLines uint `mapstructure:"max-func-lines"`
}
type NestifSettings struct {
@@ -723,6 +732,13 @@ type NlreturnSettings struct {
BlockSize int `mapstructure:"block-size"`
}
+type MndSettings struct {
+ Checks []string `mapstructure:"checks"`
+ IgnoredNumbers []string `mapstructure:"ignored-numbers"`
+ IgnoredFiles []string `mapstructure:"ignored-files"`
+ IgnoredFunctions []string `mapstructure:"ignored-functions"`
+}
+
type NoLintLintSettings struct {
RequireExplanation bool `mapstructure:"require-explanation"`
RequireSpecific bool `mapstructure:"require-specific"`
@@ -776,8 +792,9 @@ type ReassignSettings struct {
}
type ReviveSettings struct {
- MaxOpenFiles int `mapstructure:"max-open-files"`
- IgnoreGeneratedHeader bool `mapstructure:"ignore-generated-header"`
+ Go string `mapstructure:"-"`
+ MaxOpenFiles int `mapstructure:"max-open-files"`
+ IgnoreGeneratedHeader bool `mapstructure:"ignore-generated-header"`
Confidence float64
Severity string
EnableAllRules bool `mapstructure:"enable-all-rules"`
@@ -801,20 +818,25 @@ type RowsErrCheckSettings struct {
}
type SlogLintSettings struct {
- NoMixedArgs bool `mapstructure:"no-mixed-args"`
- KVOnly bool `mapstructure:"kv-only"`
- NoGlobal string `mapstructure:"no-global"`
- AttrOnly bool `mapstructure:"attr-only"`
- ContextOnly bool `mapstructure:"context-only"`
- StaticMsg bool `mapstructure:"static-msg"`
- NoRawKeys bool `mapstructure:"no-raw-keys"`
- KeyNamingCase string `mapstructure:"key-naming-case"`
- ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"`
+ NoMixedArgs bool `mapstructure:"no-mixed-args"`
+ KVOnly bool `mapstructure:"kv-only"`
+ AttrOnly bool `mapstructure:"attr-only"`
+ NoGlobal string `mapstructure:"no-global"`
+ Context string `mapstructure:"context"`
+ StaticMsg bool `mapstructure:"static-msg"`
+ NoRawKeys bool `mapstructure:"no-raw-keys"`
+ KeyNamingCase string `mapstructure:"key-naming-case"`
+ ForbiddenKeys []string `mapstructure:"forbidden-keys"`
+ ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"`
+
+ // Deprecated: use Context instead.
+ ContextOnly bool `mapstructure:"context-only"`
}
type SpancheckSettings struct {
- Checks []string `mapstructure:"checks"`
- IgnoreCheckSignatures []string `mapstructure:"ignore-check-signatures"`
+ Checks []string `mapstructure:"checks"`
+ IgnoreCheckSignatures []string `mapstructure:"ignore-check-signatures"`
+ ExtraStartSpanSignatures []string `mapstructure:"extra-start-span-signatures"`
}
type StaticCheckSettings struct {
@@ -859,6 +881,15 @@ type TestifylintSettings struct {
ExpVarPattern string `mapstructure:"pattern"`
} `mapstructure:"expected-actual"`
+ Formatter struct {
+ CheckFormatString *bool `mapstructure:"check-format-string"`
+ RequireFFuncs bool `mapstructure:"require-f-funcs"`
+ } `mapstructure:"formatter"`
+
+ GoRequire struct {
+ IgnoreHTTPHandlers bool `mapstructure:"ignore-http-handlers"`
+ } `mapstructure:"go-require"`
+
RequireError struct {
FnPattern string `mapstructure:"fn-pattern"`
} `mapstructure:"require-error"`
@@ -898,11 +929,11 @@ type UseStdlibVarsSettings struct {
TimeLayout bool `mapstructure:"time-layout"`
CryptoHash bool `mapstructure:"crypto-hash"`
DefaultRPCPath bool `mapstructure:"default-rpc-path"`
- OSDevNull bool `mapstructure:"os-dev-null"`
+ OSDevNull bool `mapstructure:"os-dev-null"` // Deprecated
SQLIsolationLevel bool `mapstructure:"sql-isolation-level"`
TLSSignatureScheme bool `mapstructure:"tls-signature-scheme"`
ConstantKind bool `mapstructure:"constant-kind"`
- SyslogPriority bool `mapstructure:"syslog-priority"`
+ SyslogPriority bool `mapstructure:"syslog-priority"` // Deprecated
}
type UnconvertSettings struct {
@@ -918,7 +949,7 @@ type UnparamSettings struct {
type UnusedSettings struct {
FieldWritesAreUses bool `mapstructure:"field-writes-are-uses"`
PostStatementsAreReads bool `mapstructure:"post-statements-are-reads"`
- ExportedIsUsed bool `mapstructure:"exported-is-used"`
+ ExportedIsUsed bool `mapstructure:"exported-is-used"` // Deprecated
ExportedFieldsAreUsed bool `mapstructure:"exported-fields-are-used"`
ParametersAreUsed bool `mapstructure:"parameters-are-used"`
LocalVariablesAreUsed bool `mapstructure:"local-variables-are-used"`
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/loader.go b/vendor/github.com/golangci/golangci-lint/pkg/config/loader.go
index 141137c21..efdbfce1f 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/loader.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/config/loader.go
@@ -6,7 +6,6 @@ import (
"os"
"path/filepath"
"slices"
- "strings"
"github.com/go-viper/mapstructure/v2"
"github.com/mitchellh/go-homedir"
@@ -15,6 +14,7 @@ import (
"github.com/golangci/golangci-lint/pkg/exitcodes"
"github.com/golangci/golangci-lint/pkg/fsutils"
+ "github.com/golangci/golangci-lint/pkg/goutil"
"github.com/golangci/golangci-lint/pkg/logutils"
)
@@ -25,6 +25,11 @@ type LoaderOptions struct {
NoConfig bool // Flag only.
}
+type LoadOptions struct {
+ CheckDeprecation bool
+ Validation bool
+}
+
type Loader struct {
opts LoaderOptions
@@ -33,20 +38,22 @@ type Loader struct {
log logutils.Log
- cfg *Config
+ cfg *Config
+ args []string
}
-func NewLoader(log logutils.Log, v *viper.Viper, fs *pflag.FlagSet, opts LoaderOptions, cfg *Config) *Loader {
+func NewLoader(log logutils.Log, v *viper.Viper, fs *pflag.FlagSet, opts LoaderOptions, cfg *Config, args []string) *Loader {
return &Loader{
opts: opts,
viper: v,
fs: fs,
log: log,
cfg: cfg,
+ args: args,
}
}
-func (l *Loader) Load() error {
+func (l *Loader) Load(opts LoadOptions) error {
err := l.setConfigFile()
if err != nil {
return err
@@ -59,18 +66,32 @@ func (l *Loader) Load() error {
l.applyStringSliceHack()
- err = l.handleDeprecation()
- if err != nil {
- return err
+ if opts.CheckDeprecation {
+ err = l.handleDeprecation()
+ if err != nil {
+ return err
+ }
}
l.handleGoVersion()
+ err = goutil.CheckGoVersion(l.cfg.Run.Go)
+ if err != nil {
+ return err
+ }
+
err = l.handleEnableOnlyOption()
if err != nil {
return err
}
+ if opts.Validation {
+ err = l.cfg.Validate()
+ if err != nil {
+ return err
+ }
+ }
+
return nil
}
@@ -116,50 +137,59 @@ func (l *Loader) evaluateOptions() (string, error) {
}
func (l *Loader) setupConfigFileSearch() {
- firstArg := extractFirstPathArg()
+ l.viper.SetConfigName(".golangci")
+
+ configSearchPaths := l.getConfigSearchPaths()
+
+ l.log.Infof("Config search paths: %s", configSearchPaths)
+
+ for _, p := range configSearchPaths {
+ l.viper.AddConfigPath(p)
+ }
+}
+
+func (l *Loader) getConfigSearchPaths() []string {
+ firstArg := "./..."
+ if len(l.args) > 0 {
+ firstArg = l.args[0]
+ }
- absStartPath, err := filepath.Abs(firstArg)
+ absPath, err := filepath.Abs(firstArg)
if err != nil {
l.log.Warnf("Can't make abs path for %q: %s", firstArg, err)
- absStartPath = filepath.Clean(firstArg)
+ absPath = filepath.Clean(firstArg)
}
// start from it
- var curDir string
- if fsutils.IsDir(absStartPath) {
- curDir = absStartPath
+ var currentDir string
+ if fsutils.IsDir(absPath) {
+ currentDir = absPath
} else {
- curDir = filepath.Dir(absStartPath)
+ currentDir = filepath.Dir(absPath)
}
// find all dirs from it up to the root
- configSearchPaths := []string{"./"}
+ searchPaths := []string{"./"}
for {
- configSearchPaths = append(configSearchPaths, curDir)
+ searchPaths = append(searchPaths, currentDir)
- newCurDir := filepath.Dir(curDir)
- if curDir == newCurDir || newCurDir == "" {
+ parent := filepath.Dir(currentDir)
+ if currentDir == parent || parent == "" {
break
}
- curDir = newCurDir
+ currentDir = parent
}
// find home directory for global config
if home, err := homedir.Dir(); err != nil {
- l.log.Warnf("Can't get user's home directory: %s", err.Error())
- } else if !slices.Contains(configSearchPaths, home) {
- configSearchPaths = append(configSearchPaths, home)
+ l.log.Warnf("Can't get user's home directory: %v", err)
+ } else if !slices.Contains(searchPaths, home) {
+ searchPaths = append(searchPaths, home)
}
- l.log.Infof("Config search paths: %s", configSearchPaths)
-
- l.viper.SetConfigName(".golangci")
-
- for _, p := range configSearchPaths {
- l.viper.AddConfigPath(p)
- }
+ return searchPaths
}
func (l *Loader) parseConfig() error {
@@ -266,7 +296,9 @@ func (l *Loader) handleGoVersion() {
l.cfg.LintersSettings.Gofumpt.LangVersion = l.cfg.Run.Go
}
- trimmedGoVersion := trimGoVersion(l.cfg.Run.Go)
+ trimmedGoVersion := goutil.TrimGoVersion(l.cfg.Run.Go)
+
+ l.cfg.LintersSettings.Revive.Go = trimmedGoVersion
l.cfg.LintersSettings.Gocritic.Go = trimmedGoVersion
@@ -280,38 +312,44 @@ func (l *Loader) handleGoVersion() {
if l.cfg.LintersSettings.Stylecheck.GoVersion == "" {
l.cfg.LintersSettings.Stylecheck.GoVersion = trimmedGoVersion
}
+
+ os.Setenv("GOSECGOVERSION", l.cfg.Run.Go)
}
func (l *Loader) handleDeprecation() error {
+ if l.cfg.InternalTest || l.cfg.InternalCmdTest || os.Getenv(logutils.EnvTestRun) == "1" {
+ return nil
+ }
+
// Deprecated since v1.57.0
if len(l.cfg.Run.SkipFiles) > 0 {
- l.warn("The configuration option `run.skip-files` is deprecated, please use `issues.exclude-files`.")
+ l.log.Warnf("The configuration option `run.skip-files` is deprecated, please use `issues.exclude-files`.")
l.cfg.Issues.ExcludeFiles = l.cfg.Run.SkipFiles
}
// Deprecated since v1.57.0
if len(l.cfg.Run.SkipDirs) > 0 {
- l.warn("The configuration option `run.skip-dirs` is deprecated, please use `issues.exclude-dirs`.")
+ l.log.Warnf("The configuration option `run.skip-dirs` is deprecated, please use `issues.exclude-dirs`.")
l.cfg.Issues.ExcludeDirs = l.cfg.Run.SkipDirs
}
// The 2 options are true by default.
// Deprecated since v1.57.0
if !l.cfg.Run.UseDefaultSkipDirs {
- l.warn("The configuration option `run.skip-dirs-use-default` is deprecated, please use `issues.exclude-dirs-use-default`.")
+ l.log.Warnf("The configuration option `run.skip-dirs-use-default` is deprecated, please use `issues.exclude-dirs-use-default`.")
}
l.cfg.Issues.UseDefaultExcludeDirs = l.cfg.Run.UseDefaultSkipDirs && l.cfg.Issues.UseDefaultExcludeDirs
// The 2 options are false by default.
// Deprecated since v1.57.0
if l.cfg.Run.ShowStats {
- l.warn("The configuration option `run.show-stats` is deprecated, please use `output.show-stats`")
+ l.log.Warnf("The configuration option `run.show-stats` is deprecated, please use `output.show-stats`")
}
l.cfg.Output.ShowStats = l.cfg.Run.ShowStats || l.cfg.Output.ShowStats
// Deprecated since v1.57.0
if l.cfg.Output.Format != "" {
- l.warn("The configuration option `output.format` is deprecated, please use `output.formats`")
+ l.log.Warnf("The configuration option `output.format` is deprecated, please use `output.formats`")
var f OutputFormats
err := f.UnmarshalText([]byte(l.cfg.Output.Format))
@@ -322,58 +360,106 @@ func (l *Loader) handleDeprecation() error {
l.cfg.Output.Formats = f
}
+ for _, format := range l.cfg.Output.Formats {
+ if format.Format == OutFormatGithubActions {
+ l.log.Warnf("The output format `%s` is deprecated, please use `%s`", OutFormatGithubActions, OutFormatColoredLineNumber)
+ break // To avoid repeating the message if there are several usages of github-actions format.
+ }
+ }
+
+ // Deprecated since v1.59.0
+ if l.cfg.Issues.ExcludeGeneratedStrict {
+ l.log.Warnf("The configuration option `issues.exclude-generated-strict` is deprecated, please use `issues.exclude-generated`")
+ l.cfg.Issues.ExcludeGenerated = "strict" // Don't use the constants to avoid cyclic dependencies.
+ }
+
l.handleLinterOptionDeprecations()
return nil
}
+//nolint:gocyclo // the complexity cannot be reduced.
func (l *Loader) handleLinterOptionDeprecations() {
// Deprecated since v1.57.0,
// but it was unofficially deprecated since v1.19 (2019) (https://github.com/golangci/golangci-lint/pull/697).
if l.cfg.LintersSettings.Govet.CheckShadowing {
- l.warn("The configuration option `linters.govet.check-shadowing` is deprecated. " +
+ l.log.Warnf("The configuration option `linters.govet.check-shadowing` is deprecated. " +
"Please enable `shadow` instead, if you are not using `enable-all`.")
}
+ if l.cfg.LintersSettings.CopyLoopVar.IgnoreAlias {
+ l.log.Warnf("The configuration option `linters.copyloopvar.ignore-alias` is deprecated and ignored," +
+ "please use `linters.copyloopvar.check-alias`.")
+ }
+
// Deprecated since v1.42.0.
if l.cfg.LintersSettings.Errcheck.Exclude != "" {
- l.warn("The configuration option `linters.errcheck.exclude` is deprecated, please use `linters.errcheck.exclude-functions`.")
+ l.log.Warnf("The configuration option `linters.errcheck.exclude` is deprecated, please use `linters.errcheck.exclude-functions`.")
+ }
+
+ // Deprecated since v1.59.0,
+ // but it was unofficially deprecated since v1.13 (2018) (https://github.com/golangci/golangci-lint/pull/332).
+ if l.cfg.LintersSettings.Errcheck.Ignore != "" {
+ l.log.Warnf("The configuration option `linters.errcheck.ignore` is deprecated, please use `linters.errcheck.exclude-functions`.")
}
// Deprecated since v1.44.0.
if l.cfg.LintersSettings.Gci.LocalPrefixes != "" {
- l.warn("The configuration option `linters.gci.local-prefixes` is deprecated, please use `prefix()` inside `linters.gci.sections`.")
+ l.log.Warnf("The configuration option `linters.gci.local-prefixes` is deprecated, please use `prefix()` inside `linters.gci.sections`.")
}
// Deprecated since v1.33.0.
if l.cfg.LintersSettings.Godot.CheckAll {
- l.warn("The configuration option `linters.godot.check-all` is deprecated, please use `linters.godot.scope: all`.")
+ l.log.Warnf("The configuration option `linters.godot.check-all` is deprecated, please use `linters.godot.scope: all`.")
}
// Deprecated since v1.44.0.
if len(l.cfg.LintersSettings.Gomnd.Settings) > 0 {
- l.warn("The configuration option `linters.gomnd.settings` is deprecated. Please use the options " +
+ l.log.Warnf("The configuration option `linters.gomnd.settings` is deprecated. Please use the options " +
"`linters.gomnd.checks`,`linters.gomnd.ignored-numbers`,`linters.gomnd.ignored-files`,`linters.gomnd.ignored-functions`.")
}
// Deprecated since v1.47.0
if l.cfg.LintersSettings.Gofumpt.LangVersion != "" {
- l.warn("The configuration option `linters.gofumpt.lang-version` is deprecated, please use global `run.go`.")
+ l.log.Warnf("The configuration option `linters.gofumpt.lang-version` is deprecated, please use global `run.go`.")
}
// Deprecated since v1.47.0
if l.cfg.LintersSettings.Staticcheck.GoVersion != "" {
- l.warn("The configuration option `linters.staticcheck.go` is deprecated, please use global `run.go`.")
+ l.log.Warnf("The configuration option `linters.staticcheck.go` is deprecated, please use global `run.go`.")
}
// Deprecated since v1.47.0
if l.cfg.LintersSettings.Gosimple.GoVersion != "" {
- l.warn("The configuration option `linters.gosimple.go` is deprecated, please use global `run.go`.")
+ l.log.Warnf("The configuration option `linters.gosimple.go` is deprecated, please use global `run.go`.")
}
// Deprecated since v1.47.0
if l.cfg.LintersSettings.Stylecheck.GoVersion != "" {
- l.warn("The configuration option `linters.stylecheck.go` is deprecated, please use global `run.go`.")
+ l.log.Warnf("The configuration option `linters.stylecheck.go` is deprecated, please use global `run.go`.")
+ }
+
+ // Deprecated since v1.60.0
+ if !l.cfg.LintersSettings.Unused.ExportedIsUsed {
+ l.log.Warnf("The configuration option `linters.unused.exported-is-used` is deprecated.")
+ }
+
+ // Deprecated since v1.58.0
+ if l.cfg.LintersSettings.SlogLint.ContextOnly {
+ l.log.Warnf("The configuration option `linters.sloglint.context-only` is deprecated, please use `linters.sloglint.context`.")
+ if l.cfg.LintersSettings.SlogLint.Context == "" {
+ l.cfg.LintersSettings.SlogLint.Context = "all"
+ }
+ }
+
+ // Deprecated since v1.51.0
+ if l.cfg.LintersSettings.UseStdlibVars.OSDevNull {
+ l.log.Warnf("The configuration option `linters.usestdlibvars.os-dev-null` is deprecated.")
+ }
+
+ // Deprecated since v1.51.0
+ if l.cfg.LintersSettings.UseStdlibVars.SyslogPriority {
+ l.log.Warnf("The configuration option `linters.usestdlibvars.syslog-priority` is deprecated.")
}
}
@@ -398,14 +484,6 @@ func (l *Loader) handleEnableOnlyOption() error {
return nil
}
-func (l *Loader) warn(format string) {
- if l.cfg.InternalTest || l.cfg.InternalCmdTest || os.Getenv(logutils.EnvTestRun) == "1" {
- return
- }
-
- l.log.Warnf(format)
-}
-
func customDecoderHook() viper.DecoderConfigOption {
return viper.DecodeHook(mapstructure.ComposeDecodeHookFunc(
// Default hooks (https://github.com/spf13/viper/blob/518241257478c557633ab36e474dfcaeb9a3c623/viper.go#L135-L138).
@@ -416,28 +494,3 @@ func customDecoderHook() viper.DecoderConfigOption {
mapstructure.TextUnmarshallerHookFunc(),
))
}
-
-func extractFirstPathArg() string {
- args := os.Args
-
- // skip all args ([golangci-lint, run/linters]) before files/dirs list
- for len(args) != 0 {
- if args[0] == "run" {
- args = args[1:]
- break
- }
-
- args = args[1:]
- }
-
- // find first file/dir arg
- firstArg := "./..."
- for _, arg := range args {
- if !strings.HasPrefix(arg, "-") {
- firstArg = arg
- break
- }
- }
-
- return firstArg
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/config/output.go b/vendor/github.com/golangci/golangci-lint/pkg/config/output.go
index a005213cf..6a26d5773 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/config/output.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/config/output.go
@@ -17,8 +17,10 @@ const (
OutFormatCodeClimate = "code-climate"
OutFormatHTML = "html"
OutFormatJunitXML = "junit-xml"
- OutFormatGithubActions = "github-actions"
+ OutFormatJunitXMLExtended = "junit-xml-extended"
+ OutFormatGithubActions = "github-actions" // Deprecated
OutFormatTeamCity = "teamcity"
+ OutFormatSarif = "sarif"
)
var AllOutputFormats = []string{
@@ -31,8 +33,10 @@ var AllOutputFormats = []string{
OutFormatCodeClimate,
OutFormatHTML,
OutFormatJunitXML,
+ OutFormatJunitXMLExtended,
OutFormatGithubActions,
OutFormatTeamCity,
+ OutFormatSarif,
}
type Output struct {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/linter.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/linter.go
index f8ca2e755..13d3a09a5 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/linter.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/linter.go
@@ -102,7 +102,7 @@ func (lnt *Linter) allAnalyzerNames() []string {
return ret
}
-func (lnt *Linter) configureAnalyzer(a *analysis.Analyzer, cfg map[string]any) error {
+func (*Linter) configureAnalyzer(a *analysis.Analyzer, cfg map[string]any) error {
for k, v := range cfg {
f := a.Flags.Lookup(k)
if f == nil {
@@ -116,7 +116,7 @@ func (lnt *Linter) configureAnalyzer(a *analysis.Analyzer, cfg map[string]any) e
}
if err := f.Value.Set(valueToString(v)); err != nil {
- return fmt.Errorf("failed to set analyzer setting %q with value %v: %w", k, v, err)
+ return fmt.Errorf("failed to set analyzer setting %q with value %q: %w", k, v, err)
}
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/metalinter.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/metalinter.go
index 333ab20f1..c2a794997 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/metalinter.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/metalinter.go
@@ -31,11 +31,11 @@ func (ml MetaLinter) Run(_ context.Context, lintCtx *linter.Context) ([]result.I
return runAnalyzers(ml, lintCtx)
}
-func (ml MetaLinter) Name() string {
+func (MetaLinter) Name() string {
return "goanalysis_metalinter"
}
-func (ml MetaLinter) Desc() string {
+func (MetaLinter) Desc() string {
return ""
}
@@ -57,11 +57,11 @@ func (ml MetaLinter) getAnalyzers() []*analysis.Analyzer {
return allAnalyzers
}
-func (ml MetaLinter) getName() string {
+func (MetaLinter) getName() string {
return "metalinter"
}
-func (ml MetaLinter) useOriginalPackages() bool {
+func (MetaLinter) useOriginalPackages() bool {
return false // `unused` can't be run by this metalinter
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/errors.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/errors.go
index f59e02cc6..7da659e80 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/errors.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/errors.go
@@ -1,4 +1,4 @@
-package goanalysis
+package pkgerrors
import (
"errors"
@@ -7,7 +7,6 @@ import (
"golang.org/x/tools/go/packages"
"github.com/golangci/golangci-lint/pkg/lint/linter"
- libpackages "github.com/golangci/golangci-lint/pkg/packages"
"github.com/golangci/golangci-lint/pkg/result"
)
@@ -19,15 +18,13 @@ func (e *IllTypedError) Error() string {
return fmt.Sprintf("errors in package: %v", e.Pkg.Errors)
}
-func buildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]result.Issue, error) {
+func BuildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]result.Issue, error) {
var issues []result.Issue
uniqReportedIssues := map[string]bool{}
var other error
for _, err := range errs {
- err := err
-
var ill *IllTypedError
if !errors.As(err, &ill) {
if other == nil {
@@ -36,8 +33,8 @@ func buildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]resu
continue
}
- for _, err := range libpackages.ExtractErrors(ill.Pkg) {
- i, perr := parseError(err)
+ for _, err := range extractErrors(ill.Pkg) {
+ issue, perr := parseError(err)
if perr != nil { // failed to parse
if uniqReportedIssues[err.Msg] {
continue
@@ -45,8 +42,8 @@ func buildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]resu
uniqReportedIssues[err.Msg] = true
lintCtx.Log.Errorf("typechecking error: %s", err.Msg)
} else {
- i.Pkg = ill.Pkg // to save to cache later
- issues = append(issues, *i)
+ issue.Pkg = ill.Pkg // to save to cache later
+ issues = append(issues, *issue)
}
}
}
@@ -57,16 +54,3 @@ func buildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]resu
return issues, nil
}
-
-func parseError(srcErr packages.Error) (*result.Issue, error) {
- pos, err := libpackages.ParseErrorPosition(srcErr.Pos)
- if err != nil {
- return nil, err
- }
-
- return &result.Issue{
- Pos: *pos,
- Text: srcErr.Msg,
- FromLinter: "typecheck",
- }, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/packages/util.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/extract.go
index 6a7789ebb..d1257e663 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/packages/util.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/extract.go
@@ -1,4 +1,4 @@
-package packages
+package pkgerrors
import (
"fmt"
@@ -12,7 +12,7 @@ import (
// ex: `/example/main.go:11:17: foobar`
var reFile = regexp.MustCompile(`^.+\.go:\d+:\d+: .+`)
-func ExtractErrors(pkg *packages.Package) []packages.Error {
+func extractErrors(pkg *packages.Package) []packages.Error {
errors := extractErrorsImpl(pkg, map[*packages.Package]bool{})
if len(errors) == 0 {
return errors
@@ -38,7 +38,7 @@ func ExtractErrors(pkg *packages.Package) []packages.Error {
if len(pkg.GoFiles) != 0 {
// errors were extracted from deps and have at least one file in package
for i := range uniqErrors {
- if _, parseErr := ParseErrorPosition(uniqErrors[i].Pos); parseErr == nil {
+ if _, parseErr := parseErrorPosition(uniqErrors[i].Pos); parseErr == nil {
continue
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/packages/errors.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/parse.go
index ff37651af..b25b50f71 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/packages/errors.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors/parse.go
@@ -1,4 +1,4 @@
-package packages
+package pkgerrors
import (
"errors"
@@ -6,9 +6,26 @@ import (
"go/token"
"strconv"
"strings"
+
+ "golang.org/x/tools/go/packages"
+
+ "github.com/golangci/golangci-lint/pkg/result"
)
-func ParseErrorPosition(pos string) (*token.Position, error) {
+func parseError(srcErr packages.Error) (*result.Issue, error) {
+ pos, err := parseErrorPosition(srcErr.Pos)
+ if err != nil {
+ return nil, err
+ }
+
+ return &result.Issue{
+ Pos: *pos,
+ Text: srcErr.Msg,
+ FromLinter: "typecheck",
+ }, nil
+}
+
+func parseErrorPosition(pos string) (*token.Position, error) {
// file:line(<optional>:colon)
parts := strings.Split(pos, ":")
if len(parts) == 1 {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go
index 6b57cb0c9..58ea297ea 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go
@@ -15,6 +15,7 @@ import (
"github.com/golangci/golangci-lint/internal/errorutil"
"github.com/golangci/golangci-lint/internal/pkgcache"
+ "github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors"
)
type actionAllocator struct {
@@ -184,7 +185,7 @@ func (act *action) analyze() {
// It looks like there should be !pass.Analyzer.RunDespiteErrors
// but govet's cgocall crashes on it. Govet itself contains !pass.Analyzer.RunDespiteErrors condition here,
// but it exits before it if packages.Load have failed.
- act.err = fmt.Errorf("analysis skipped: %w", &IllTypedError{Pkg: act.pkg})
+ act.err = fmt.Errorf("analysis skipped: %w", &pkgerrors.IllTypedError{Pkg: act.pkg})
} else {
startedAt = time.Now()
act.result, act.err = pass.Analyzer.Run(pass)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go
index c54357eb6..8abe2b6c1 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go
@@ -16,6 +16,7 @@ import (
"golang.org/x/tools/go/packages"
"github.com/golangci/golangci-lint/pkg/goanalysis/load"
+ "github.com/golangci/golangci-lint/pkg/goutil"
"github.com/golangci/golangci-lint/pkg/logutils"
)
@@ -150,12 +151,21 @@ func (lp *loadingPackage) loadFromSource(loadMode LoadMode) error {
}
return imp.Types, nil
}
+
+ // TODO(ldez) temporary workaround
+ rv, err := goutil.CleanRuntimeVersion()
+ if err != nil {
+ return err
+ }
+
tc := &types.Config{
Importer: importerFunc(importer),
Error: func(err error) {
pkg.Errors = append(pkg.Errors, lp.convertError(err)...)
},
+ GoVersion: rv, // TODO(ldez) temporary workaround
}
+
_ = types.NewChecker(tc, pkg.Fset, pkg.Types, pkg.TypesInfo).Files(pkg.Syntax)
// Don't handle error here: errors are adding by tc.Error function.
@@ -470,7 +480,7 @@ func sizeOfReflectValueTreeBytes(rv reflect.Value, visitedPtrs map[uintptr]struc
return sizeOfReflectValueTreeBytes(rv.Elem(), visitedPtrs)
case reflect.Struct:
ret := 0
- for i := 0; i < rv.NumField(); i++ {
+ for i := range rv.NumField() {
ret += sizeOfReflectValueTreeBytes(rv.Field(i), visitedPtrs)
}
return ret
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners.go b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners.go
index b832fc32d..79e52f52a 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/goanalysis/runners.go
@@ -13,6 +13,7 @@ import (
"golang.org/x/tools/go/packages"
"github.com/golangci/golangci-lint/internal/pkgcache"
+ "github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/logutils"
"github.com/golangci/golangci-lint/pkg/result"
@@ -74,7 +75,7 @@ func runAnalyzers(cfg runAnalyzersConfig, lintCtx *linter.Context) ([]result.Iss
return retIssues
}
- errIssues, err := buildIssuesFromIllTypedError(errs, lintCtx)
+ errIssues, err := pkgerrors.BuildIssuesFromIllTypedError(errs, lintCtx)
if err != nil {
return nil, err
}
@@ -133,7 +134,7 @@ func saveIssuesToCache(allPkgs []*packages.Package, pkgsFromCache map[*packages.
perPkgIssues[i.Pkg] = append(perPkgIssues[i.Pkg], *i)
}
- savedIssuesCount := int32(0)
+ var savedIssuesCount int64 = 0
lintResKey := getIssuesCacheKey(analyzers)
workerCount := runtime.GOMAXPROCS(-1)
@@ -161,7 +162,7 @@ func saveIssuesToCache(allPkgs []*packages.Package, pkgsFromCache map[*packages.
})
}
- atomic.AddInt32(&savedIssuesCount, int32(len(encodedIssues)))
+ atomic.AddInt64(&savedIssuesCount, int64(len(encodedIssues)))
if err := lintCtx.PkgCache.Put(pkg, pkgcache.HashModeNeedAllDeps, lintResKey, encodedIssues); err != nil {
lintCtx.Log.Infof("Failed to save package %s issues (%d) to cache: %s", pkg, len(pkgIssues), err)
} else {
@@ -204,7 +205,7 @@ func loadIssuesFromCache(pkgs []*packages.Package, lintCtx *linter.Context,
wg.Add(workerCount)
pkgCh := make(chan *packages.Package, len(pkgs))
- for i := 0; i < workerCount; i++ {
+ for range workerCount {
go func() {
defer wg.Done()
for pkg := range pkgCh {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/asasalint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/asasalint/asasalint.go
index d783d3365..653a2d514 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/asasalint.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/asasalint/asasalint.go
@@ -1,4 +1,4 @@
-package golinters
+package asasalint
import (
"github.com/alingse/asasalint"
@@ -9,7 +9,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/internal"
)
-func NewAsasalint(setting *config.AsasalintSettings) *goanalysis.Linter {
+func New(setting *config.AsasalintSettings) *goanalysis.Linter {
cfg := asasalint.LinterSetting{}
if setting != nil {
cfg.Exclude = setting.Exclude
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/asciicheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/asciicheck/asciicheck.go
index 64c2e1fb3..675dfc478 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/asciicheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/asciicheck/asciicheck.go
@@ -1,4 +1,4 @@
-package golinters
+package asciicheck
import (
"github.com/tdakkota/asciicheck"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewAsciicheck() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := asciicheck.NewAnalyzer()
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/bidichk.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/bidichk/bidichk.go
index 62c60e8ce..4ced901e8 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/bidichk.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/bidichk/bidichk.go
@@ -1,4 +1,4 @@
-package golinters
+package bidichk
import (
"strings"
@@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewBiDiChk(cfg *config.BiDiChkSettings) *goanalysis.Linter {
+func New(cfg *config.BiDiChkSettings) *goanalysis.Linter {
a := bidichk.NewAnalyzer()
cfgMap := map[string]map[string]any{}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/bodyclose.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/bodyclose/bodyclose.go
index 97c768de1..f39814edc 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/bodyclose.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/bodyclose/bodyclose.go
@@ -1,4 +1,4 @@
-package golinters
+package bodyclose
import (
"github.com/timakin/bodyclose/passes/bodyclose"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewBodyclose() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := bodyclose.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/canonicalheader/canonicalheader.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/canonicalheader/canonicalheader.go
new file mode 100644
index 000000000..d721916a4
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/canonicalheader/canonicalheader.go
@@ -0,0 +1,19 @@
+package canonicalheader
+
+import (
+ "github.com/lasiar/canonicalheader"
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/golangci/golangci-lint/pkg/goanalysis"
+)
+
+func New() *goanalysis.Linter {
+ a := canonicalheader.Analyzer
+
+ return goanalysis.NewLinter(
+ a.Name,
+ a.Doc,
+ []*analysis.Analyzer{a},
+ nil,
+ ).WithLoadMode(goanalysis.LoadModeTypesInfo)
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/containedctx.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/containedctx/containedctx.go
index ac2d96ef6..6fdb4ea6e 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/containedctx.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/containedctx/containedctx.go
@@ -1,4 +1,4 @@
-package golinters
+package containedctx
import (
"github.com/sivchari/containedctx"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewContainedCtx() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := containedctx.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/contextcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/contextcheck/contextcheck.go
index 0ab5750da..a34c518b2 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/contextcheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/contextcheck/contextcheck.go
@@ -1,4 +1,4 @@
-package golinters
+package contextcheck
import (
"github.com/kkHAIKE/contextcheck"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/linter"
)
-func NewContextCheck() *goanalysis.Linter {
+func New() *goanalysis.Linter {
analyzer := contextcheck.NewAnalyzer(contextcheck.Configuration{})
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/copyloopvar.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/copyloopvar/copyloopvar.go
index fa49cbd84..adb4ee728 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/copyloopvar.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/copyloopvar/copyloopvar.go
@@ -1,4 +1,4 @@
-package golinters
+package copyloopvar
import (
"github.com/karamaru-alpha/copyloopvar"
@@ -8,14 +8,14 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewCopyLoopVar(settings *config.CopyLoopVarSettings) *goanalysis.Linter {
+func New(settings *config.CopyLoopVarSettings) *goanalysis.Linter {
a := copyloopvar.NewAnalyzer()
var cfg map[string]map[string]any
if settings != nil {
cfg = map[string]map[string]any{
a.Name: {
- "ignore-alias": settings.IgnoreAlias,
+ "check-alias": settings.CheckAlias,
},
}
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/cyclop.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/cyclop/cyclop.go
index 2b4a4a0ba..eb8c0577a 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/cyclop.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/cyclop/cyclop.go
@@ -1,4 +1,4 @@
-package golinters
+package cyclop
import (
"github.com/bkielbasa/cyclop/pkg/analyzer"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewCyclop(settings *config.Cyclop) *goanalysis.Linter {
+func New(settings *config.Cyclop) *goanalysis.Linter {
a := analyzer.NewAnalyzer()
var cfg map[string]map[string]any
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/decorder.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/decorder/decorder.go
index e41482ee1..a05f6a325 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/decorder.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/decorder/decorder.go
@@ -1,4 +1,4 @@
-package golinters
+package decorder
import (
"strings"
@@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewDecorder(settings *config.DecorderSettings) *goanalysis.Linter {
+func New(settings *config.DecorderSettings) *goanalysis.Linter {
a := decorder.Analyzer
// disable all rules/checks by default
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/depguard.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/depguard/depguard.go
index 484d33d72..d2aedf252 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/depguard.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/depguard/depguard.go
@@ -1,4 +1,4 @@
-package golinters
+package depguard
import (
"github.com/OpenPeeDeeP/depguard/v2"
@@ -9,7 +9,7 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/linter"
)
-func NewDepguard(settings *config.DepGuardSettings) *goanalysis.Linter {
+func New(settings *config.DepGuardSettings) *goanalysis.Linter {
conf := depguard.LinterSettings{}
if settings != nil {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dogsled.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/dogsled/dogsled.go
index 11a3c3a9f..49108f4f1 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dogsled.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/dogsled/dogsled.go
@@ -1,4 +1,4 @@
-package golinters
+package dogsled
import (
"fmt"
@@ -14,14 +14,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const dogsledName = "dogsled"
+const linterName = "dogsled"
-func NewDogsled(settings *config.DogsledSettings) *goanalysis.Linter {
+func New(settings *config.DogsledSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: dogsledName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues := runDogsled(pass, settings)
@@ -39,7 +39,7 @@ func NewDogsled(settings *config.DogsledSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- dogsledName,
+ linterName,
"Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())",
[]*analysis.Analyzer{analyzer},
nil,
@@ -100,7 +100,7 @@ func (v *returnsVisitor) Visit(node ast.Node) ast.Visitor {
if numBlank > v.maxBlanks {
v.issues = append(v.issues, result.Issue{
- FromLinter: dogsledName,
+ FromLinter: linterName,
Text: fmt.Sprintf("declaration has %v blank identifiers", numBlank),
Pos: v.f.Position(assgnStmt.Pos()),
})
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl/dupl.go
index 9ec5d3808..7abcb4c4f 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl/dupl.go
@@ -1,4 +1,4 @@
-package golinters
+package dupl
import (
"fmt"
@@ -16,14 +16,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const duplName = "dupl"
+const linterName = "dupl"
-func NewDupl(settings *config.DuplSettings) *goanalysis.Linter {
+func New(settings *config.DuplSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: duplName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runDupl(pass, settings)
@@ -44,7 +44,7 @@ func NewDupl(settings *config.DuplSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- duplName,
+ linterName,
"Tool for code clone detection",
[]*analysis.Analyzer{analyzer},
nil,
@@ -88,7 +88,7 @@ func runDupl(pass *analysis.Pass, settings *config.DuplSettings) ([]goanalysis.I
To: i.From.LineEnd(),
},
Text: text,
- FromLinter: duplName,
+ FromLinter: linterName,
}, pass))
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupword.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupword/dupword.go
index 3d5242696..bba4fc9e1 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupword.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupword/dupword.go
@@ -1,4 +1,4 @@
-package golinters
+package dupword
import (
"strings"
@@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewDupWord(setting *config.DupWordSettings) *goanalysis.Linter {
+func New(setting *config.DupWordSettings) *goanalysis.Linter {
a := dupword.NewAnalyzer()
cfgMap := map[string]map[string]any{}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/durationcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/durationcheck/durationcheck.go
index c33247765..88f22c27c 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/durationcheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/durationcheck/durationcheck.go
@@ -1,4 +1,4 @@
-package golinters
+package durationcheck
import (
"github.com/charithe/durationcheck"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewDurationCheck() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := durationcheck.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goerr113.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/err113/err113.go
index a304cbe54..2600128be 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goerr113.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/err113/err113.go
@@ -1,4 +1,4 @@
-package golinters
+package err113
import (
"github.com/Djarvur/go-err113"
@@ -7,11 +7,13 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewGoerr113() *goanalysis.Linter {
+func New() *goanalysis.Linter {
+ a := err113.NewAnalyzer()
+
return goanalysis.NewLinter(
- "goerr113",
+ a.Name,
"Go linter to check the errors handling expressions",
- []*analysis.Analyzer{err113.NewAnalyzer()},
+ []*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errcheck/errcheck.go
index b945012ed..9a8a2aa87 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errcheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errcheck/errcheck.go
@@ -1,4 +1,4 @@
-package golinters
+package errcheck
import (
"bufio"
@@ -22,20 +22,20 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const errcheckName = "errcheck"
+const linterName = "errcheck"
-func NewErrcheck(settings *config.ErrcheckSettings) *goanalysis.Linter {
+func New(settings *config.ErrcheckSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: errcheckName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: goanalysis.DummyRun,
}
return goanalysis.NewLinter(
- errcheckName,
+ linterName,
"errcheck is a program for checking for unchecked errors in Go code. "+
"These unchecked errors can be critical bugs in some cases",
[]*analysis.Analyzer{analyzer},
@@ -100,7 +100,7 @@ func runErrCheck(lintCtx *linter.Context, pass *analysis.Pass, checker *errcheck
issues[i] = goanalysis.NewIssue(
&result.Issue{
- FromLinter: errcheckName,
+ FromLinter: linterName,
Text: text,
Pos: err.Pos,
},
@@ -254,6 +254,7 @@ func readExcludeFile(name string) ([]string, error) {
if fh == nil {
return nil, fmt.Errorf("failed reading exclude file: %s: %w", name, err)
}
+ defer func() { _ = fh.Close() }()
scanner := bufio.NewScanner(fh)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errchkjson.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errchkjson/errchkjson.go
index 641e87010..8389a750c 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errchkjson.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errchkjson/errchkjson.go
@@ -1,4 +1,4 @@
-package golinters
+package errchkjson
import (
"github.com/breml/errchkjson"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewErrChkJSON(cfg *config.ErrChkJSONSettings) *goanalysis.Linter {
+func New(cfg *config.ErrChkJSONSettings) *goanalysis.Linter {
a := errchkjson.NewAnalyzer()
cfgMap := map[string]map[string]any{}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errname.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errname/errname.go
index ce64f374c..f868854c1 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errname.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errname/errname.go
@@ -1,4 +1,4 @@
-package golinters
+package errname
import (
"github.com/Antonboom/errname/pkg/analyzer"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewErrName() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := analyzer.New()
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errorlint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errorlint/errorlint.go
index adc3eadf2..86db8552d 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/errorlint.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/errorlint/errorlint.go
@@ -1,4 +1,4 @@
-package golinters
+package errorlint
import (
"github.com/polyfloyd/go-errorlint/errorlint"
@@ -8,8 +8,22 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewErrorLint(cfg *config.ErrorLintSettings) *goanalysis.Linter {
- a := errorlint.NewAnalyzer()
+func New(cfg *config.ErrorLintSettings) *goanalysis.Linter {
+ var opts []errorlint.Option
+
+ if cfg != nil {
+ ae := toAllowPairs(cfg.AllowedErrors)
+ if len(ae) > 0 {
+ opts = append(opts, errorlint.WithAllowedErrors(ae))
+ }
+
+ aew := toAllowPairs(cfg.AllowedErrorsWildcard)
+ if len(aew) > 0 {
+ opts = append(opts, errorlint.WithAllowedWildcard(aew))
+ }
+ }
+
+ a := errorlint.NewAnalyzer(opts...)
cfgMap := map[string]map[string]any{}
@@ -30,3 +44,11 @@ func NewErrorLint(cfg *config.ErrorLintSettings) *goanalysis.Linter {
cfgMap,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}
+
+func toAllowPairs(data []config.ErrorLintAllowPair) []errorlint.AllowPair {
+ var pairs []errorlint.AllowPair
+ for _, allowedError := range data {
+ pairs = append(pairs, errorlint.AllowPair(allowedError))
+ }
+ return pairs
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/execinquery.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/execinquery/execinquery.go
index 6c5bcb631..3832873c6 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/execinquery.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/execinquery/execinquery.go
@@ -1,4 +1,4 @@
-package golinters
+package execinquery
import (
"github.com/lufeee/execinquery"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewExecInQuery() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := execinquery.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustive.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustive/exhaustive.go
index 6280cbb56..9249efb69 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustive.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustive/exhaustive.go
@@ -1,4 +1,4 @@
-package golinters
+package exhaustive
import (
"github.com/nishanths/exhaustive"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewExhaustive(settings *config.ExhaustiveSettings) *goanalysis.Linter {
+func New(settings *config.ExhaustiveSettings) *goanalysis.Linter {
a := exhaustive.Analyzer
var cfg map[string]map[string]any
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustruct.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustruct/exhaustruct.go
index 4621b7bf5..53ad87154 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustruct.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/exhaustruct/exhaustruct.go
@@ -1,4 +1,4 @@
-package golinters
+package exhaustruct
import (
"github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer"
@@ -9,7 +9,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/internal"
)
-func NewExhaustruct(settings *config.ExhaustructSettings) *goanalysis.Linter {
+func New(settings *config.ExhaustructSettings) *goanalysis.Linter {
var include, exclude []string
if settings != nil {
include = settings.Include
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exportloopref.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/exportloopref/exportloopref.go
index 30bdeedaa..e232f8045 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/exportloopref.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/exportloopref/exportloopref.go
@@ -1,4 +1,4 @@
-package golinters
+package exportloopref
import (
"github.com/kyoh86/exportloopref"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewExportLoopRef() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := exportloopref.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/fatcontext/fatcontext.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/fatcontext/fatcontext.go
new file mode 100644
index 000000000..378025a8c
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/fatcontext/fatcontext.go
@@ -0,0 +1,19 @@
+package fatcontext
+
+import (
+ "github.com/Crocmagnon/fatcontext/pkg/analyzer"
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/golangci/golangci-lint/pkg/goanalysis"
+)
+
+func New() *goanalysis.Linter {
+ a := analyzer.Analyzer
+
+ return goanalysis.NewLinter(
+ a.Name,
+ a.Doc,
+ []*analysis.Analyzer{a},
+ nil,
+ ).WithLoadMode(goanalysis.LoadModeTypesInfo)
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/forbidigo.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/forbidigo/forbidigo.go
index 194d4fa03..3572b60c2 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/forbidigo.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/forbidigo/forbidigo.go
@@ -1,4 +1,4 @@
-package golinters
+package forbidigo
import (
"fmt"
@@ -14,14 +14,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const forbidigoName = "forbidigo"
+const linterName = "forbidigo"
-func NewForbidigo(settings *config.ForbidigoSettings) *goanalysis.Linter {
+func New(settings *config.ForbidigoSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: forbidigoName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runForbidigo(pass, settings)
@@ -44,7 +44,7 @@ func NewForbidigo(settings *config.ForbidigoSettings) *goanalysis.Linter {
// But we cannot make this depend on the settings and have to mirror the mode chosen in GetAllSupportedLinterConfigs,
// therefore we have to use LoadModeTypesInfo in all cases.
return goanalysis.NewLinter(
- forbidigoName,
+ linterName,
"Forbids identifiers",
[]*analysis.Analyzer{analyzer},
nil,
@@ -73,7 +73,7 @@ func runForbidigo(pass *analysis.Pass, settings *config.ForbidigoSettings) ([]go
forbid, err := forbidigo.NewLinter(patterns, options...)
if err != nil {
- return nil, fmt.Errorf("failed to create linter %q: %w", forbidigoName, err)
+ return nil, fmt.Errorf("failed to create linter %q: %w", linterName, err)
}
var issues []goanalysis.Issue
@@ -94,7 +94,7 @@ func runForbidigo(pass *analysis.Pass, settings *config.ForbidigoSettings) ([]go
issues = append(issues, goanalysis.NewIssue(&result.Issue{
Pos: hint.Position(),
Text: hint.Details(),
- FromLinter: forbidigoName,
+ FromLinter: linterName,
}, pass))
}
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert/forcetypeassert.go
index 574e53c71..741b57cea 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert/forcetypeassert.go
@@ -1,4 +1,4 @@
-package golinters
+package forcetypeassert
import (
"github.com/gostaticanalysis/forcetypeassert"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewForceTypeAssert() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := forcetypeassert.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/funlen.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/funlen/funlen.go
index 084028a75..e43339394 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/funlen.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/funlen/funlen.go
@@ -1,4 +1,4 @@
-package golinters
+package funlen
import (
"go/token"
@@ -14,14 +14,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const funlenName = "funlen"
+const linterName = "funlen"
-func NewFunlen(settings *config.FunlenSettings) *goanalysis.Linter {
+func New(settings *config.FunlenSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: funlenName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues := runFunlen(pass, settings)
@@ -39,7 +39,7 @@ func NewFunlen(settings *config.FunlenSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- funlenName,
+ linterName,
"Tool for detection of long functions",
[]*analysis.Analyzer{analyzer},
nil,
@@ -67,7 +67,7 @@ func runFunlen(pass *analysis.Pass, settings *config.FunlenSettings) []goanalysi
Line: i.Pos.Line,
},
Text: strings.TrimRight(i.Message, "\n"),
- FromLinter: funlenName,
+ FromLinter: linterName,
}, pass)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gci.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gci/gci.go
index 7f869930c..a9afb6c89 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gci.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gci/gci.go
@@ -1,13 +1,17 @@
-package golinters
+package gci
import (
"fmt"
+ "sort"
+ "strings"
"sync"
gcicfg "github.com/daixiang0/gci/pkg/config"
"github.com/daixiang0/gci/pkg/gci"
"github.com/daixiang0/gci/pkg/io"
"github.com/daixiang0/gci/pkg/log"
+ "github.com/daixiang0/gci/pkg/section"
+ "github.com/golangci/modinfo"
"github.com/hexops/gotextdiff"
"github.com/hexops/gotextdiff/myers"
"github.com/hexops/gotextdiff/span"
@@ -19,16 +23,19 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/linter"
)
-const gciName = "gci"
+const linterName = "gci"
-func NewGci(settings *config.GciSettings) *goanalysis.Linter {
+func New(settings *config.GciSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: gciName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: goanalysis.DummyRun,
+ Requires: []*analysis.Analyzer{
+ modinfo.Analyzer,
+ },
}
var cfg *gcicfg.Config
@@ -37,6 +44,7 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter {
Cfg: gcicfg.BoolConfig{
SkipGenerated: settings.SkipGenerated,
CustomOrder: settings.CustomOrder,
+ NoLexOrder: settings.NoLexOrder,
},
SectionStrings: settings.Sections,
}
@@ -47,7 +55,7 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter {
}
var err error
- cfg, err = rawCfg.Parse()
+ cfg, err = YamlConfig{origin: rawCfg}.Parse()
if err != nil {
internal.LinterLogger.Fatalf("gci: configuration parsing: %v", err)
}
@@ -56,12 +64,18 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter {
var lock sync.Mutex
return goanalysis.NewLinter(
- gciName,
+ linterName,
"Gci controls Go package import order and makes it always deterministic.",
[]*analysis.Analyzer{analyzer},
nil,
).WithContextSetter(func(lintCtx *linter.Context) {
analyzer.Run = func(pass *analysis.Pass) (any, error) {
+ var err error
+ cfg.Sections, err = hackSectionList(pass, cfg)
+ if err != nil {
+ return nil, err
+ }
+
issues, err := runGci(pass, lintCtx, cfg, &lock)
if err != nil {
return nil, err
@@ -98,7 +112,7 @@ func runGci(pass *analysis.Pass, lintCtx *linter.Context, cfg *gcicfg.Config, lo
continue
}
- is, err := internal.ExtractIssuesFromPatch(diff, lintCtx, gciName, getIssuedTextGci)
+ is, err := internal.ExtractIssuesFromPatch(diff, lintCtx, linterName, getIssuedTextGci)
if err != nil {
return nil, fmt.Errorf("can't extract issues from gci diff output %s: %w", diff, err)
}
@@ -111,6 +125,57 @@ func runGci(pass *analysis.Pass, lintCtx *linter.Context, cfg *gcicfg.Config, lo
return issues, nil
}
+func getIssuedTextGci(settings *config.LintersSettings) string {
+ text := "File is not `gci`-ed"
+
+ hasOptions := settings.Gci.SkipGenerated || len(settings.Gci.Sections) > 0
+ if !hasOptions {
+ return text
+ }
+
+ text += " with"
+
+ if settings.Gci.SkipGenerated {
+ text += " --skip-generated"
+ }
+
+ if len(settings.Gci.Sections) > 0 {
+ for _, sect := range settings.Gci.Sections {
+ text += " -s " + sect
+ }
+ }
+
+ if settings.Gci.CustomOrder {
+ text += " --custom-order"
+ }
+
+ return text
+}
+
+func hackSectionList(pass *analysis.Pass, cfg *gcicfg.Config) (section.SectionList, error) {
+ var sections section.SectionList
+
+ for _, sect := range cfg.Sections {
+ // local module hack
+ if v, ok := sect.(*section.LocalModule); ok {
+ info, err := modinfo.FindModuleFromPass(pass)
+ if err != nil {
+ return nil, err
+ }
+
+ if info.Path == "" {
+ continue
+ }
+
+ v.Path = info.Path
+ }
+
+ sections = append(sections, sect)
+ }
+
+ return sections, nil
+}
+
// diffFormattedFilesToArray is a copy of gci.DiffFormattedFilesToArray without io.StdInGenerator.
// gci.DiffFormattedFilesToArray uses gci.processStdInAndGoFilesInPaths that uses io.StdInGenerator but stdin is not active on CI.
// https://github.com/daixiang0/gci/blob/6f5cb16718ba07f0342a58de9b830ec5a6d58790/pkg/gci/gci.go#L63-L75
@@ -130,29 +195,56 @@ func diffFormattedFilesToArray(paths []string, cfg gcicfg.Config, diffs *[]strin
})
}
-func getIssuedTextGci(settings *config.LintersSettings) string {
- text := "File is not `gci`-ed"
+// Code below this comment is borrowed and modified from gci.
+// https://github.com/daixiang0/gci/blob/v0.13.5/pkg/config/config.go
+
+var defaultOrder = map[string]int{
+ section.StandardType: 0,
+ section.DefaultType: 1,
+ section.CustomType: 2,
+ section.BlankType: 3,
+ section.DotType: 4,
+ section.AliasType: 5,
+ section.LocalModuleType: 6,
+}
- hasOptions := settings.Gci.SkipGenerated || len(settings.Gci.Sections) > 0
- if !hasOptions {
- return text
- }
+type YamlConfig struct {
+ origin gcicfg.YamlConfig
+}
- text += " with"
+//nolint:gocritic // code borrowed from gci and modified to fix LocalModule section behavior.
+func (g YamlConfig) Parse() (*gcicfg.Config, error) {
+ var err error
- if settings.Gci.SkipGenerated {
- text += " --skip-generated"
+ sections, err := section.Parse(g.origin.SectionStrings)
+ if err != nil {
+ return nil, err
}
- if len(settings.Gci.Sections) > 0 {
- for _, section := range settings.Gci.Sections {
- text += " -s " + section
- }
+ if sections == nil {
+ sections = section.DefaultSections()
}
- if settings.Gci.CustomOrder {
- text += " --custom-order"
+ // if default order sorted sections
+ if !g.origin.Cfg.CustomOrder {
+ sort.Slice(sections, func(i, j int) bool {
+ sectionI, sectionJ := sections[i].Type(), sections[j].Type()
+
+ if g.origin.Cfg.NoLexOrder || strings.Compare(sectionI, sectionJ) != 0 {
+ return defaultOrder[sectionI] < defaultOrder[sectionJ]
+ }
+
+ return strings.Compare(sections[i].String(), sections[j].String()) < 0
+ })
}
- return text
+ sectionSeparators, err := section.Parse(g.origin.SectionSeparatorStrings)
+ if err != nil {
+ return nil, err
+ }
+ if sectionSeparators == nil {
+ sectionSeparators = section.DefaultSectionSeparators()
+ }
+
+ return &gcicfg.Config{BoolConfig: g.origin.Cfg, Sections: sections, SectionSeparators: sectionSeparators}, nil
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter/ginkgolinter.go
index 182b001d5..54d207257 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter/ginkgolinter.go
@@ -1,4 +1,4 @@
-package golinters
+package ginkgolinter
import (
"github.com/nunnatsa/ginkgolinter"
@@ -9,7 +9,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewGinkgoLinter(settings *config.GinkgoLinterSettings) *goanalysis.Linter {
+func New(settings *config.GinkgoLinterSettings) *goanalysis.Linter {
cfg := &types.Config{}
if settings != nil {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go
index d2e302a28..be604d805 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go
@@ -1,4 +1,4 @@
-package golinters
+package gocheckcompilerdirectives
import (
"4d63.com/gocheckcompilerdirectives/checkcompilerdirectives"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewGoCheckCompilerDirectives() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := checkcompilerdirectives.Analyzer()
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals/gochecknoglobals.go
index a35876d99..af22b2f8e 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals/gochecknoglobals.go
@@ -1,4 +1,4 @@
-package golinters
+package gochecknoglobals
import (
"4d63.com/gochecknoglobals/checknoglobals"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewGochecknoglobals() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := checknoglobals.Analyzer()
// gochecknoglobals only lints test files if the `-t` flag is passed,
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits/gochecknoinits.go
index 28f025943..1345eb8c2 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits/gochecknoinits.go
@@ -1,4 +1,4 @@
-package golinters
+package gochecknoinits
import (
"fmt"
@@ -14,14 +14,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const gochecknoinitsName = "gochecknoinits"
+const linterName = "gochecknoinits"
-func NewGochecknoinits() *goanalysis.Linter {
+func New() *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: gochecknoinitsName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
var res []goanalysis.Issue
@@ -44,7 +44,7 @@ func NewGochecknoinits() *goanalysis.Linter {
}
return goanalysis.NewLinter(
- gochecknoinitsName,
+ linterName,
"Checks that no init functions are present in Go code",
[]*analysis.Analyzer{analyzer},
nil,
@@ -61,12 +61,12 @@ func checkFileForInits(f *ast.File, fset *token.FileSet) []result.Issue {
continue
}
- name := funcDecl.Name.Name
- if name == "init" && funcDecl.Recv.NumFields() == 0 {
+ fnName := funcDecl.Name.Name
+ if fnName == "init" && funcDecl.Recv.NumFields() == 0 {
res = append(res, result.Issue{
Pos: fset.Position(funcDecl.Pos()),
- Text: fmt.Sprintf("don't use %s function", internal.FormatCode(name, nil)),
- FromLinter: gochecknoinitsName,
+ Text: fmt.Sprintf("don't use %s function", internal.FormatCode(fnName, nil)),
+ FromLinter: linterName,
})
}
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype/gochecksumtype.go
index a022abae9..446f0e564 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype/gochecksumtype.go
@@ -1,4 +1,4 @@
-package golinters
+package gochecksumtype
import (
"strings"
@@ -13,14 +13,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const goCheckSumTypeName = "gochecksumtype"
+const linterName = "gochecksumtype"
-func NewGoCheckSumType() *goanalysis.Linter {
+func New() *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: goCheckSumTypeName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runGoCheckSumType(pass)
@@ -41,7 +41,7 @@ func NewGoCheckSumType() *goanalysis.Linter {
}
return goanalysis.NewLinter(
- goCheckSumTypeName,
+ linterName,
`Run exhaustiveness checks on Go "sum types"`,
[]*analysis.Analyzer{analyzer},
nil,
@@ -70,7 +70,7 @@ func runGoCheckSumType(pass *analysis.Pass) ([]goanalysis.Issue, error) {
}
resIssues = append(resIssues, goanalysis.NewIssue(&result.Issue{
- FromLinter: goCheckSumTypeName,
+ FromLinter: linterName,
Text: strings.TrimPrefix(err.Error(), err.Pos().String()+": "),
Pos: err.Pos(),
}, pass))
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocognit.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocognit/gocognit.go
index 00cd26b09..5fe0f90f0 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocognit.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocognit/gocognit.go
@@ -1,4 +1,4 @@
-package golinters
+package gocognit
import (
"fmt"
@@ -15,9 +15,9 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const gocognitName = "gocognit"
+const linterName = "gocognit"
-func NewGocognit(settings *config.GocognitSettings) *goanalysis.Linter {
+func New(settings *config.GocognitSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
@@ -40,7 +40,7 @@ func NewGocognit(settings *config.GocognitSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- gocognitName,
+ linterName,
"Computes and checks the cognitive complexity of functions",
[]*analysis.Analyzer{analyzer},
nil,
@@ -72,7 +72,7 @@ func runGocognit(pass *analysis.Pass, settings *config.GocognitSettings) []goana
Pos: s.Pos,
Text: fmt.Sprintf("cognitive complexity %d of func %s is high (> %d)",
s.Complexity, internal.FormatCode(s.FuncName, nil), settings.MinComplexity),
- FromLinter: gocognitName,
+ FromLinter: linterName,
}, pass))
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goconst.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goconst/goconst.go
index 553f6be97..07bed301f 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goconst.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goconst/goconst.go
@@ -1,4 +1,4 @@
-package golinters
+package goconst
import (
"fmt"
@@ -14,14 +14,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const goconstName = "goconst"
+const linterName = "goconst"
-func NewGoconst(settings *config.GoConstSettings) *goanalysis.Linter {
+func New(settings *config.GoConstSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: goconstName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runGoconst(pass, settings)
@@ -42,7 +42,7 @@ func NewGoconst(settings *config.GoConstSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- goconstName,
+ linterName,
"Finds repeated strings that could be replaced by a constant",
[]*analysis.Analyzer{analyzer},
nil,
@@ -90,7 +90,7 @@ func runGoconst(pass *analysis.Pass, settings *config.GoConstSettings) ([]goanal
res = append(res, goanalysis.NewIssue(&result.Issue{
Pos: i.Pos,
Text: text,
- FromLinter: goconstName,
+ FromLinter: linterName,
}, pass))
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocritic.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocritic/gocritic.go
index 5f5d34393..68cc338e4 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocritic.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocritic/gocritic.go
@@ -1,4 +1,4 @@
-package golinters
+package gocritic
import (
"errors"
@@ -14,6 +14,7 @@ import (
"github.com/go-critic/go-critic/checkers"
gocriticlinter "github.com/go-critic/go-critic/linter"
+ _ "github.com/quasilyte/go-ruleguard/dsl"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/tools/go/analysis"
@@ -25,14 +26,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const goCriticName = "gocritic"
+const linterName = "gocritic"
var (
- goCriticDebugf = logutils.Debug(logutils.DebugKeyGoCritic)
- isGoCriticDebug = logutils.HaveDebugTag(logutils.DebugKeyGoCritic)
+ debugf = logutils.Debug(logutils.DebugKeyGoCritic)
+ isDebug = logutils.HaveDebugTag(logutils.DebugKeyGoCritic)
)
-func NewGoCritic(settings *config.GoCriticSettings) *goanalysis.Linter {
+func New(settings *config.GoCriticSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
@@ -41,7 +42,7 @@ func NewGoCritic(settings *config.GoCriticSettings) *goanalysis.Linter {
}
analyzer := &analysis.Analyzer{
- Name: goCriticName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues, err := wrapper.run(pass)
@@ -62,7 +63,7 @@ func NewGoCritic(settings *config.GoCriticSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- goCriticName,
+ linterName,
`Provides diagnostics that check for bugs, performance and style issues.
Extensible without recompilation through dynamic rules.
Dynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion.`,
@@ -81,7 +82,7 @@ Dynamic rules are written declaratively with AST patterns, filters, report messa
}
type goCriticWrapper struct {
- settingsWrapper *goCriticSettingsWrapper
+ settingsWrapper *settingsWrapper
configDir string
sizes types.Sizes
once sync.Once
@@ -95,16 +96,16 @@ func (w *goCriticWrapper) init(logger logutils.Log, settings *config.GoCriticSet
w.once.Do(func() {
err := checkers.InitEmbeddedRules()
if err != nil {
- logger.Fatalf("%s: %v: setting an explicit GOROOT can fix this problem", goCriticName, err)
+ logger.Fatalf("%s: %v: setting an explicit GOROOT can fix this problem", linterName, err)
}
})
- settingsWrapper := newGoCriticSettingsWrapper(settings, logger)
+ settingsWrapper := newSettingsWrapper(settings, logger)
settingsWrapper.InferEnabledChecks()
// Validate must be after InferEnabledChecks, not before.
// Because it uses gathered information about tags set and finally enabled checks.
if err := settingsWrapper.Validate(); err != nil {
- logger.Fatalf("%s: invalid settings: %s", goCriticName, err)
+ logger.Fatalf("%s: invalid settings: %s", linterName, err)
}
w.settingsWrapper = settingsWrapper
@@ -126,7 +127,7 @@ func (w *goCriticWrapper) run(pass *analysis.Pass) ([]goanalysis.Issue, error) {
linterCtx.SetPackageInfo(pass.TypesInfo, pass.Pkg)
- pkgIssues := runGoCriticOnPackage(linterCtx, enabledCheckers, pass.Files)
+ pkgIssues := runOnPackage(linterCtx, enabledCheckers, pass.Files)
issues := make([]goanalysis.Issue, 0, len(pkgIssues))
for i := range pkgIssues {
@@ -213,19 +214,19 @@ func (w *goCriticWrapper) normalizeCheckerParamsValue(p any) any {
}
}
-func runGoCriticOnPackage(linterCtx *gocriticlinter.Context, checks []*gocriticlinter.Checker, files []*ast.File) []result.Issue {
+func runOnPackage(linterCtx *gocriticlinter.Context, checks []*gocriticlinter.Checker, files []*ast.File) []result.Issue {
var res []result.Issue
for _, f := range files {
filename := filepath.Base(linterCtx.FileSet.Position(f.Pos()).Filename)
linterCtx.SetFileInfo(filename, f)
- issues := runGoCriticOnFile(linterCtx, f, checks)
+ issues := runOnFile(linterCtx, f, checks)
res = append(res, issues...)
}
return res
}
-func runGoCriticOnFile(linterCtx *gocriticlinter.Context, f *ast.File, checks []*gocriticlinter.Checker) []result.Issue {
+func runOnFile(linterCtx *gocriticlinter.Context, f *ast.File, checks []*gocriticlinter.Checker) []result.Issue {
var res []result.Issue
for _, c := range checks {
@@ -236,7 +237,7 @@ func runGoCriticOnFile(linterCtx *gocriticlinter.Context, f *ast.File, checks []
issue := result.Issue{
Pos: pos,
Text: fmt.Sprintf("%s: %s", c.Info.Name, warn.Text),
- FromLinter: goCriticName,
+ FromLinter: linterName,
}
if warn.HasQuickFix() {
@@ -263,7 +264,7 @@ func (m goCriticChecks[T]) has(name string) bool {
return ok
}
-type goCriticSettingsWrapper struct {
+type settingsWrapper struct {
*config.GoCriticSettings
logger logutils.Log
@@ -281,7 +282,7 @@ type goCriticSettingsWrapper struct {
inferredEnabledChecksLowerCased goCriticChecks[struct{}]
}
-func newGoCriticSettingsWrapper(settings *config.GoCriticSettings, logger logutils.Log) *goCriticSettingsWrapper {
+func newSettingsWrapper(settings *config.GoCriticSettings, logger logutils.Log) *settingsWrapper {
allCheckers := gocriticlinter.GetCheckersInfo()
allChecks := make(goCriticChecks[struct{}], len(allCheckers))
@@ -299,7 +300,7 @@ func newGoCriticSettingsWrapper(settings *config.GoCriticSettings, logger loguti
allTagsSorted := maps.Keys(allChecksByTag)
sort.Strings(allTagsSorted)
- return &goCriticSettingsWrapper{
+ return &settingsWrapper{
GoCriticSettings: settings,
logger: logger,
allCheckers: allCheckers,
@@ -312,16 +313,16 @@ func newGoCriticSettingsWrapper(settings *config.GoCriticSettings, logger loguti
}
}
-func (s *goCriticSettingsWrapper) IsCheckEnabled(name string) bool {
+func (s *settingsWrapper) IsCheckEnabled(name string) bool {
return s.inferredEnabledChecks.has(name)
}
-func (s *goCriticSettingsWrapper) GetLowerCasedParams() map[string]config.GoCriticCheckSettings {
+func (s *settingsWrapper) GetLowerCasedParams() map[string]config.GoCriticCheckSettings {
return normalizeMap(s.SettingsPerCheck)
}
-// InferEnabledChecks tries to be consistent with (lintersdb.EnabledSet).build.
-func (s *goCriticSettingsWrapper) InferEnabledChecks() {
+// InferEnabledChecks tries to be consistent with (lintersdb.Manager).build.
+func (s *settingsWrapper) InferEnabledChecks() {
s.debugChecksInitialState()
enabledByDefaultChecks, disabledByDefaultChecks := s.buildEnabledAndDisabledByDefaultChecks()
@@ -357,7 +358,7 @@ func (s *goCriticSettingsWrapper) InferEnabledChecks() {
for _, check := range s.EnabledChecks {
if enabledChecks.has(check) {
- s.logger.Warnf("%s: no need to enable check %q: it's already enabled", goCriticName, check)
+ s.logger.Warnf("%s: no need to enable check %q: it's already enabled", linterName, check)
continue
}
enabledChecks[check] = struct{}{}
@@ -378,7 +379,7 @@ func (s *goCriticSettingsWrapper) InferEnabledChecks() {
for _, check := range s.DisabledChecks {
if !enabledChecks.has(check) {
- s.logger.Warnf("%s: no need to disable check %q: it's already disabled", goCriticName, check)
+ s.logger.Warnf("%s: no need to disable check %q: it's already disabled", linterName, check)
continue
}
delete(enabledChecks, check)
@@ -390,7 +391,7 @@ func (s *goCriticSettingsWrapper) InferEnabledChecks() {
s.debugChecksFinalState()
}
-func (s *goCriticSettingsWrapper) buildEnabledAndDisabledByDefaultChecks() (enabled, disabled []string) {
+func (s *settingsWrapper) buildEnabledAndDisabledByDefaultChecks() (enabled, disabled []string) {
for _, info := range s.allCheckers {
if enabledByDef := isEnabledByDefaultGoCriticChecker(info); enabledByDef {
enabled = append(enabled, info.Name)
@@ -401,7 +402,7 @@ func (s *goCriticSettingsWrapper) buildEnabledAndDisabledByDefaultChecks() (enab
return enabled, disabled
}
-func (s *goCriticSettingsWrapper) expandTagsToChecks(tags []string) []string {
+func (s *settingsWrapper) expandTagsToChecks(tags []string) []string {
var checks []string
for _, tag := range tags {
checks = append(checks, s.allChecksByTag[tag]...)
@@ -409,19 +410,19 @@ func (s *goCriticSettingsWrapper) expandTagsToChecks(tags []string) []string {
return checks
}
-func (s *goCriticSettingsWrapper) debugChecksInitialState() {
- if !isGoCriticDebug {
+func (s *settingsWrapper) debugChecksInitialState() {
+ if !isDebug {
return
}
- goCriticDebugf("All gocritic existing tags and checks:")
+ debugf("All gocritic existing tags and checks:")
for _, tag := range s.allTagsSorted {
debugChecksListf(s.allChecksByTag[tag], " tag %q", tag)
}
}
-func (s *goCriticSettingsWrapper) debugChecksFinalState() {
- if !isGoCriticDebug {
+func (s *settingsWrapper) debugChecksFinalState() {
+ if !isDebug {
return
}
@@ -429,25 +430,25 @@ func (s *goCriticSettingsWrapper) debugChecksFinalState() {
var disabledChecks []string
for _, checker := range s.allCheckers {
- name := checker.Name
- if s.inferredEnabledChecks.has(name) {
- enabledChecks = append(enabledChecks, name)
+ check := checker.Name
+ if s.inferredEnabledChecks.has(check) {
+ enabledChecks = append(enabledChecks, check)
} else {
- disabledChecks = append(disabledChecks, name)
+ disabledChecks = append(disabledChecks, check)
}
}
debugChecksListf(enabledChecks, "Final used")
if len(disabledChecks) == 0 {
- goCriticDebugf("All checks are enabled")
+ debugf("All checks are enabled")
} else {
debugChecksListf(disabledChecks, "Final not used")
}
}
// Validate tries to be consistent with (lintersdb.Validator).validateEnabledDisabledLintersConfig.
-func (s *goCriticSettingsWrapper) Validate() error {
+func (s *settingsWrapper) Validate() error {
for _, v := range []func() error{
s.validateOptionsCombinations,
s.validateCheckerTags,
@@ -462,7 +463,7 @@ func (s *goCriticSettingsWrapper) Validate() error {
return nil
}
-func (s *goCriticSettingsWrapper) validateOptionsCombinations() error {
+func (s *settingsWrapper) validateOptionsCombinations() error {
if s.EnableAll {
if s.DisableAll {
return errors.New("enable-all and disable-all options must not be combined")
@@ -494,49 +495,49 @@ func (s *goCriticSettingsWrapper) validateOptionsCombinations() error {
return nil
}
-func (s *goCriticSettingsWrapper) validateCheckerTags() error {
+func (s *settingsWrapper) validateCheckerTags() error {
for _, tag := range s.EnabledTags {
if !s.allChecksByTag.has(tag) {
- return fmt.Errorf("enabled tag %q doesn't exist, see %s's documentation", tag, goCriticName)
+ return fmt.Errorf("enabled tag %q doesn't exist, see %s's documentation", tag, linterName)
}
}
for _, tag := range s.DisabledTags {
if !s.allChecksByTag.has(tag) {
- return fmt.Errorf("disabled tag %q doesn't exist, see %s's documentation", tag, goCriticName)
+ return fmt.Errorf("disabled tag %q doesn't exist, see %s's documentation", tag, linterName)
}
}
return nil
}
-func (s *goCriticSettingsWrapper) validateCheckerNames() error {
- for _, name := range s.EnabledChecks {
- if !s.allChecks.has(name) {
- return fmt.Errorf("enabled check %q doesn't exist, see %s's documentation", name, goCriticName)
+func (s *settingsWrapper) validateCheckerNames() error {
+ for _, check := range s.EnabledChecks {
+ if !s.allChecks.has(check) {
+ return fmt.Errorf("enabled check %q doesn't exist, see %s's documentation", check, linterName)
}
}
- for _, name := range s.DisabledChecks {
- if !s.allChecks.has(name) {
- return fmt.Errorf("disabled check %q doesn't exist, see %s documentation", name, goCriticName)
+ for _, check := range s.DisabledChecks {
+ if !s.allChecks.has(check) {
+ return fmt.Errorf("disabled check %q doesn't exist, see %s documentation", check, linterName)
}
}
- for name := range s.SettingsPerCheck {
- lcName := strings.ToLower(name)
+ for check := range s.SettingsPerCheck {
+ lcName := strings.ToLower(check)
if !s.allChecksLowerCased.has(lcName) {
- return fmt.Errorf("invalid check settings: check %q doesn't exist, see %s documentation", name, goCriticName)
+ return fmt.Errorf("invalid check settings: check %q doesn't exist, see %s documentation", check, linterName)
}
if !s.inferredEnabledChecksLowerCased.has(lcName) {
- s.logger.Warnf("%s: settings were provided for disabled check %q", goCriticName, name)
+ s.logger.Warnf("%s: settings were provided for disabled check %q", check, linterName)
}
}
return nil
}
-func (s *goCriticSettingsWrapper) validateDisabledAndEnabledAtOneMoment() error {
+func (s *settingsWrapper) validateDisabledAndEnabledAtOneMoment() error {
for _, tag := range s.DisabledTags {
if slices.Contains(s.EnabledTags, tag) {
return fmt.Errorf("tag %q disabled and enabled at one moment", tag)
@@ -552,7 +553,7 @@ func (s *goCriticSettingsWrapper) validateDisabledAndEnabledAtOneMoment() error
return nil
}
-func (s *goCriticSettingsWrapper) validateAtLeastOneCheckerEnabled() error {
+func (s *settingsWrapper) validateAtLeastOneCheckerEnabled() error {
if len(s.inferredEnabledChecks) == 0 {
return errors.New("eventually all checks were disabled: at least one must be enabled")
}
@@ -576,11 +577,11 @@ func isEnabledByDefaultGoCriticChecker(info *gocriticlinter.CheckerInfo) bool {
}
func debugChecksListf(checks []string, format string, args ...any) {
- if !isGoCriticDebug {
+ if !isDebug {
return
}
- goCriticDebugf("%s checks (%d): %s", fmt.Sprintf(format, args...), len(checks), sprintSortedStrings(checks))
+ debugf("%s checks (%d): %s", fmt.Sprintf(format, args...), len(checks), sprintSortedStrings(checks))
}
func sprintSortedStrings(v []string) string {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocyclo.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocyclo/gocyclo.go
index cbf05fff0..51333dc15 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocyclo.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gocyclo/gocyclo.go
@@ -1,4 +1,4 @@
-package golinters
+package gocyclo
import (
"fmt"
@@ -14,14 +14,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const gocycloName = "gocyclo"
+const linterName = "gocyclo"
-func NewGocyclo(settings *config.GoCycloSettings) *goanalysis.Linter {
+func New(settings *config.GoCycloSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: gocycloName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues := runGoCyclo(pass, settings)
@@ -39,7 +39,7 @@ func NewGocyclo(settings *config.GoCycloSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- gocycloName,
+ linterName,
"Computes and checks the cyclomatic complexity of functions",
[]*analysis.Analyzer{analyzer},
nil,
@@ -68,7 +68,7 @@ func runGoCyclo(pass *analysis.Pass, settings *config.GoCycloSettings) []goanaly
issues = append(issues, goanalysis.NewIssue(&result.Issue{
Pos: s.Pos,
Text: text,
- FromLinter: gocycloName,
+ FromLinter: linterName,
}, pass))
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/godot.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/godot/godot.go
index 614ea4102..fc51b5bb8 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/godot.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/godot/godot.go
@@ -1,4 +1,4 @@
-package golinters
+package godot
import (
"sync"
@@ -12,9 +12,9 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const godotName = "godot"
+const linterName = "godot"
-func NewGodot(settings *config.GodotSettings) *goanalysis.Linter {
+func New(settings *config.GodotSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
@@ -39,7 +39,7 @@ func NewGodot(settings *config.GodotSettings) *goanalysis.Linter {
}
analyzer := &analysis.Analyzer{
- Name: godotName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runGodot(pass, dotSettings)
@@ -60,7 +60,7 @@ func NewGodot(settings *config.GodotSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- godotName,
+ linterName,
"Check if comments end in a period",
[]*analysis.Analyzer{analyzer},
nil,
@@ -88,7 +88,7 @@ func runGodot(pass *analysis.Pass, settings godot.Settings) ([]goanalysis.Issue,
issue := result.Issue{
Pos: i.Pos,
Text: i.Message,
- FromLinter: godotName,
+ FromLinter: linterName,
Replacement: &result.Replacement{
NewLines: []string{i.Replacement},
},
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/godox.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/godox/godox.go
index afe997bd2..d8de026ba 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/godox.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/godox/godox.go
@@ -1,4 +1,4 @@
-package golinters
+package godox
import (
"go/token"
@@ -14,14 +14,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const godoxName = "godox"
+const linterName = "godox"
-func NewGodox(settings *config.GodoxSettings) *goanalysis.Linter {
+func New(settings *config.GodoxSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: godoxName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues := runGodox(pass, settings)
@@ -39,7 +39,7 @@ func NewGodox(settings *config.GodoxSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- godoxName,
+ linterName,
"Tool for detection of FIXME, TODO and other comment keywords",
[]*analysis.Analyzer{analyzer},
nil,
@@ -67,7 +67,7 @@ func runGodox(pass *analysis.Pass, settings *config.GodoxSettings) []goanalysis.
Line: i.Pos.Line,
},
Text: strings.TrimRight(i.Message, "\n"),
- FromLinter: godoxName,
+ FromLinter: linterName,
}, pass)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofmt.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofmt/gofmt.go
index 9a0069444..289ceab8a 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofmt.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofmt/gofmt.go
@@ -1,4 +1,4 @@
-package golinters
+package gofmt
import (
"fmt"
@@ -13,20 +13,20 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/linter"
)
-const gofmtName = "gofmt"
+const linterName = "gofmt"
-func NewGofmt(settings *config.GoFmtSettings) *goanalysis.Linter {
+func New(settings *config.GoFmtSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: gofmtName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: goanalysis.DummyRun,
}
return goanalysis.NewLinter(
- gofmtName,
+ linterName,
"Gofmt checks whether code was gofmt-ed. By default "+
"this tool runs with -s option to check for code simplification",
[]*analysis.Analyzer{analyzer},
@@ -72,7 +72,7 @@ func runGofmt(lintCtx *linter.Context, pass *analysis.Pass, settings *config.GoF
continue
}
- is, err := internal.ExtractIssuesFromPatch(string(diff), lintCtx, gofmtName, getIssuedTextGoFmt)
+ is, err := internal.ExtractIssuesFromPatch(string(diff), lintCtx, linterName, getIssuedTextGoFmt)
if err != nil {
return nil, fmt.Errorf("can't extract issues from gofmt diff output %q: %w", string(diff), err)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofumpt.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go
index 4c6a9cec1..3bb7df12e 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofumpt.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go
@@ -1,10 +1,11 @@
-package golinters
+package gofumpt
import (
"bytes"
"fmt"
"io"
"os"
+ "strings"
"sync"
"github.com/shazow/go-diff/difflib"
@@ -17,13 +18,13 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/linter"
)
-const gofumptName = "gofumpt"
+const linterName = "gofumpt"
type differ interface {
Diff(out io.Writer, a io.ReadSeeker, b io.ReadSeeker) error
}
-func NewGofumpt(settings *config.GofumptSettings) *goanalysis.Linter {
+func New(settings *config.GofumptSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
@@ -40,13 +41,13 @@ func NewGofumpt(settings *config.GofumptSettings) *goanalysis.Linter {
}
analyzer := &analysis.Analyzer{
- Name: gofumptName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: goanalysis.DummyRun,
}
return goanalysis.NewLinter(
- gofumptName,
+ linterName,
"Gofumpt checks whether code was gofumpt-ed.",
[]*analysis.Analyzer{analyzer},
nil,
@@ -97,7 +98,7 @@ func runGofumpt(lintCtx *linter.Context, pass *analysis.Pass, diff differ, optio
}
diff := out.String()
- is, err := internal.ExtractIssuesFromPatch(diff, lintCtx, gofumptName, getIssuedTextGoFumpt)
+ is, err := internal.ExtractIssuesFromPatch(diff, lintCtx, linterName, getIssuedTextGoFumpt)
if err != nil {
return nil, fmt.Errorf("can't extract issues from gofumpt diff output %q: %w", diff, err)
}
@@ -113,10 +114,11 @@ func runGofumpt(lintCtx *linter.Context, pass *analysis.Pass, diff differ, optio
func getLangVersion(settings *config.GofumptSettings) string {
if settings == nil || settings.LangVersion == "" {
- // TODO: defaults to "1.15", in the future (v2) must be set by using build.Default.ReleaseTags like staticcheck.
- return "1.15"
+ // TODO: defaults to "1.15", in the future (v2) must be removed.
+ return "go1.15"
}
- return settings.LangVersion
+
+ return "go" + strings.TrimPrefix(settings.LangVersion, "go")
}
func getIssuedTextGoFumpt(settings *config.LintersSettings) string {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goheader.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goheader/goheader.go
index b47f0304e..14d517fb3 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goheader.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goheader/goheader.go
@@ -1,4 +1,4 @@
-package golinters
+package goheader
import (
"go/token"
@@ -13,9 +13,9 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const goHeaderName = "goheader"
+const linterName = "goheader"
-func NewGoHeader(settings *config.GoHeaderSettings) *goanalysis.Linter {
+func New(settings *config.GoHeaderSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
@@ -29,7 +29,7 @@ func NewGoHeader(settings *config.GoHeaderSettings) *goanalysis.Linter {
}
analyzer := &analysis.Analyzer{
- Name: goHeaderName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runGoHeader(pass, conf)
@@ -50,7 +50,7 @@ func NewGoHeader(settings *config.GoHeaderSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- goHeaderName,
+ linterName,
"Checks is file header matches to pattern",
[]*analysis.Analyzer{analyzer},
nil,
@@ -94,7 +94,7 @@ func runGoHeader(pass *analysis.Pass, conf *goheader.Configuration) ([]goanalysi
Filename: path,
},
Text: i.Message(),
- FromLinter: goHeaderName,
+ FromLinter: linterName,
}
if fix := i.Fix(); fix != nil {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goimports.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goimports/goimports.go
index 224970f5c..de965d5c8 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goimports.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goimports/goimports.go
@@ -1,4 +1,4 @@
-package golinters
+package goimports
import (
"fmt"
@@ -14,20 +14,20 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/linter"
)
-const goimportsName = "goimports"
+const linterName = "goimports"
-func NewGoimports(settings *config.GoImportsSettings) *goanalysis.Linter {
+func New(settings *config.GoImportsSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: goimportsName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: goanalysis.DummyRun,
}
return goanalysis.NewLinter(
- goimportsName,
+ linterName,
"Check import statements are formatted according to the 'goimport' command. "+
"Reformat imports in autofix mode.",
[]*analysis.Analyzer{analyzer},
@@ -70,7 +70,7 @@ func runGoImports(lintCtx *linter.Context, pass *analysis.Pass) ([]goanalysis.Is
continue
}
- is, err := internal.ExtractIssuesFromPatch(string(diff), lintCtx, goimportsName, getIssuedTextGoImports)
+ is, err := internal.ExtractIssuesFromPatch(string(diff), lintCtx, linterName, getIssuedTextGoImports)
if err != nil {
return nil, fmt.Errorf("can't extract issues from gofmt diff output %q: %w", string(diff), err)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomnd.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomnd.go
deleted file mode 100644
index b4bf957a7..000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomnd.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package golinters
-
-import (
- mnd "github.com/tommy-muehle/go-mnd/v2"
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
-)
-
-func NewGoMND(settings *config.GoMndSettings) *goanalysis.Linter {
- var linterCfg map[string]map[string]any
-
- if settings != nil {
- // TODO(ldez) For compatibility only, must be drop in v2.
- if len(settings.Settings) > 0 {
- linterCfg = settings.Settings
- } else {
- cfg := make(map[string]any)
- if len(settings.Checks) > 0 {
- cfg["checks"] = settings.Checks
- }
- if len(settings.IgnoredNumbers) > 0 {
- cfg["ignored-numbers"] = settings.IgnoredNumbers
- }
- if len(settings.IgnoredFiles) > 0 {
- cfg["ignored-files"] = settings.IgnoredFiles
- }
- if len(settings.IgnoredFunctions) > 0 {
- cfg["ignored-functions"] = settings.IgnoredFunctions
- }
-
- linterCfg = map[string]map[string]any{
- "mnd": cfg,
- }
- }
- }
-
- return goanalysis.NewLinter(
- "gomnd",
- "An analyzer to detect magic numbers.",
- []*analysis.Analyzer{mnd.Analyzer},
- linterCfg,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives/gomoddirectives.go
index 6902b3207..9cde7e26c 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives/gomoddirectives.go
@@ -1,4 +1,4 @@
-package golinters
+package gomoddirectives
import (
"sync"
@@ -12,10 +12,9 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const goModDirectivesName = "gomoddirectives"
+const linterName = "gomoddirectives"
-// NewGoModDirectives returns a new gomoddirectives linter.
-func NewGoModDirectives(settings *config.GoModDirectivesSettings) *goanalysis.Linter {
+func New(settings *config.GoModDirectivesSettings) *goanalysis.Linter {
var issues []goanalysis.Issue
var once sync.Once
@@ -34,7 +33,7 @@ func NewGoModDirectives(settings *config.GoModDirectivesSettings) *goanalysis.Li
}
return goanalysis.NewLinter(
- goModDirectivesName,
+ linterName,
"Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.",
[]*analysis.Analyzer{analyzer},
nil,
@@ -44,13 +43,13 @@ func NewGoModDirectives(settings *config.GoModDirectivesSettings) *goanalysis.Li
results, err := gomoddirectives.Analyze(opts)
if err != nil {
lintCtx.Log.Warnf("running %s failed: %s: "+
- "if you are not using go modules it is suggested to disable this linter", goModDirectivesName, err)
+ "if you are not using go modules it is suggested to disable this linter", linterName, err)
return
}
for _, p := range results {
issues = append(issues, goanalysis.NewIssue(&result.Issue{
- FromLinter: goModDirectivesName,
+ FromLinter: linterName,
Pos: p.Start,
Text: p.Reason,
}, pass))
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomodguard.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomodguard/gomodguard.go
index fe880b57f..8f1036b0f 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomodguard.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomodguard/gomodguard.go
@@ -1,4 +1,4 @@
-package golinters
+package gomodguard
import (
"sync"
@@ -14,14 +14,13 @@ import (
)
const (
- gomodguardName = "gomodguard"
- gomodguardDesc = "Allow and block list linter for direct Go module dependencies. " +
+ name = "gomodguard"
+ desc = "Allow and block list linter for direct Go module dependencies. " +
"This is different from depguard where there are different block " +
"types for example version constraints and module recommendations."
)
-// NewGomodguard returns a new Gomodguard linter.
-func NewGomodguard(settings *config.GoModGuardSettings) *goanalysis.Linter {
+func New(settings *config.GoModGuardSettings) *goanalysis.Linter {
var issues []goanalysis.Issue
var mu sync.Mutex
@@ -61,8 +60,8 @@ func NewGomodguard(settings *config.GoModGuardSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- gomodguardName,
- gomodguardDesc,
+ name,
+ desc,
[]*analysis.Analyzer{analyzer},
nil,
).WithContextSetter(func(lintCtx *linter.Context) {
@@ -81,7 +80,7 @@ func NewGomodguard(settings *config.GoModGuardSettings) *goanalysis.Linter {
for _, gomodguardIssue := range gomodguardIssues {
issues = append(issues, goanalysis.NewIssue(&result.Issue{
- FromLinter: gomodguardName,
+ FromLinter: name,
Pos: gomodguardIssue.Position,
Text: gomodguardIssue.Reason,
}, pass))
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname/goprintffuncname.go
index 97df64051..85154a9b3 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname/goprintffuncname.go
@@ -1,4 +1,4 @@
-package golinters
+package goprintffuncname
import (
"github.com/jirfag/go-printf-func-name/pkg/analyzer"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewGoPrintfFuncName() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := analyzer.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosec.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosec/gosec.go
index 3ce37cac4..a5367399b 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosec.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosec/gosec.go
@@ -1,4 +1,4 @@
-package golinters
+package gosec
import (
"fmt"
@@ -10,6 +10,7 @@ import (
"sync"
"github.com/securego/gosec/v2"
+ "github.com/securego/gosec/v2/analyzers"
"github.com/securego/gosec/v2/issue"
"github.com/securego/gosec/v2/rules"
"golang.org/x/tools/go/analysis"
@@ -21,31 +22,40 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const gosecName = "gosec"
+const linterName = "gosec"
-func NewGosec(settings *config.GoSecSettings) *goanalysis.Linter {
+func New(settings *config.GoSecSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
- var filters []rules.RuleFilter
conf := gosec.NewConfig()
+
+ var ruleFilters []rules.RuleFilter
+ var analyzerFilters []analyzers.AnalyzerFilter
if settings != nil {
- filters = gosecRuleFilters(settings.Includes, settings.Excludes)
+ // TODO(ldez) to remove when the problem will be fixed by gosec.
+ // https://github.com/securego/gosec/issues/1211
+ // https://github.com/securego/gosec/issues/1209
+ settings.Excludes = append(settings.Excludes, "G407")
+
+ ruleFilters = createRuleFilters(settings.Includes, settings.Excludes)
+ analyzerFilters = createAnalyzerFilters(settings.Includes, settings.Excludes)
conf = toGosecConfig(settings)
}
logger := log.New(io.Discard, "", 0)
- ruleDefinitions := rules.Generate(false, filters...)
+ ruleDefinitions := rules.Generate(false, ruleFilters...)
+ analyzerDefinitions := analyzers.Generate(false, analyzerFilters...)
analyzer := &analysis.Analyzer{
- Name: gosecName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: goanalysis.DummyRun,
}
return goanalysis.NewLinter(
- gosecName,
+ linterName,
"Inspects source code for security problems",
[]*analysis.Analyzer{analyzer},
nil,
@@ -53,7 +63,9 @@ func NewGosec(settings *config.GoSecSettings) *goanalysis.Linter {
analyzer.Run = func(pass *analysis.Pass) (any, error) {
// The `gosecAnalyzer` is here because of concurrency issue.
gosecAnalyzer := gosec.NewAnalyzer(conf, true, settings.ExcludeGenerated, false, settings.Concurrency, logger)
+
gosecAnalyzer.LoadRules(ruleDefinitions.RulesInfo())
+ gosecAnalyzer.LoadAnalyzers(analyzerDefinitions.AnalyzersInfo())
issues := runGoSec(lintCtx, pass, settings, gosecAnalyzer)
@@ -77,6 +89,7 @@ func runGoSec(lintCtx *linter.Context, pass *analysis.Pass, settings *config.GoS
}
analyzer.CheckRules(pkg)
+ analyzer.CheckAnalyzers(pkg)
secIssues, _, _ := analyzer.Report()
if len(secIssues) == 0 {
@@ -126,7 +139,7 @@ func runGoSec(lintCtx *linter.Context, pass *analysis.Pass, settings *config.GoS
},
Text: text,
LineRange: r,
- FromLinter: gosecName,
+ FromLinter: linterName,
}, pass))
}
@@ -175,8 +188,23 @@ func convertGosecGlobals(globalOptionFromConfig any, conf gosec.Config) {
}
}
+// based on https://github.com/securego/gosec/blob/81cda2f91fbe1bf4735feb55febcae03e697a92b/cmd/gosec/main.go#L258-L275
+func createAnalyzerFilters(includes, excludes []string) []analyzers.AnalyzerFilter {
+ var filters []analyzers.AnalyzerFilter
+
+ if len(includes) > 0 {
+ filters = append(filters, analyzers.NewAnalyzerFilter(false, includes...))
+ }
+
+ if len(excludes) > 0 {
+ filters = append(filters, analyzers.NewAnalyzerFilter(true, excludes...))
+ }
+
+ return filters
+}
+
// based on https://github.com/securego/gosec/blob/569328eade2ccbad4ce2d0f21ee158ab5356a5cf/cmd/gosec/main.go#L170-L188
-func gosecRuleFilters(includes, excludes []string) []rules.RuleFilter {
+func createRuleFilters(includes, excludes []string) []rules.RuleFilter {
var filters []rules.RuleFilter
if len(includes) > 0 {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosimple.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosimple/gosimple.go
index b7930f0ee..c03871adf 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosimple.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosimple/gosimple.go
@@ -1,4 +1,4 @@
-package golinters
+package gosimple
import (
"honnef.co/go/tools/simple"
@@ -8,10 +8,10 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/internal"
)
-func NewGosimple(settings *config.StaticCheckSettings) *goanalysis.Linter {
+func New(settings *config.StaticCheckSettings) *goanalysis.Linter {
cfg := internal.StaticCheckConfig(settings)
- analyzers := internal.SetupStaticCheckAnalyzers(simple.Analyzers, internal.GetGoVersion(settings), cfg.Checks)
+ analyzers := internal.SetupStaticCheckAnalyzers(simple.Analyzers, cfg.Checks)
return goanalysis.NewLinter(
"gosimple",
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan/gosmopolitan.go
index f4c211470..4f6fb8035 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan/gosmopolitan.go
@@ -1,4 +1,4 @@
-package golinters
+package gosmopolitan
import (
"strings"
@@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewGosmopolitan(s *config.GosmopolitanSettings) *goanalysis.Linter {
+func New(s *config.GosmopolitanSettings) *goanalysis.Linter {
a := gosmopolitan.NewAnalyzer()
cfgMap := map[string]map[string]any{}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/govet.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/govet/govet.go
index 30410abae..eb63a5d33 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/govet.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/govet/govet.go
@@ -1,4 +1,4 @@
-package golinters
+package govet
import (
"slices"
@@ -139,11 +139,11 @@ var (
)
var (
- govetDebugf = logutils.Debug(logutils.DebugKeyGovet)
- isGovetDebug = logutils.HaveDebugTag(logutils.DebugKeyGovet)
+ debugf = logutils.Debug(logutils.DebugKeyGovet)
+ isDebug = logutils.HaveDebugTag(logutils.DebugKeyGovet)
)
-func NewGovet(settings *config.GovetSettings) *goanalysis.Linter {
+func New(settings *config.GovetSettings) *goanalysis.Linter {
var conf map[string]map[string]any
if settings != nil {
conf = settings.Settings
@@ -179,17 +179,11 @@ func analyzersFromConfig(settings *config.GovetSettings) []*analysis.Analyzer {
}
func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers []*analysis.Analyzer) bool {
- // TODO(ldez) remove loopclosure when go1.23
+ // TODO(ldez) remove loopclosure when go1.24
if name == loopclosure.Analyzer.Name && config.IsGoGreaterThanOrEqual(cfg.Go, "1.22") {
return false
}
- // TODO(ldez) re-enable httpresponse once https://github.com/golangci/golangci-lint/issues/4482 is fixed.
- if name == httpresponse.Analyzer.Name {
- govetDebugf("httpresponse is disabled due to panic. See https://github.com/golang/go/issues/66259")
- return false
- }
-
// Keeping for backward compatibility.
if cfg.CheckShadowing && name == shadow.Analyzer.Name {
return true
@@ -214,7 +208,7 @@ func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers
}
func debugAnalyzersListf(analyzers []*analysis.Analyzer, message string) {
- if !isGovetDebug {
+ if !isDebug {
return
}
@@ -225,5 +219,5 @@ func debugAnalyzersListf(analyzers []*analysis.Analyzer, message string) {
sort.Strings(analyzerNames)
- govetDebugf("%s (%d): %s", message, len(analyzerNames), analyzerNames)
+ debugf("%s (%d): %s", message, len(analyzerNames), analyzerNames)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/grouper.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/grouper/grouper.go
index f4eb3c427..aa6ce1ceb 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/grouper.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/grouper/grouper.go
@@ -1,4 +1,4 @@
-package golinters
+package grouper
import (
grouper "github.com/leonklingele/grouper/pkg/analyzer"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter {
+func New(settings *config.GrouperSettings) *goanalysis.Linter {
a := grouper.New()
linterCfg := map[string]map[string]any{}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/importas.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/importas/importas.go
index f699edfc8..45117c9a4 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/importas.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/importas/importas.go
@@ -1,4 +1,4 @@
-package golinters
+package importas
import (
"fmt"
@@ -13,7 +13,7 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/linter"
)
-func NewImportAs(settings *config.ImportAsSettings) *goanalysis.Linter {
+func New(settings *config.ImportAsSettings) *goanalysis.Linter {
analyzer := importas.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/inamedparam.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/inamedparam/inamedparam.go
index 293716dfd..5cf06a08c 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/inamedparam.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/inamedparam/inamedparam.go
@@ -1,4 +1,4 @@
-package golinters
+package inamedparam
import (
"github.com/macabu/inamedparam"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewINamedParam(settings *config.INamedParamSettings) *goanalysis.Linter {
+func New(settings *config.INamedParamSettings) *goanalysis.Linter {
a := inamedparam.Analyzer
var cfg map[string]map[string]any
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ineffassign.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/ineffassign/ineffassign.go
index e4c2abf71..ba86fb90e 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ineffassign.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/ineffassign/ineffassign.go
@@ -1,4 +1,4 @@
-package golinters
+package ineffassign
import (
"github.com/gordonklaus/ineffassign/pkg/ineffassign"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewIneffassign() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := ineffassign.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/interfacebloat.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/interfacebloat/interfacebloat.go
index 93dfe338e..88927a3d9 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/interfacebloat.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/interfacebloat/interfacebloat.go
@@ -1,4 +1,4 @@
-package golinters
+package interfacebloat
import (
"github.com/sashamelentyev/interfacebloat/pkg/analyzer"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewInterfaceBloat(settings *config.InterfaceBloatSettings) *goanalysis.Linter {
+func New(settings *config.InterfaceBloatSettings) *goanalysis.Linter {
a := analyzer.New()
var cfg map[string]map[string]any
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go
index b20230dfa..f919c5b2a 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go
@@ -242,7 +242,6 @@ func ExtractIssuesFromPatch(patch string, lintCtx *linter.Context, linterName st
changes := p.parse(hunk)
for _, change := range changes {
- change := change // fix scope
i := result.Issue{
FromLinter: linterName,
Pos: token.Position{
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/staticcheck_common.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/staticcheck_common.go
index 5b5812c31..958013d0d 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/staticcheck_common.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/internal/staticcheck_common.go
@@ -14,20 +14,7 @@ import (
var debugf = logutils.Debug(logutils.DebugKeyMegacheck)
-func GetGoVersion(settings *config.StaticCheckSettings) string {
- var goVersion string
- if settings != nil {
- goVersion = settings.GoVersion
- }
-
- if goVersion != "" {
- return goVersion
- }
-
- return "1.17"
-}
-
-func SetupStaticCheckAnalyzers(src []*lint.Analyzer, goVersion string, checks []string) []*analysis.Analyzer {
+func SetupStaticCheckAnalyzers(src []*lint.Analyzer, checks []string) []*analysis.Analyzer {
var names []string
for _, a := range src {
names = append(names, a.Analyzer.Name)
@@ -38,7 +25,6 @@ func SetupStaticCheckAnalyzers(src []*lint.Analyzer, goVersion string, checks []
var ret []*analysis.Analyzer
for _, a := range src {
if filter[a.Analyzer.Name] {
- SetAnalyzerGoVersion(a.Analyzer, goVersion)
ret = append(ret, a.Analyzer)
}
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/intrange.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/intrange/intrange.go
index e204087f3..d5ffd4345 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/intrange.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/intrange/intrange.go
@@ -1,4 +1,4 @@
-package golinters
+package intrange
import (
"github.com/ckaznocha/intrange"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewIntrange() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := intrange.Analyzer
return goanalysis.NewLinter(
@@ -15,5 +15,5 @@ func NewIntrange() *goanalysis.Linter {
a.Doc,
[]*analysis.Analyzer{a},
nil,
- ).WithLoadMode(goanalysis.LoadModeSyntax)
+ ).WithLoadMode(goanalysis.LoadModeTypesInfo)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ireturn.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/ireturn/ireturn.go
index 44a72e83f..57de57111 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/ireturn.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/ireturn/ireturn.go
@@ -1,4 +1,4 @@
-package golinters
+package ireturn
import (
"strings"
@@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewIreturn(settings *config.IreturnSettings) *goanalysis.Linter {
+func New(settings *config.IreturnSettings) *goanalysis.Linter {
a := analyzer.NewAnalyzer()
cfg := map[string]map[string]any{}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/lll.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/lll/lll.go
index 2c9ae9832..67f89eecb 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/lll.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/lll/lll.go
@@ -1,4 +1,4 @@
-package golinters
+package lll
import (
"bufio"
@@ -19,16 +19,16 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const lllName = "lll"
+const linterName = "lll"
const goCommentDirectivePrefix = "//go:"
-func NewLLL(settings *config.LllSettings) *goanalysis.Linter {
+func New(settings *config.LllSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: lllName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runLll(pass, settings)
@@ -49,7 +49,7 @@ func NewLLL(settings *config.LllSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- lllName,
+ linterName,
"Reports long lines",
[]*analysis.Analyzer{analyzer},
nil,
@@ -121,8 +121,8 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r
Filename: filename,
Line: lineNumber,
},
- Text: fmt.Sprintf("line is %d characters", lineLen),
- FromLinter: lllName,
+ Text: fmt.Sprintf("the line is %d characters long, which exceeds the maximum of %d characters.", lineLen, maxLineLen),
+ FromLinter: linterName,
})
}
}
@@ -146,7 +146,7 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r
Column: 1,
},
Text: fmt.Sprintf("line is more than %d characters", bufio.MaxScanTokenSize),
- FromLinter: lllName,
+ FromLinter: linterName,
})
} else {
return nil, fmt.Errorf("can't scan file %s: %w", filename, err)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/loggercheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/loggercheck/loggercheck.go
index a4a63722c..077e8a512 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/loggercheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/loggercheck/loggercheck.go
@@ -1,4 +1,4 @@
-package golinters
+package loggercheck
import (
"github.com/timonwong/loggercheck"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewLoggerCheck(settings *config.LoggerCheckSettings) *goanalysis.Linter {
+func New(settings *config.LoggerCheckSettings) *goanalysis.Linter {
var opts []loggercheck.Option
if settings != nil {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/maintidx.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/maintidx/maintidx.go
index b5751227b..08f12369e 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/maintidx.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/maintidx/maintidx.go
@@ -1,4 +1,4 @@
-package golinters
+package maintidx
import (
"github.com/yagipy/maintidx"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewMaintIdx(cfg *config.MaintIdxSettings) *goanalysis.Linter {
+func New(cfg *config.MaintIdxSettings) *goanalysis.Linter {
analyzer := maintidx.Analyzer
cfgMap := map[string]map[string]any{
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/makezero.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/makezero/makezero.go
index 9aeb08a60..ae4bf2184 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/makezero.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/makezero/makezero.go
@@ -1,4 +1,4 @@
-package golinters
+package makezero
import (
"fmt"
@@ -13,14 +13,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const makezeroName = "makezero"
+const linterName = "makezero"
-func NewMakezero(settings *config.MakezeroSettings) *goanalysis.Linter {
+func New(settings *config.MakezeroSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: makezeroName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runMakeZero(pass, settings)
@@ -41,7 +41,7 @@ func NewMakezero(settings *config.MakezeroSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- makezeroName,
+ linterName,
"Finds slice declarations with non-zero initial length",
[]*analysis.Analyzer{analyzer},
nil,
@@ -65,7 +65,7 @@ func runMakeZero(pass *analysis.Pass, settings *config.MakezeroSettings) ([]goan
issues = append(issues, goanalysis.NewIssue(&result.Issue{
Pos: hint.Position(),
Text: hint.Details(),
- FromLinter: makezeroName,
+ FromLinter: linterName,
}, pass))
}
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/mirror.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/mirror/mirror.go
index 3d5766fe8..34b880b52 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/mirror.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/mirror/mirror.go
@@ -1,4 +1,4 @@
-package golinters
+package mirror
import (
"sync"
@@ -11,7 +11,7 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-func NewMirror() *goanalysis.Linter {
+func New() *goanalysis.Linter {
var (
mu sync.Mutex
issues []goanalysis.Issue
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/misspell.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/misspell/misspell.go
index 70ee5602c..44409cec9 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/misspell.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/misspell/misspell.go
@@ -1,4 +1,4 @@
-package golinters
+package misspell
import (
"fmt"
@@ -17,20 +17,20 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const misspellName = "misspell"
+const linterName = "misspell"
-func NewMisspell(settings *config.MisspellSettings) *goanalysis.Linter {
+func New(settings *config.MisspellSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: misspellName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: goanalysis.DummyRun,
}
return goanalysis.NewLinter(
- misspellName,
+ linterName,
"Finds commonly misspelled English words",
[]*analysis.Analyzer{analyzer},
nil,
@@ -153,7 +153,7 @@ func runMisspellOnFile(lintCtx *linter.Context, filename string, replacer *missp
res = append(res, result.Issue{
Pos: pos,
Text: text,
- FromLinter: misspellName,
+ FromLinter: linterName,
Replacement: replacement,
})
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/mnd/mnd.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/mnd/mnd.go
new file mode 100644
index 000000000..9aa8692ff
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/mnd/mnd.go
@@ -0,0 +1,63 @@
+package mnd
+
+import (
+ mnd "github.com/tommy-muehle/go-mnd/v2"
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/golangci/golangci-lint/pkg/config"
+ "github.com/golangci/golangci-lint/pkg/goanalysis"
+)
+
+func New(settings *config.MndSettings) *goanalysis.Linter {
+ return newMND(mnd.Analyzer, settings, nil)
+}
+
+func NewGoMND(settings *config.GoMndSettings) *goanalysis.Linter {
+ // shallow copy because mnd.Analyzer is a global variable.
+ a := new(analysis.Analyzer)
+ *a = *mnd.Analyzer
+
+ // Used to force the analyzer name to use the same name as the linter.
+ // This is required to avoid displaying the analyzer name inside the issue text.
+ a.Name = "gomnd"
+
+ var linterCfg map[string]map[string]any
+
+ if settings != nil && len(settings.Settings) > 0 {
+ // Convert deprecated setting.
+ linterCfg = map[string]map[string]any{
+ a.Name: settings.Settings["mnd"],
+ }
+ }
+
+ return newMND(a, &settings.MndSettings, linterCfg)
+}
+
+func newMND(a *analysis.Analyzer, settings *config.MndSettings, linterCfg map[string]map[string]any) *goanalysis.Linter {
+ if len(linterCfg) == 0 && settings != nil {
+ cfg := make(map[string]any)
+ if len(settings.Checks) > 0 {
+ cfg["checks"] = settings.Checks
+ }
+ if len(settings.IgnoredNumbers) > 0 {
+ cfg["ignored-numbers"] = settings.IgnoredNumbers
+ }
+ if len(settings.IgnoredFiles) > 0 {
+ cfg["ignored-files"] = settings.IgnoredFiles
+ }
+ if len(settings.IgnoredFunctions) > 0 {
+ cfg["ignored-functions"] = settings.IgnoredFunctions
+ }
+
+ linterCfg = map[string]map[string]any{
+ a.Name: cfg,
+ }
+ }
+
+ return goanalysis.NewLinter(
+ a.Name,
+ "An analyzer to detect magic numbers.",
+ []*analysis.Analyzer{a},
+ linterCfg,
+ ).WithLoadMode(goanalysis.LoadModeSyntax)
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/musttag.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/musttag/musttag.go
index 9b97ed4f3..30047abfc 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/musttag.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/musttag/musttag.go
@@ -1,4 +1,4 @@
-package golinters
+package musttag
import (
"go-simpler.org/musttag"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewMustTag(setting *config.MustTagSettings) *goanalysis.Linter {
+func New(setting *config.MustTagSettings) *goanalysis.Linter {
var funcs []musttag.Func
if setting != nil {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nakedret.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nakedret/nakedret.go
index 083145804..beabf2cd8 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nakedret.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nakedret/nakedret.go
@@ -1,4 +1,4 @@
-package golinters
+package nakedret
import (
"github.com/alexkohler/nakedret/v2"
@@ -8,13 +8,13 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewNakedret(settings *config.NakedretSettings) *goanalysis.Linter {
- var maxLines int
+func New(settings *config.NakedretSettings) *goanalysis.Linter {
+ var maxLines uint
if settings != nil {
maxLines = settings.MaxFuncLines
}
- a := nakedret.NakedReturnAnalyzer(uint(maxLines))
+ a := nakedret.NakedReturnAnalyzer(maxLines)
return goanalysis.NewLinter(
a.Name,
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nestif.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nestif/nestif.go
index 4daad31cd..43be973b0 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nestif.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nestif/nestif.go
@@ -1,4 +1,4 @@
-package golinters
+package nestif
import (
"sort"
@@ -13,9 +13,9 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const nestifName = "nestif"
+const linterName = "nestif"
-func NewNestif(settings *config.NestifSettings) *goanalysis.Linter {
+func New(settings *config.NestifSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
@@ -38,7 +38,7 @@ func NewNestif(settings *config.NestifSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- nestifName,
+ linterName,
"Reports deeply nested if statements",
[]*analysis.Analyzer{analyzer},
nil,
@@ -70,7 +70,7 @@ func runNestIf(pass *analysis.Pass, settings *config.NestifSettings) []goanalysi
issues = append(issues, goanalysis.NewIssue(&result.Issue{
Pos: i.Pos,
Text: i.Message,
- FromLinter: nestifName,
+ FromLinter: linterName,
}, pass))
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilerr.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilerr/nilerr.go
index 79d86b55a..c9e466905 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilerr.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilerr/nilerr.go
@@ -1,4 +1,4 @@
-package golinters
+package nilerr
import (
"github.com/gostaticanalysis/nilerr"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewNilErr() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := nilerr.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnil.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnil/nilnil.go
index 539a65768..c9237035d 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnil.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nilnil/nilnil.go
@@ -1,4 +1,4 @@
-package golinters
+package nilnil
import (
"strings"
@@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewNilNil(cfg *config.NilNilSettings) *goanalysis.Linter {
+func New(cfg *config.NilNilSettings) *goanalysis.Linter {
a := analyzer.New()
cfgMap := make(map[string]map[string]any)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nlreturn.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nlreturn/nlreturn.go
index a7a65e2a3..509218808 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nlreturn.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nlreturn/nlreturn.go
@@ -1,4 +1,4 @@
-package golinters
+package nlreturn
import (
"github.com/ssgreg/nlreturn/v2/pkg/nlreturn"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewNLReturn(settings *config.NlreturnSettings) *goanalysis.Linter {
+func New(settings *config.NlreturnSettings) *goanalysis.Linter {
a := nlreturn.NewAnalyzer()
cfg := map[string]map[string]any{}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/noctx.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/noctx/noctx.go
index e62f6cbf3..8a063c613 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/noctx.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/noctx/noctx.go
@@ -1,4 +1,4 @@
-package golinters
+package noctx
import (
"github.com/sonatard/noctx"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewNoctx() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := noctx.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint.go
deleted file mode 100644
index 8ed2dceb9..000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package golinters
-
-import (
- "fmt"
- "go/ast"
- "sync"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/golangci/golangci-lint/pkg/config"
- "github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/nolintlint"
- "github.com/golangci/golangci-lint/pkg/lint/linter"
- "github.com/golangci/golangci-lint/pkg/result"
-)
-
-const NoLintLintName = "nolintlint"
-
-func NewNoLintLint(settings *config.NoLintLintSettings) *goanalysis.Linter {
- var mu sync.Mutex
- var resIssues []goanalysis.Issue
-
- analyzer := &analysis.Analyzer{
- Name: NoLintLintName,
- Doc: goanalysis.TheOnlyanalyzerDoc,
- Run: func(pass *analysis.Pass) (any, error) {
- issues, err := runNoLintLint(pass, settings)
- if err != nil {
- return nil, err
- }
-
- if len(issues) == 0 {
- return nil, nil
- }
-
- mu.Lock()
- resIssues = append(resIssues, issues...)
- mu.Unlock()
-
- return nil, nil
- },
- }
-
- return goanalysis.NewLinter(
- NoLintLintName,
- "Reports ill-formed or insufficient nolint directives",
- []*analysis.Analyzer{analyzer},
- nil,
- ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
- return resIssues
- }).WithLoadMode(goanalysis.LoadModeSyntax)
-}
-
-func runNoLintLint(pass *analysis.Pass, settings *config.NoLintLintSettings) ([]goanalysis.Issue, error) {
- var needs nolintlint.Needs
- if settings.RequireExplanation {
- needs |= nolintlint.NeedsExplanation
- }
- if settings.RequireSpecific {
- needs |= nolintlint.NeedsSpecific
- }
- if !settings.AllowUnused {
- needs |= nolintlint.NeedsUnused
- }
-
- lnt, err := nolintlint.NewLinter(needs, settings.AllowNoExplanation)
- if err != nil {
- return nil, err
- }
-
- nodes := make([]ast.Node, 0, len(pass.Files))
- for _, n := range pass.Files {
- nodes = append(nodes, n)
- }
-
- lintIssues, err := lnt.Run(pass.Fset, nodes...)
- if err != nil {
- return nil, fmt.Errorf("linter failed to run: %w", err)
- }
-
- var issues []goanalysis.Issue
-
- for _, i := range lintIssues {
- expectNoLint := false
- var expectedNolintLinter string
- if ii, ok := i.(nolintlint.UnusedCandidate); ok {
- expectedNolintLinter = ii.ExpectedLinter
- expectNoLint = true
- }
-
- issue := &result.Issue{
- FromLinter: NoLintLintName,
- Text: i.Details(),
- Pos: i.Position(),
- ExpectNoLint: expectNoLint,
- ExpectedNoLintLinter: expectedNolintLinter,
- Replacement: i.Replacement(),
- }
-
- issues = append(issues, goanalysis.NewIssue(issue, pass))
- }
-
- return issues, nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/README.md b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/README.md
index 1643df7a5..e4d48f012 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/README.md
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/README.md
@@ -1,7 +1,7 @@
# nolintlint
nolintlint is a Go static analysis tool to find ill-formed or insufficiently explained `//nolint` directives for golangci-lint
-(or any other linter, using this package)
+(or any other linter, using this package)
## Purpose
@@ -15,7 +15,7 @@ func hash(data []byte) []byte {
}
```
-In the above case, nolint directives are present but the user has no idea why this is being done or which linter
+In the above case, nolint directives are present, but the user has no idea why this is being done or which linter
is being suppressed (in this case, gosec recommends against use of md5). `nolintlint` can require that the code provide an explanation, which might look as follows:
```Go
@@ -26,6 +26,6 @@ func hash(data []byte) []byte {
}
```
-`nolintlint` can also identify cases where you may have written `// nolint`. Finally `nolintlint`, can also enforce that you
+`nolintlint` can also identify cases where you may have written `// nolint`. Finally, `nolintlint`, can also enforce that you
use the machine-readable nolint directive format `//nolint:all` and that you mention what linter is being suppressed, as shown above when we write `//nolint:gosec`.
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/nolintlint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/nolintlint.go
new file mode 100644
index 000000000..08dd74378
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal/nolintlint.go
@@ -0,0 +1,311 @@
+// Package internal provides a linter to ensure that all //nolint directives are followed by explanations
+package internal
+
+import (
+ "fmt"
+ "go/ast"
+ "go/token"
+ "regexp"
+ "strings"
+ "unicode"
+
+ "github.com/golangci/golangci-lint/pkg/result"
+)
+
+type BaseIssue struct {
+ fullDirective string
+ directiveWithOptionalLeadingSpace string
+ position token.Position
+ replacement *result.Replacement
+}
+
+//nolint:gocritic // TODO(ldez) must be change in the future.
+func (b BaseIssue) Position() token.Position {
+ return b.position
+}
+
+//nolint:gocritic // TODO(ldez) must be change in the future.
+func (b BaseIssue) Replacement() *result.Replacement {
+ return b.replacement
+}
+
+type ExtraLeadingSpace struct {
+ BaseIssue
+}
+
+//nolint:gocritic // TODO(ldez) must be change in the future.
+func (i ExtraLeadingSpace) Details() string {
+ return fmt.Sprintf("directive `%s` should not have more than one leading space", i.fullDirective)
+}
+
+func (i ExtraLeadingSpace) String() string { return toString(i) }
+
+type NotMachine struct {
+ BaseIssue
+}
+
+//nolint:gocritic // TODO(ldez) must be change in the future.
+func (i NotMachine) Details() string {
+ expected := i.fullDirective[:2] + strings.TrimLeftFunc(i.fullDirective[2:], unicode.IsSpace)
+ return fmt.Sprintf("directive `%s` should be written without leading space as `%s`",
+ i.fullDirective, expected)
+}
+
+func (i NotMachine) String() string { return toString(i) }
+
+type NotSpecific struct {
+ BaseIssue
+}
+
+//nolint:gocritic // TODO(ldez) must be change in the future.
+func (i NotSpecific) Details() string {
+ return fmt.Sprintf("directive `%s` should mention specific linter such as `%s:my-linter`",
+ i.fullDirective, i.directiveWithOptionalLeadingSpace)
+}
+
+func (i NotSpecific) String() string { return toString(i) }
+
+type ParseError struct {
+ BaseIssue
+}
+
+//nolint:gocritic // TODO(ldez) must be change in the future.
+func (i ParseError) Details() string {
+ return fmt.Sprintf("directive `%s` should match `%s[:<comma-separated-linters>] [// <explanation>]`",
+ i.fullDirective,
+ i.directiveWithOptionalLeadingSpace)
+}
+
+func (i ParseError) String() string { return toString(i) }
+
+type NoExplanation struct {
+ BaseIssue
+ fullDirectiveWithoutExplanation string
+}
+
+//nolint:gocritic // TODO(ldez) must be change in the future.
+func (i NoExplanation) Details() string {
+ return fmt.Sprintf("directive `%s` should provide explanation such as `%s // this is why`",
+ i.fullDirective, i.fullDirectiveWithoutExplanation)
+}
+
+func (i NoExplanation) String() string { return toString(i) }
+
+type UnusedCandidate struct {
+ BaseIssue
+ ExpectedLinter string
+}
+
+//nolint:gocritic // TODO(ldez) must be change in the future.
+func (i UnusedCandidate) Details() string {
+ details := fmt.Sprintf("directive `%s` is unused", i.fullDirective)
+ if i.ExpectedLinter != "" {
+ details += fmt.Sprintf(" for linter %q", i.ExpectedLinter)
+ }
+ return details
+}
+
+func (i UnusedCandidate) String() string { return toString(i) }
+
+func toString(issue Issue) string {
+ return fmt.Sprintf("%s at %s", issue.Details(), issue.Position())
+}
+
+type Issue interface {
+ Details() string
+ Position() token.Position
+ String() string
+ Replacement() *result.Replacement
+}
+
+type Needs uint
+
+const (
+ NeedsMachineOnly Needs = 1 << iota
+ NeedsSpecific
+ NeedsExplanation
+ NeedsUnused
+ NeedsAll = NeedsMachineOnly | NeedsSpecific | NeedsExplanation
+)
+
+var commentPattern = regexp.MustCompile(`^//\s*(nolint)(:\s*[\w-]+\s*(?:,\s*[\w-]+\s*)*)?\b`)
+
+// matches a complete nolint directive
+var fullDirectivePattern = regexp.MustCompile(`^//\s*nolint(?::(\s*[\w-]+\s*(?:,\s*[\w-]+\s*)*))?\s*(//.*)?\s*\n?$`)
+
+type Linter struct {
+ needs Needs // indicates which linter checks to perform
+ excludeByLinter map[string]bool
+}
+
+// NewLinter creates a linter that enforces that the provided directives fulfill the provided requirements
+func NewLinter(needs Needs, excludes []string) (*Linter, error) {
+ excludeByName := make(map[string]bool)
+ for _, e := range excludes {
+ excludeByName[e] = true
+ }
+
+ return &Linter{
+ needs: needs | NeedsMachineOnly,
+ excludeByLinter: excludeByName,
+ }, nil
+}
+
+var (
+ leadingSpacePattern = regexp.MustCompile(`^//(\s*)`)
+ trailingBlankExplanation = regexp.MustCompile(`\s*(//\s*)?$`)
+)
+
+//nolint:funlen,gocyclo // the function is going to be refactored in the future
+func (l Linter) Run(fset *token.FileSet, nodes ...ast.Node) ([]Issue, error) {
+ var issues []Issue
+
+ for _, node := range nodes {
+ file, ok := node.(*ast.File)
+ if !ok {
+ continue
+ }
+
+ for _, c := range file.Comments {
+ for _, comment := range c.List {
+ if !commentPattern.MatchString(comment.Text) {
+ continue
+ }
+
+ // check for a space between the "//" and the directive
+ leadingSpaceMatches := leadingSpacePattern.FindStringSubmatch(comment.Text)
+
+ var leadingSpace string
+ if len(leadingSpaceMatches) > 0 {
+ leadingSpace = leadingSpaceMatches[1]
+ }
+
+ directiveWithOptionalLeadingSpace := "//"
+ if leadingSpace != "" {
+ directiveWithOptionalLeadingSpace += " "
+ }
+
+ split := strings.Split(strings.SplitN(comment.Text, ":", 2)[0], "//")
+ directiveWithOptionalLeadingSpace += strings.TrimSpace(split[1])
+
+ pos := fset.Position(comment.Pos())
+ end := fset.Position(comment.End())
+
+ base := BaseIssue{
+ fullDirective: comment.Text,
+ directiveWithOptionalLeadingSpace: directiveWithOptionalLeadingSpace,
+ position: pos,
+ }
+
+ // check for, report and eliminate leading spaces, so we can check for other issues
+ if leadingSpace != "" {
+ removeWhitespace := &result.Replacement{
+ Inline: &result.InlineFix{
+ StartCol: pos.Column + 1,
+ Length: len(leadingSpace),
+ NewString: "",
+ },
+ }
+ if (l.needs & NeedsMachineOnly) != 0 {
+ issue := NotMachine{BaseIssue: base}
+ issue.BaseIssue.replacement = removeWhitespace
+ issues = append(issues, issue)
+ } else if len(leadingSpace) > 1 {
+ issue := ExtraLeadingSpace{BaseIssue: base}
+ issue.BaseIssue.replacement = removeWhitespace
+ issue.BaseIssue.replacement.Inline.NewString = " " // assume a single space was intended
+ issues = append(issues, issue)
+ }
+ }
+
+ fullMatches := fullDirectivePattern.FindStringSubmatch(comment.Text)
+ if len(fullMatches) == 0 {
+ issues = append(issues, ParseError{BaseIssue: base})
+ continue
+ }
+
+ lintersText, explanation := fullMatches[1], fullMatches[2]
+
+ var linters []string
+ if lintersText != "" && !strings.HasPrefix(lintersText, "all") {
+ lls := strings.Split(lintersText, ",")
+ linters = make([]string, 0, len(lls))
+ rangeStart := (pos.Column - 1) + len("//") + len(leadingSpace) + len("nolint:")
+ for i, ll := range lls {
+ rangeEnd := rangeStart + len(ll)
+ if i < len(lls)-1 {
+ rangeEnd++ // include trailing comma
+ }
+ trimmedLinterName := strings.TrimSpace(ll)
+ if trimmedLinterName != "" {
+ linters = append(linters, trimmedLinterName)
+ }
+ rangeStart = rangeEnd
+ }
+ }
+
+ if (l.needs & NeedsSpecific) != 0 {
+ if len(linters) == 0 {
+ issues = append(issues, NotSpecific{BaseIssue: base})
+ }
+ }
+
+ // when detecting unused directives, we send all the directives through and filter them out in the nolint processor
+ if (l.needs & NeedsUnused) != 0 {
+ removeNolintCompletely := &result.Replacement{}
+
+ startCol := pos.Column - 1
+
+ if startCol == 0 {
+ // if the directive starts from a new line, remove the line
+ removeNolintCompletely.NeedOnlyDelete = true
+ } else {
+ removeNolintCompletely.Inline = &result.InlineFix{
+ StartCol: startCol,
+ Length: end.Column - pos.Column,
+ NewString: "",
+ }
+ }
+
+ if len(linters) == 0 {
+ issue := UnusedCandidate{BaseIssue: base}
+ issue.replacement = removeNolintCompletely
+ issues = append(issues, issue)
+ } else {
+ for _, linter := range linters {
+ issue := UnusedCandidate{BaseIssue: base, ExpectedLinter: linter}
+ // only offer replacement if there is a single linter
+ // because of issues around commas and the possibility of all
+ // linters being removed
+ if len(linters) == 1 {
+ issue.replacement = removeNolintCompletely
+ }
+ issues = append(issues, issue)
+ }
+ }
+ }
+
+ if (l.needs&NeedsExplanation) != 0 && (explanation == "" || strings.TrimSpace(explanation) == "//") {
+ needsExplanation := len(linters) == 0 // if no linters are mentioned, we must have explanation
+ // otherwise, check if we are excluding all the mentioned linters
+ for _, ll := range linters {
+ if !l.excludeByLinter[ll] { // if a linter does require explanation
+ needsExplanation = true
+ break
+ }
+ }
+
+ if needsExplanation {
+ fullDirectiveWithoutExplanation := trailingBlankExplanation.ReplaceAllString(comment.Text, "")
+ issues = append(issues, NoExplanation{
+ BaseIssue: base,
+ fullDirectiveWithoutExplanation: fullDirectiveWithoutExplanation,
+ })
+ }
+ }
+ }
+ }
+ }
+
+ return issues, nil
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/nolintlint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/nolintlint.go
index 1bce5ef5d..9f04454a5 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/nolintlint.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nolintlint/nolintlint.go
@@ -1,303 +1,103 @@
-// Package nolintlint provides a linter to ensure that all //nolint directives are followed by explanations
package nolintlint
import (
"fmt"
"go/ast"
- "go/token"
- "regexp"
- "strings"
- "unicode"
+ "sync"
+ "golang.org/x/tools/go/analysis"
+
+ "github.com/golangci/golangci-lint/pkg/config"
+ "github.com/golangci/golangci-lint/pkg/goanalysis"
+ "github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal"
+ "github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/result"
)
-type BaseIssue struct {
- fullDirective string
- directiveWithOptionalLeadingSpace string
- position token.Position
- replacement *result.Replacement
-}
+const LinterName = "nolintlint"
-//nolint:gocritic // TODO(ldez) must be change in the future.
-func (b BaseIssue) Position() token.Position {
- return b.position
-}
-
-//nolint:gocritic // TODO(ldez) must be change in the future.
-func (b BaseIssue) Replacement() *result.Replacement {
- return b.replacement
-}
-
-type ExtraLeadingSpace struct {
- BaseIssue
-}
-
-//nolint:gocritic // TODO(ldez) must be change in the future.
-func (i ExtraLeadingSpace) Details() string {
- return fmt.Sprintf("directive `%s` should not have more than one leading space", i.fullDirective)
-}
-
-func (i ExtraLeadingSpace) String() string { return toString(i) }
-
-type NotMachine struct {
- BaseIssue
-}
-
-//nolint:gocritic // TODO(ldez) must be change in the future.
-func (i NotMachine) Details() string {
- expected := i.fullDirective[:2] + strings.TrimLeftFunc(i.fullDirective[2:], unicode.IsSpace)
- return fmt.Sprintf("directive `%s` should be written without leading space as `%s`",
- i.fullDirective, expected)
-}
-
-func (i NotMachine) String() string { return toString(i) }
-
-type NotSpecific struct {
- BaseIssue
-}
+func New(settings *config.NoLintLintSettings) *goanalysis.Linter {
+ var mu sync.Mutex
+ var resIssues []goanalysis.Issue
-//nolint:gocritic // TODO(ldez) must be change in the future.
-func (i NotSpecific) Details() string {
- return fmt.Sprintf("directive `%s` should mention specific linter such as `%s:my-linter`",
- i.fullDirective, i.directiveWithOptionalLeadingSpace)
-}
-
-func (i NotSpecific) String() string { return toString(i) }
-
-type ParseError struct {
- BaseIssue
-}
-
-//nolint:gocritic // TODO(ldez) must be change in the future.
-func (i ParseError) Details() string {
- return fmt.Sprintf("directive `%s` should match `%s[:<comma-separated-linters>] [// <explanation>]`",
- i.fullDirective,
- i.directiveWithOptionalLeadingSpace)
-}
-
-func (i ParseError) String() string { return toString(i) }
-
-type NoExplanation struct {
- BaseIssue
- fullDirectiveWithoutExplanation string
-}
-
-//nolint:gocritic // TODO(ldez) must be change in the future.
-func (i NoExplanation) Details() string {
- return fmt.Sprintf("directive `%s` should provide explanation such as `%s // this is why`",
- i.fullDirective, i.fullDirectiveWithoutExplanation)
-}
+ analyzer := &analysis.Analyzer{
+ Name: LinterName,
+ Doc: goanalysis.TheOnlyanalyzerDoc,
+ Run: func(pass *analysis.Pass) (any, error) {
+ issues, err := runNoLintLint(pass, settings)
+ if err != nil {
+ return nil, err
+ }
-func (i NoExplanation) String() string { return toString(i) }
+ if len(issues) == 0 {
+ return nil, nil
+ }
-type UnusedCandidate struct {
- BaseIssue
- ExpectedLinter string
-}
+ mu.Lock()
+ resIssues = append(resIssues, issues...)
+ mu.Unlock()
-//nolint:gocritic // TODO(ldez) must be change in the future.
-func (i UnusedCandidate) Details() string {
- details := fmt.Sprintf("directive `%s` is unused", i.fullDirective)
- if i.ExpectedLinter != "" {
- details += fmt.Sprintf(" for linter %q", i.ExpectedLinter)
+ return nil, nil
+ },
}
- return details
-}
-
-func (i UnusedCandidate) String() string { return toString(i) }
-func toString(issue Issue) string {
- return fmt.Sprintf("%s at %s", issue.Details(), issue.Position())
+ return goanalysis.NewLinter(
+ LinterName,
+ "Reports ill-formed or insufficient nolint directives",
+ []*analysis.Analyzer{analyzer},
+ nil,
+ ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
+ return resIssues
+ }).WithLoadMode(goanalysis.LoadModeSyntax)
}
-type Issue interface {
- Details() string
- Position() token.Position
- String() string
- Replacement() *result.Replacement
-}
-
-type Needs uint
-
-const (
- NeedsMachineOnly Needs = 1 << iota
- NeedsSpecific
- NeedsExplanation
- NeedsUnused
- NeedsAll = NeedsMachineOnly | NeedsSpecific | NeedsExplanation
-)
-
-var commentPattern = regexp.MustCompile(`^//\s*(nolint)(:\s*[\w-]+\s*(?:,\s*[\w-]+\s*)*)?\b`)
-
-// matches a complete nolint directive
-var fullDirectivePattern = regexp.MustCompile(`^//\s*nolint(?::(\s*[\w-]+\s*(?:,\s*[\w-]+\s*)*))?\s*(//.*)?\s*\n?$`)
-
-type Linter struct {
- needs Needs // indicates which linter checks to perform
- excludeByLinter map[string]bool
-}
+func runNoLintLint(pass *analysis.Pass, settings *config.NoLintLintSettings) ([]goanalysis.Issue, error) {
+ var needs internal.Needs
+ if settings.RequireExplanation {
+ needs |= internal.NeedsExplanation
+ }
+ if settings.RequireSpecific {
+ needs |= internal.NeedsSpecific
+ }
+ if !settings.AllowUnused {
+ needs |= internal.NeedsUnused
+ }
-// NewLinter creates a linter that enforces that the provided directives fulfill the provided requirements
-func NewLinter(needs Needs, excludes []string) (*Linter, error) {
- excludeByName := make(map[string]bool)
- for _, e := range excludes {
- excludeByName[e] = true
+ lnt, err := internal.NewLinter(needs, settings.AllowNoExplanation)
+ if err != nil {
+ return nil, err
}
- return &Linter{
- needs: needs | NeedsMachineOnly,
- excludeByLinter: excludeByName,
- }, nil
-}
+ nodes := make([]ast.Node, 0, len(pass.Files))
+ for _, n := range pass.Files {
+ nodes = append(nodes, n)
+ }
-var (
- leadingSpacePattern = regexp.MustCompile(`^//(\s*)`)
- trailingBlankExplanation = regexp.MustCompile(`\s*(//\s*)?$`)
-)
+ lintIssues, err := lnt.Run(pass.Fset, nodes...)
+ if err != nil {
+ return nil, fmt.Errorf("linter failed to run: %w", err)
+ }
-//nolint:funlen,gocyclo // the function is going to be refactored in the future
-func (l Linter) Run(fset *token.FileSet, nodes ...ast.Node) ([]Issue, error) {
- var issues []Issue
+ var issues []goanalysis.Issue
- for _, node := range nodes {
- file, ok := node.(*ast.File)
- if !ok {
- continue
+ for _, i := range lintIssues {
+ expectNoLint := false
+ var expectedNolintLinter string
+ if ii, ok := i.(internal.UnusedCandidate); ok {
+ expectedNolintLinter = ii.ExpectedLinter
+ expectNoLint = true
}
- for _, c := range file.Comments {
- for _, comment := range c.List {
- if !commentPattern.MatchString(comment.Text) {
- continue
- }
-
- // check for a space between the "//" and the directive
- leadingSpaceMatches := leadingSpacePattern.FindStringSubmatch(comment.Text)
-
- var leadingSpace string
- if len(leadingSpaceMatches) > 0 {
- leadingSpace = leadingSpaceMatches[1]
- }
-
- directiveWithOptionalLeadingSpace := "//"
- if leadingSpace != "" {
- directiveWithOptionalLeadingSpace += " "
- }
-
- split := strings.Split(strings.SplitN(comment.Text, ":", 2)[0], "//")
- directiveWithOptionalLeadingSpace += strings.TrimSpace(split[1])
-
- pos := fset.Position(comment.Pos())
- end := fset.Position(comment.End())
-
- base := BaseIssue{
- fullDirective: comment.Text,
- directiveWithOptionalLeadingSpace: directiveWithOptionalLeadingSpace,
- position: pos,
- }
-
- // check for, report and eliminate leading spaces, so we can check for other issues
- if leadingSpace != "" {
- removeWhitespace := &result.Replacement{
- Inline: &result.InlineFix{
- StartCol: pos.Column + 1,
- Length: len(leadingSpace),
- NewString: "",
- },
- }
- if (l.needs & NeedsMachineOnly) != 0 {
- issue := NotMachine{BaseIssue: base}
- issue.BaseIssue.replacement = removeWhitespace
- issues = append(issues, issue)
- } else if len(leadingSpace) > 1 {
- issue := ExtraLeadingSpace{BaseIssue: base}
- issue.BaseIssue.replacement = removeWhitespace
- issue.BaseIssue.replacement.Inline.NewString = " " // assume a single space was intended
- issues = append(issues, issue)
- }
- }
-
- fullMatches := fullDirectivePattern.FindStringSubmatch(comment.Text)
- if len(fullMatches) == 0 {
- issues = append(issues, ParseError{BaseIssue: base})
- continue
- }
-
- lintersText, explanation := fullMatches[1], fullMatches[2]
-
- var linters []string
- if lintersText != "" && !strings.HasPrefix(lintersText, "all") {
- lls := strings.Split(lintersText, ",")
- linters = make([]string, 0, len(lls))
- rangeStart := (pos.Column - 1) + len("//") + len(leadingSpace) + len("nolint:")
- for i, ll := range lls {
- rangeEnd := rangeStart + len(ll)
- if i < len(lls)-1 {
- rangeEnd++ // include trailing comma
- }
- trimmedLinterName := strings.TrimSpace(ll)
- if trimmedLinterName != "" {
- linters = append(linters, trimmedLinterName)
- }
- rangeStart = rangeEnd
- }
- }
-
- if (l.needs & NeedsSpecific) != 0 {
- if len(linters) == 0 {
- issues = append(issues, NotSpecific{BaseIssue: base})
- }
- }
-
- // when detecting unused directives, we send all the directives through and filter them out in the nolint processor
- if (l.needs & NeedsUnused) != 0 {
- removeNolintCompletely := &result.Replacement{
- Inline: &result.InlineFix{
- StartCol: pos.Column - 1,
- Length: end.Column - pos.Column,
- NewString: "",
- },
- }
-
- if len(linters) == 0 {
- issue := UnusedCandidate{BaseIssue: base}
- issue.replacement = removeNolintCompletely
- issues = append(issues, issue)
- } else {
- for _, linter := range linters {
- issue := UnusedCandidate{BaseIssue: base, ExpectedLinter: linter}
- // only offer replacement if there is a single linter
- // because of issues around commas and the possibility of all
- // linters being removed
- if len(linters) == 1 {
- issue.replacement = removeNolintCompletely
- }
- issues = append(issues, issue)
- }
- }
- }
-
- if (l.needs&NeedsExplanation) != 0 && (explanation == "" || strings.TrimSpace(explanation) == "//") {
- needsExplanation := len(linters) == 0 // if no linters are mentioned, we must have explanation
- // otherwise, check if we are excluding all the mentioned linters
- for _, ll := range linters {
- if !l.excludeByLinter[ll] { // if a linter does require explanation
- needsExplanation = true
- break
- }
- }
-
- if needsExplanation {
- fullDirectiveWithoutExplanation := trailingBlankExplanation.ReplaceAllString(comment.Text, "")
- issues = append(issues, NoExplanation{
- BaseIssue: base,
- fullDirectiveWithoutExplanation: fullDirectiveWithoutExplanation,
- })
- }
- }
- }
+ issue := &result.Issue{
+ FromLinter: LinterName,
+ Text: i.Details(),
+ Pos: i.Position(),
+ ExpectNoLint: expectNoLint,
+ ExpectedNoLintLinter: expectedNolintLinter,
+ Replacement: i.Replacement(),
}
+
+ issues = append(issues, goanalysis.NewIssue(issue, pass))
}
return issues, nil
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns/nonamedreturns.go
index ccfd5d682..42a618e64 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns/nonamedreturns.go
@@ -1,4 +1,4 @@
-package golinters
+package nonamedreturns
import (
"github.com/firefart/nonamedreturns/analyzer"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewNoNamedReturns(settings *config.NoNamedReturnsSettings) *goanalysis.Linter {
+func New(settings *config.NoNamedReturnsSettings) *goanalysis.Linter {
a := analyzer.Analyzer
var cfg map[string]map[string]any
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport/nosprintfhostport.go
index a4fdcb859..8f06ae1f6 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport/nosprintfhostport.go
@@ -1,4 +1,4 @@
-package golinters
+package nosprintfhostport
import (
"github.com/stbenjam/no-sprintf-host-port/pkg/analyzer"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewNoSprintfHostPort() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := analyzer.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/paralleltest.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/paralleltest/paralleltest.go
index 55fc7548d..0c908fa38 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/paralleltest.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/paralleltest/paralleltest.go
@@ -1,4 +1,4 @@
-package golinters
+package paralleltest
import (
"github.com/kunwardeep/paralleltest/pkg/paralleltest"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewParallelTest(settings *config.ParallelTestSettings) *goanalysis.Linter {
+func New(settings *config.ParallelTestSettings) *goanalysis.Linter {
a := paralleltest.NewAnalyzer()
var cfg map[string]map[string]any
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/perfsprint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/perfsprint/perfsprint.go
index 8dc3e56aa..a4ead1914 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/perfsprint.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/perfsprint/perfsprint.go
@@ -1,4 +1,4 @@
-package golinters
+package perfsprint
import (
"github.com/catenacyber/perfsprint/analyzer"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewPerfSprint(settings *config.PerfSprintSettings) *goanalysis.Linter {
+func New(settings *config.PerfSprintSettings) *goanalysis.Linter {
a := analyzer.New()
cfg := map[string]map[string]any{
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/prealloc.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/prealloc/prealloc.go
index 944286ee0..ce7ff9d59 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/prealloc.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/prealloc/prealloc.go
@@ -1,4 +1,4 @@
-package golinters
+package prealloc
import (
"fmt"
@@ -14,14 +14,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const preallocName = "prealloc"
+const linterName = "prealloc"
-func NewPreAlloc(settings *config.PreallocSettings) *goanalysis.Linter {
+func New(settings *config.PreallocSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: preallocName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues := runPreAlloc(pass, settings)
@@ -39,7 +39,7 @@ func NewPreAlloc(settings *config.PreallocSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- preallocName,
+ linterName,
"Finds slice declarations that could potentially be pre-allocated",
[]*analysis.Analyzer{analyzer},
nil,
@@ -57,7 +57,7 @@ func runPreAlloc(pass *analysis.Pass, settings *config.PreallocSettings) []goana
issues = append(issues, goanalysis.NewIssue(&result.Issue{
Pos: pass.Fset.Position(hint.Pos),
Text: fmt.Sprintf("Consider pre-allocating %s", internal.FormatCode(hint.DeclaredSliceName, nil)),
- FromLinter: preallocName,
+ FromLinter: linterName,
}, pass))
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/predeclared.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/predeclared/predeclared.go
index e9afa792a..b8d189fd5 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/predeclared.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/predeclared/predeclared.go
@@ -1,4 +1,4 @@
-package golinters
+package predeclared
import (
"github.com/nishanths/predeclared/passes/predeclared"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewPredeclared(settings *config.PredeclaredSettings) *goanalysis.Linter {
+func New(settings *config.PredeclaredSettings) *goanalysis.Linter {
a := predeclared.Analyzer
var cfg map[string]map[string]any
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/promlinter.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/promlinter/promlinter.go
index 59eac1014..5decbbc7c 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/promlinter.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/promlinter/promlinter.go
@@ -1,4 +1,4 @@
-package golinters
+package promlinter
import (
"fmt"
@@ -13,9 +13,9 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const promlinterName = "promlinter"
+const linterName = "promlinter"
-func NewPromlinter(settings *config.PromlinterSettings) *goanalysis.Linter {
+func New(settings *config.PromlinterSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
@@ -28,7 +28,7 @@ func NewPromlinter(settings *config.PromlinterSettings) *goanalysis.Linter {
}
analyzer := &analysis.Analyzer{
- Name: promlinterName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues := runPromLinter(pass, promSettings)
@@ -46,7 +46,7 @@ func NewPromlinter(settings *config.PromlinterSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- promlinterName,
+ linterName,
"Check Prometheus metrics naming via promlint",
[]*analysis.Analyzer{analyzer},
nil,
@@ -67,7 +67,7 @@ func runPromLinter(pass *analysis.Pass, promSettings promlinter.Setting) []goana
issue := result.Issue{
Pos: i.Pos,
Text: fmt.Sprintf("Metric: %s Error: %s", i.Metric, i.Text),
- FromLinter: promlinterName,
+ FromLinter: linterName,
}
issues[k] = goanalysis.NewIssue(&issue, pass)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/protogetter.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/protogetter/protogetter.go
index fdc5b6641..302ce67b8 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/protogetter.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/protogetter/protogetter.go
@@ -1,4 +1,4 @@
-package golinters
+package protogetter
import (
"sync"
@@ -12,7 +12,7 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-func NewProtoGetter(settings *config.ProtoGetterSettings) *goanalysis.Linter {
+func New(settings *config.ProtoGetterSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/reassign.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/reassign/reassign.go
index 43a6ce43a..cfc85635e 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/reassign.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/reassign/reassign.go
@@ -1,4 +1,4 @@
-package golinters
+package reassign
import (
"fmt"
@@ -11,7 +11,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewReassign(settings *config.ReassignSettings) *goanalysis.Linter {
+func New(settings *config.ReassignSettings) *goanalysis.Linter {
a := reassign.NewAnalyzer()
var cfg map[string]map[string]any
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/revive.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/revive/revive.go
index 0715d9370..90ce15db6 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/revive.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/revive/revive.go
@@ -1,4 +1,4 @@
-package golinters
+package revive
import (
"bytes"
@@ -10,6 +10,7 @@ import (
"sync"
"github.com/BurntSushi/toml"
+ hcversion "github.com/hashicorp/go-version"
reviveConfig "github.com/mgechev/revive/config"
"github.com/mgechev/revive/lint"
"github.com/mgechev/revive/rule"
@@ -23,9 +24,9 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const reviveName = "revive"
+const linterName = "revive"
-var reviveDebugf = logutils.Debug(logutils.DebugKeyRevive)
+var debugf = logutils.Debug(logutils.DebugKeyRevive)
// jsonObject defines a JSON object of a failure
type jsonObject struct {
@@ -33,10 +34,7 @@ type jsonObject struct {
lint.Failure `json:",inline"`
}
-// NewRevive returns a new Revive linter.
-//
-
-func NewRevive(settings *config.ReviveSettings) *goanalysis.Linter {
+func New(settings *config.ReviveSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
@@ -47,13 +45,19 @@ func NewRevive(settings *config.ReviveSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- reviveName,
+ linterName,
"Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.",
[]*analysis.Analyzer{analyzer},
nil,
).WithContextSetter(func(lintCtx *linter.Context) {
+ w, err := newWrapper(settings)
+ if err != nil {
+ lintCtx.Log.Errorf("setup revive: %v", err)
+ return
+ }
+
analyzer.Run = func(pass *analysis.Pass) (any, error) {
- issues, err := runRevive(lintCtx, pass, settings)
+ issues, err := w.run(lintCtx, pass)
if err != nil {
return nil, err
}
@@ -73,27 +77,46 @@ func NewRevive(settings *config.ReviveSettings) *goanalysis.Linter {
}).WithLoadMode(goanalysis.LoadModeSyntax)
}
-func runRevive(lintCtx *linter.Context, pass *analysis.Pass, settings *config.ReviveSettings) ([]goanalysis.Issue, error) {
- packages := [][]string{internal.GetFileNames(pass)}
+type wrapper struct {
+ revive lint.Linter
+ formatter lint.Formatter
+ lintingRules []lint.Rule
+ conf *lint.Config
+}
- conf, err := getReviveConfig(settings)
+func newWrapper(settings *config.ReviveSettings) (*wrapper, error) {
+ conf, err := getConfig(settings)
if err != nil {
return nil, err
}
- formatter, err := reviveConfig.GetFormatter("json")
+ conf.GoVersion, err = hcversion.NewVersion(settings.Go)
if err != nil {
return nil, err
}
- revive := lint.New(os.ReadFile, settings.MaxOpenFiles)
+ formatter, err := reviveConfig.GetFormatter("json")
+ if err != nil {
+ return nil, err
+ }
lintingRules, err := reviveConfig.GetLintingRules(conf, []lint.Rule{})
if err != nil {
return nil, err
}
- failures, err := revive.Lint(packages, lintingRules, *conf)
+ return &wrapper{
+ revive: lint.New(os.ReadFile, settings.MaxOpenFiles),
+ formatter: formatter,
+ lintingRules: lintingRules,
+ conf: conf,
+ }, nil
+}
+
+func (w *wrapper) run(lintCtx *linter.Context, pass *analysis.Pass) ([]goanalysis.Issue, error) {
+ packages := [][]string{internal.GetFileNames(pass)}
+
+ failures, err := w.revive.Lint(packages, w.lintingRules, *w.conf)
if err != nil {
return nil, err
}
@@ -103,7 +126,7 @@ func runRevive(lintCtx *linter.Context, pass *analysis.Pass, settings *config.Re
var output string
go func() {
- output, err = formatter.Format(formatChan, *conf)
+ output, err = w.formatter.Format(formatChan, *w.conf)
if err != nil {
lintCtx.Log.Errorf("Format error: %v", err)
}
@@ -111,7 +134,7 @@ func runRevive(lintCtx *linter.Context, pass *analysis.Pass, settings *config.Re
}()
for f := range failures {
- if f.Confidence < conf.Confidence {
+ if f.Confidence < w.conf.Confidence {
continue
}
@@ -129,13 +152,13 @@ func runRevive(lintCtx *linter.Context, pass *analysis.Pass, settings *config.Re
var issues []goanalysis.Issue
for i := range results {
- issues = append(issues, reviveToIssue(pass, &results[i]))
+ issues = append(issues, toIssue(pass, &results[i]))
}
return issues, nil
}
-func reviveToIssue(pass *analysis.Pass, object *jsonObject) goanalysis.Issue {
+func toIssue(pass *analysis.Pass, object *jsonObject) goanalysis.Issue {
lineRangeTo := object.Position.End.Line
if object.RuleName == (&rule.ExportedRule{}).Name() {
lineRangeTo = object.Position.Start.Line
@@ -154,7 +177,7 @@ func reviveToIssue(pass *analysis.Pass, object *jsonObject) goanalysis.Issue {
From: object.Position.Start.Line,
To: lineRangeTo,
},
- FromLinter: reviveName,
+ FromLinter: linterName,
}, pass)
}
@@ -163,10 +186,13 @@ func reviveToIssue(pass *analysis.Pass, object *jsonObject) goanalysis.Issue {
// https://github.com/golangci/golangci-lint/issues/1745
// https://github.com/mgechev/revive/blob/v1.3.7/config/config.go#L217
// https://github.com/mgechev/revive/blob/v1.3.7/config/config.go#L169-L174
-func getReviveConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
+func getConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
conf := defaultConfig()
- if !reflect.DeepEqual(cfg, &config.ReviveSettings{}) {
+ // Since the Go version is dynamic, this value must be neutralized in order to compare with a "zero value" of the configuration structure.
+ zero := &config.ReviveSettings{Go: cfg.Go}
+
+ if !reflect.DeepEqual(cfg, zero) {
rawRoot := createConfigMap(cfg)
buf := bytes.NewBuffer(nil)
@@ -192,7 +218,7 @@ func getReviveConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
conf.Rules[k] = r
}
- reviveDebugf("revive configuration: %#v", conf)
+ debugf("revive configuration: %#v", conf)
return conf, nil
}
@@ -258,7 +284,7 @@ func safeTomlSlice(r []any) []any {
}
// This element is not exported by revive, so we need copy the code.
-// Extracted from https://github.com/mgechev/revive/blob/v1.3.7/config/config.go#L15
+// Extracted from https://github.com/mgechev/revive/blob/v1.3.9/config/config.go#L15
var defaultRules = []lint.Rule{
&rule.VarDeclarationsRule{},
&rule.PackageCommentsRule{},
@@ -341,6 +367,7 @@ var allRules = append([]lint.Rule{
&rule.EnforceRepeatedArgTypeStyleRule{},
&rule.EnforceSliceStyleRule{},
&rule.MaxControlNestingRule{},
+ &rule.CommentsDensityRule{},
}, defaultRules...)
const defaultConfidence = 0.8
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck/rowserrcheck.go
index 17814c7c0..3fe824467 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck/rowserrcheck.go
@@ -1,4 +1,4 @@
-package golinters
+package rowserrcheck
import (
"github.com/jingyugao/rowserrcheck/passes/rowserr"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewRowsErrCheck(settings *config.RowsErrCheckSettings) *goanalysis.Linter {
+func New(settings *config.RowsErrCheckSettings) *goanalysis.Linter {
var pkgs []string
if settings != nil {
pkgs = settings.Packages
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/sloglint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/sloglint/sloglint.go
index 788d0c523..486662577 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/sloglint.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/sloglint/sloglint.go
@@ -1,4 +1,4 @@
-package golinters
+package sloglint
import (
"go-simpler.org/sloglint"
@@ -8,18 +8,19 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewSlogLint(settings *config.SlogLintSettings) *goanalysis.Linter {
+func New(settings *config.SlogLintSettings) *goanalysis.Linter {
var opts *sloglint.Options
if settings != nil {
opts = &sloglint.Options{
NoMixedArgs: settings.NoMixedArgs,
KVOnly: settings.KVOnly,
- NoGlobal: settings.NoGlobal,
AttrOnly: settings.AttrOnly,
- ContextOnly: settings.ContextOnly,
+ NoGlobal: settings.NoGlobal,
+ ContextOnly: settings.Context,
StaticMsg: settings.StaticMsg,
NoRawKeys: settings.NoRawKeys,
KeyNamingCase: settings.KeyNamingCase,
+ ForbiddenKeys: settings.ForbiddenKeys,
ArgsOnSepLines: settings.ArgsOnSepLines,
}
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/spancheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/spancheck/spancheck.go
index 426c318a4..a800a1705 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/spancheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/spancheck/spancheck.go
@@ -1,4 +1,4 @@
-package golinters
+package spancheck
import (
"github.com/jjti/go-spancheck"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewSpancheck(settings *config.SpancheckSettings) *goanalysis.Linter {
+func New(settings *config.SpancheckSettings) *goanalysis.Linter {
cfg := spancheck.NewDefaultConfig()
if settings != nil {
@@ -19,6 +19,10 @@ func NewSpancheck(settings *config.SpancheckSettings) *goanalysis.Linter {
if settings.IgnoreCheckSignatures != nil {
cfg.IgnoreChecksSignaturesSlice = settings.IgnoreCheckSignatures
}
+
+ if settings.ExtraStartSpanSignatures != nil {
+ cfg.StartSpanMatchersSlice = settings.ExtraStartSpanSignatures
+ }
}
a := spancheck.NewAnalyzerWithConfig(cfg)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck/sqlclosecheck.go
index 94fd8b2c0..5eb32ff9d 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck/sqlclosecheck.go
@@ -1,4 +1,4 @@
-package golinters
+package sqlclosecheck
import (
"github.com/ryanrolds/sqlclosecheck/pkg/analyzer"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewSQLCloseCheck() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := analyzer.NewAnalyzer()
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/staticcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/staticcheck/staticcheck.go
index f0a2e6c03..79394bdb7 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/staticcheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/staticcheck/staticcheck.go
@@ -1,4 +1,4 @@
-package golinters
+package staticcheck
import (
"honnef.co/go/tools/staticcheck"
@@ -8,9 +8,9 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/internal"
)
-func NewStaticcheck(settings *config.StaticCheckSettings) *goanalysis.Linter {
+func New(settings *config.StaticCheckSettings) *goanalysis.Linter {
cfg := internal.StaticCheckConfig(settings)
- analyzers := internal.SetupStaticCheckAnalyzers(staticcheck.Analyzers, internal.GetGoVersion(settings), cfg.Checks)
+ analyzers := internal.SetupStaticCheckAnalyzers(staticcheck.Analyzers, cfg.Checks)
return goanalysis.NewLinter(
"staticcheck",
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/stylecheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/stylecheck/stylecheck.go
index 338326b90..60859f28a 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/stylecheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/stylecheck/stylecheck.go
@@ -1,4 +1,4 @@
-package golinters
+package stylecheck
import (
"golang.org/x/tools/go/analysis"
@@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/internal"
)
-func NewStylecheck(settings *config.StaticCheckSettings) *goanalysis.Linter {
+func New(settings *config.StaticCheckSettings) *goanalysis.Linter {
cfg := internal.StaticCheckConfig(settings)
// `scconfig.Analyzer` is a singleton, then it's not possible to have more than one instance for all staticcheck "sub-linters".
@@ -20,7 +20,7 @@ func NewStylecheck(settings *config.StaticCheckSettings) *goanalysis.Linter {
return cfg, nil
}
- analyzers := internal.SetupStaticCheckAnalyzers(stylecheck.Analyzers, internal.GetGoVersion(settings), cfg.Checks)
+ analyzers := internal.SetupStaticCheckAnalyzers(stylecheck.Analyzers, cfg.Checks)
return goanalysis.NewLinter(
"stylecheck",
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagalign.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagalign/tagalign.go
index 4a2e000fe..f438c51b5 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagalign.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagalign/tagalign.go
@@ -1,4 +1,4 @@
-package golinters
+package tagalign
import (
"sync"
@@ -12,7 +12,7 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-func NewTagAlign(settings *config.TagAlignSettings) *goanalysis.Linter {
+func New(settings *config.TagAlignSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagliatelle.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagliatelle/tagliatelle.go
index 731860353..d1674c3e9 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagliatelle.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tagliatelle/tagliatelle.go
@@ -1,4 +1,4 @@
-package golinters
+package tagliatelle
import (
"github.com/ldez/tagliatelle"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewTagliatelle(settings *config.TagliatelleSettings) *goanalysis.Linter {
+func New(settings *config.TagliatelleSettings) *goanalysis.Linter {
cfg := tagliatelle.Config{
Rules: map[string]string{
"json": "camel",
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tenv.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tenv/tenv.go
index 6c102711d..b80a783b6 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tenv.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tenv/tenv.go
@@ -1,4 +1,4 @@
-package golinters
+package tenv
import (
"github.com/sivchari/tenv"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewTenv(settings *config.TenvSettings) *goanalysis.Linter {
+func New(settings *config.TenvSettings) *goanalysis.Linter {
a := tenv.Analyzer
var cfg map[string]map[string]any
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testableexamples.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/testableexamples/testableexamples.go
index 2cb8127d6..6b76271db 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testableexamples.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/testableexamples/testableexamples.go
@@ -1,4 +1,4 @@
-package golinters
+package testableexamples
import (
"github.com/maratori/testableexamples/pkg/testableexamples"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewTestableexamples() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := testableexamples.NewAnalyzer()
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testifylint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/testifylint/testifylint.go
index dd5763a3d..b3f2f0bd4 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testifylint.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/testifylint/testifylint.go
@@ -1,4 +1,4 @@
-package golinters
+package testifylint
import (
"github.com/Antonboom/testifylint/analyzer"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewTestifylint(settings *config.TestifylintSettings) *goanalysis.Linter {
+func New(settings *config.TestifylintSettings) *goanalysis.Linter {
a := analyzer.New()
cfg := make(map[string]map[string]any)
@@ -18,6 +18,8 @@ func NewTestifylint(settings *config.TestifylintSettings) *goanalysis.Linter {
"disable-all": settings.DisableAll,
"bool-compare.ignore-custom-types": settings.BoolCompare.IgnoreCustomTypes,
+ "formatter.require-f-funcs": settings.Formatter.RequireFFuncs,
+ "go-require.ignore-http-handlers": settings.GoRequire.IgnoreHTTPHandlers,
}
if len(settings.EnabledCheckers) > 0 {
cfg[a.Name]["enable"] = settings.EnabledCheckers
@@ -26,6 +28,9 @@ func NewTestifylint(settings *config.TestifylintSettings) *goanalysis.Linter {
cfg[a.Name]["disable"] = settings.DisabledCheckers
}
+ if b := settings.Formatter.CheckFormatString; b != nil {
+ cfg[a.Name]["formatter.check-format-string"] = *b
+ }
if p := settings.ExpectedActual.ExpVarPattern; p != "" {
cfg[a.Name]["expected-actual.pattern"] = p
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testpackage.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/testpackage/testpackage.go
index d572ea0fe..632152712 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/testpackage.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/testpackage/testpackage.go
@@ -1,4 +1,4 @@
-package golinters
+package testpackage
import (
"strings"
@@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewTestpackage(cfg *config.TestpackageSettings) *goanalysis.Linter {
+func New(cfg *config.TestpackageSettings) *goanalysis.Linter {
a := testpackage.NewAnalyzer()
var settings map[string]map[string]any
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/thelper.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/thelper/thelper.go
index b1f96d3d6..cc6ea755c 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/thelper.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/thelper/thelper.go
@@ -1,4 +1,4 @@
-package golinters
+package thelper
import (
"strings"
@@ -12,7 +12,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/internal"
)
-func NewThelper(cfg *config.ThelperSettings) *goanalysis.Linter {
+func New(cfg *config.ThelperSettings) *goanalysis.Linter {
a := analyzer.NewAnalyzer()
opts := map[string]struct{}{
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tparallel.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tparallel/tparallel.go
index 80569ced7..4f7c43a99 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/tparallel.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/tparallel/tparallel.go
@@ -1,4 +1,4 @@
-package golinters
+package tparallel
import (
"github.com/moricho/tparallel"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewTparallel() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := tparallel.Analyzer
return goanalysis.NewLinter(
a.Name,
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/typecheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/typecheck.go
index ed403648b..d0eaa00d0 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/typecheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/typecheck.go
@@ -20,5 +20,5 @@ func NewTypecheck() *goanalysis.Linter {
"Like the front-end of a Go compiler, parses and type-checks Go code",
[]*analysis.Analyzer{analyzer},
nil,
- ).WithLoadMode(goanalysis.LoadModeTypesInfo)
+ ).WithLoadMode(goanalysis.LoadModeNone)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/unconvert.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/unconvert/unconvert.go
index c6e6bda93..954cc9eb3 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/unconvert.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/unconvert/unconvert.go
@@ -1,4 +1,4 @@
-package golinters
+package unconvert
import (
"sync"
@@ -12,14 +12,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const unconvertName = "unconvert"
+const linterName = "unconvert"
-func NewUnconvert(settings *config.UnconvertSettings) *goanalysis.Linter {
+func New(settings *config.UnconvertSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: unconvertName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (any, error) {
issues := runUnconvert(pass, settings)
@@ -37,7 +37,7 @@ func NewUnconvert(settings *config.UnconvertSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- unconvertName,
+ linterName,
"Remove unnecessary type conversions",
[]*analysis.Analyzer{analyzer},
nil,
@@ -54,7 +54,7 @@ func runUnconvert(pass *analysis.Pass, settings *config.UnconvertSettings) []goa
issues = append(issues, goanalysis.NewIssue(&result.Issue{
Pos: position,
Text: "unnecessary conversion",
- FromLinter: unconvertName,
+ FromLinter: linterName,
}, pass))
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/unparam.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/unparam/unparam.go
index 6ec35a00f..0fe184736 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/unparam.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/unparam/unparam.go
@@ -1,4 +1,4 @@
-package golinters
+package unparam
import (
"sync"
@@ -14,14 +14,14 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const unparamName = "unparam"
+const linterName = "unparam"
-func NewUnparam(settings *config.UnparamSettings) *goanalysis.Linter {
+func New(settings *config.UnparamSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: unparamName,
+ Name: linterName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Run: func(pass *analysis.Pass) (any, error) {
@@ -43,7 +43,7 @@ func NewUnparam(settings *config.UnparamSettings) *goanalysis.Linter {
}
return goanalysis.NewLinter(
- unparamName,
+ linterName,
"Reports unused function parameters",
[]*analysis.Analyzer{analyzer},
nil,
@@ -82,7 +82,7 @@ func runUnparam(pass *analysis.Pass, settings *config.UnparamSettings) ([]goanal
issues = append(issues, goanalysis.NewIssue(&result.Issue{
Pos: pass.Fset.Position(i.Pos()),
Text: i.Message(),
- FromLinter: unparamName,
+ FromLinter: linterName,
}, pass))
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/unused.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/unused/unused.go
index 5e3a8dbd7..7b2b478fc 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/unused.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/unused/unused.go
@@ -1,4 +1,4 @@
-package golinters
+package unused
import (
"fmt"
@@ -12,19 +12,18 @@ import (
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/goanalysis"
- "github.com/golangci/golangci-lint/pkg/golinters/internal"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/result"
)
-const unusedName = "unused"
+const linterName = "unused"
-func NewUnused(settings *config.UnusedSettings, scSettings *config.StaticCheckSettings) *goanalysis.Linter {
+func New(settings *config.UnusedSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
analyzer := &analysis.Analyzer{
- Name: unusedName,
+ Name: linterName,
Doc: unused.Analyzer.Analyzer.Doc,
Requires: unused.Analyzer.Analyzer.Requires,
Run: func(pass *analysis.Pass) (any, error) {
@@ -41,10 +40,8 @@ func NewUnused(settings *config.UnusedSettings, scSettings *config.StaticCheckSe
},
}
- internal.SetAnalyzerGoVersion(analyzer, internal.GetGoVersion(scSettings))
-
return goanalysis.NewLinter(
- unusedName,
+ linterName,
"Checks Go code for unused constants, variables, functions and types",
[]*analysis.Analyzer{analyzer},
nil,
@@ -75,7 +72,7 @@ func runUnused(pass *analysis.Pass, cfg *config.UnusedSettings) []goanalysis.Iss
}
issue := goanalysis.NewIssue(&result.Issue{
- FromLinter: unusedName,
+ FromLinter: linterName,
Text: fmt.Sprintf("%s %s is unused", object.Kind, object.Name),
Pos: object.Position,
}, pass)
@@ -90,11 +87,13 @@ func getUnusedResults(pass *analysis.Pass, settings *config.UnusedSettings) unus
opts := unused.Options{
FieldWritesAreUses: settings.FieldWritesAreUses,
PostStatementsAreReads: settings.PostStatementsAreReads,
- ExportedIsUsed: settings.ExportedIsUsed,
- ExportedFieldsAreUsed: settings.ExportedFieldsAreUsed,
- ParametersAreUsed: settings.ParametersAreUsed,
- LocalVariablesAreUsed: settings.LocalVariablesAreUsed,
- GeneratedIsUsed: settings.GeneratedIsUsed,
+ // Related to https://github.com/golangci/golangci-lint/issues/4218
+ // https://github.com/dominikh/go-tools/issues/1474#issuecomment-1850760813
+ ExportedIsUsed: true,
+ ExportedFieldsAreUsed: settings.ExportedFieldsAreUsed,
+ ParametersAreUsed: settings.ParametersAreUsed,
+ LocalVariablesAreUsed: settings.LocalVariablesAreUsed,
+ GeneratedIsUsed: settings.GeneratedIsUsed,
}
// ref: https://github.com/dominikh/go-tools/blob/4ec1f474ca6c0feb8e10a8fcca4ab95f5b5b9881/internal/cmd/unused/unused.go#L68
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars/usestdlibvars.go
index 1b2e5e5c7..050e47f24 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars/usestdlibvars.go
@@ -1,4 +1,4 @@
-package golinters
+package usestdlibvars
import (
"github.com/sashamelentyev/usestdlibvars/pkg/analyzer"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewUseStdlibVars(cfg *config.UseStdlibVarsSettings) *goanalysis.Linter {
+func New(cfg *config.UseStdlibVarsSettings) *goanalysis.Linter {
a := analyzer.New()
cfgMap := make(map[string]map[string]any)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/varnamelen.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/varnamelen/varnamelen.go
index bf2e8bff6..6cb57ffa5 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/varnamelen.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/varnamelen/varnamelen.go
@@ -1,4 +1,4 @@
-package golinters
+package varnamelen
import (
"strconv"
@@ -11,7 +11,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter {
+func New(settings *config.VarnamelenSettings) *goanalysis.Linter {
analyzer := varnamelen.NewAnalyzer()
cfg := map[string]map[string]any{}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wastedassign.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/wastedassign/wastedassign.go
index 8b48a21cc..094fa95c2 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wastedassign.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/wastedassign/wastedassign.go
@@ -1,4 +1,4 @@
-package golinters
+package wastedassign
import (
"github.com/sanposhiho/wastedassign/v2"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewWastedAssign() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := wastedassign.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/whitespace.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/whitespace/whitespace.go
index 7a09e8d90..721bfada1 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/whitespace.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/whitespace/whitespace.go
@@ -1,4 +1,4 @@
-package golinters
+package whitespace
import (
"fmt"
@@ -13,9 +13,9 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-const whitespaceName = "whitespace"
+const linterName = "whitespace"
-func NewWhitespace(settings *config.WhitespaceSettings) *goanalysis.Linter {
+func New(settings *config.WhitespaceSettings) *goanalysis.Linter {
var mu sync.Mutex
var resIssues []goanalysis.Issue
@@ -63,7 +63,7 @@ func runWhitespace(pass *analysis.Pass, wsSettings whitespace.Settings) ([]goana
issues := make([]goanalysis.Issue, len(lintIssues))
for i, issue := range lintIssues {
report := &result.Issue{
- FromLinter: whitespaceName,
+ FromLinter: linterName,
Pos: pass.Fset.PositionFor(issue.Diagnostic, false),
Text: issue.Message,
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wrapcheck.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/wrapcheck/wrapcheck.go
index 5a40e943c..96ec2eeae 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wrapcheck.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/wrapcheck/wrapcheck.go
@@ -1,4 +1,4 @@
-package golinters
+package wrapcheck
import (
"github.com/tomarrell/wrapcheck/v2/wrapcheck"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewWrapcheck(settings *config.WrapcheckSettings) *goanalysis.Linter {
+func New(settings *config.WrapcheckSettings) *goanalysis.Linter {
cfg := wrapcheck.NewDefaultConfig()
if settings != nil {
if len(settings.IgnoreSigs) != 0 {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wsl.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/wsl/wsl.go
index cbef76e18..c728340ec 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/wsl.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/wsl/wsl.go
@@ -1,4 +1,4 @@
-package golinters
+package wsl
import (
"github.com/bombsimon/wsl/v4"
@@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewWSL(settings *config.WSLSettings) *goanalysis.Linter {
+func New(settings *config.WSLSettings) *goanalysis.Linter {
var conf *wsl.Configuration
if settings != nil {
conf = &wsl.Configuration{
@@ -25,6 +25,7 @@ func NewWSL(settings *config.WSLSettings) *goanalysis.Linter {
ForceCuddleErrCheckAndAssign: settings.ForceCuddleErrCheckAndAssign,
ErrorVariableNames: settings.ErrorVariableNames,
ForceExclusiveShortDeclarations: settings.ForceExclusiveShortDeclarations,
+ IncludeGenerated: true, // force to true because golangci-lint already have a way to filter generated files.
}
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/golinters/zerologlint.go b/vendor/github.com/golangci/golangci-lint/pkg/golinters/zerologlint/zerologlint.go
index a1346172a..6ca74020c 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/golinters/zerologlint.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/golinters/zerologlint/zerologlint.go
@@ -1,4 +1,4 @@
-package golinters
+package zerologlint
import (
"github.com/ykadowak/zerologlint"
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
-func NewZerologLint() *goanalysis.Linter {
+func New() *goanalysis.Linter {
a := zerologlint.Analyzer
return goanalysis.NewLinter(
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/goutil/version.go b/vendor/github.com/golangci/golangci-lint/pkg/goutil/version.go
new file mode 100644
index 000000000..4f42ebd1b
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/pkg/goutil/version.go
@@ -0,0 +1,75 @@
+package goutil
+
+import (
+ "fmt"
+ "go/version"
+ "regexp"
+ "runtime"
+ "strings"
+
+ hcversion "github.com/hashicorp/go-version"
+)
+
+func CheckGoVersion(goVersion string) error {
+ rv, err := CleanRuntimeVersion()
+ if err != nil {
+ return fmt.Errorf("clean runtime version: %w", err)
+ }
+
+ langVersion := version.Lang(rv)
+
+ runtimeVersion, err := hcversion.NewVersion(strings.TrimPrefix(langVersion, "go"))
+ if err != nil {
+ return err
+ }
+
+ targetedVersion, err := hcversion.NewVersion(TrimGoVersion(goVersion))
+ if err != nil {
+ return err
+ }
+
+ if runtimeVersion.LessThan(targetedVersion) {
+ return fmt.Errorf("the Go language version (%s) used to build golangci-lint is lower than the targeted Go version (%s)",
+ langVersion, goVersion)
+ }
+
+ return nil
+}
+
+// TrimGoVersion Trims the Go version to keep only M.m.
+// Since Go 1.21 the version inside the go.mod can be a patched version (ex: 1.21.0).
+// The version can also include information which we want to remove (ex: 1.21alpha1)
+// https://go.dev/doc/toolchain#versions
+// This a problem with staticcheck and gocritic.
+func TrimGoVersion(v string) string {
+ if v == "" {
+ return ""
+ }
+
+ exp := regexp.MustCompile(`(\d\.\d+)(?:\.\d+|[a-z]+\d)`)
+
+ if exp.MatchString(v) {
+ return exp.FindStringSubmatch(v)[1]
+ }
+
+ return v
+}
+
+func CleanRuntimeVersion() (string, error) {
+ return cleanRuntimeVersion(runtime.Version())
+}
+
+func cleanRuntimeVersion(rv string) (string, error) {
+ parts := strings.Fields(rv)
+
+ for _, part := range parts {
+ // Allow to handle:
+ // - GOEXPERIMENT -> "go1.23.0 X:boringcrypto"
+ // - devel -> "devel go1.24-e705a2d Wed Aug 7 01:16:42 2024 +0000 linux/amd64"
+ if strings.HasPrefix(part, "go1.") {
+ return part, nil
+ }
+ }
+
+ return "", fmt.Errorf("invalid Go runtime version: %s", rv)
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/config.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/config.go
index 8e57d6bdf..57c51fa75 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/config.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/config.go
@@ -27,10 +27,19 @@ const (
// LastLinter nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives.
const LastLinter = "nolintlint"
+type DeprecationLevel int
+
+const (
+ DeprecationNone DeprecationLevel = iota
+ DeprecationWarning
+ DeprecationError
+)
+
type Deprecation struct {
Since string
Message string
Replacement string
+ Level DeprecationLevel
}
type Config struct {
@@ -113,15 +122,24 @@ func (lc *Config) WithSince(version string) *Config {
return lc
}
-func (lc *Config) Deprecated(message, version, replacement string) *Config {
+func (lc *Config) Deprecated(message, version, replacement string, level DeprecationLevel) *Config {
lc.Deprecation = &Deprecation{
Since: version,
Message: message,
Replacement: replacement,
+ Level: level,
}
return lc
}
+func (lc *Config) DeprecatedWarning(message, version, replacement string) *Config {
+ return lc.Deprecated(message, version, replacement, DeprecationWarning)
+}
+
+func (lc *Config) DeprecatedError(message, version, replacement string) *Config {
+ return lc.Deprecated(message, version, replacement, DeprecationError)
+}
+
func (lc *Config) IsDeprecated() bool {
return lc.Deprecation != nil
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/linter.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/linter.go
index 1d4e7b04c..088aa3d78 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/linter.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/lint/linter/linter.go
@@ -17,6 +17,7 @@ type Noop struct {
name string
desc string
reason string
+ level DeprecationLevel
}
func NewNoop(l Linter, reason string) Noop {
@@ -27,11 +28,12 @@ func NewNoop(l Linter, reason string) Noop {
}
}
-func NewNoopDeprecated(name string, cfg *config.Config) Noop {
+func NewNoopDeprecated(name string, cfg *config.Config, level DeprecationLevel) Noop {
noop := Noop{
name: name,
desc: "Deprecated",
reason: "This linter is fully inactivated: it will not produce any reports.",
+ level: level,
}
if cfg.InternalCmdTest {
@@ -42,9 +44,17 @@ func NewNoopDeprecated(name string, cfg *config.Config) Noop {
}
func (n Noop) Run(_ context.Context, lintCtx *Context) ([]result.Issue, error) {
- if n.reason != "" {
+ if n.reason == "" {
+ return nil, nil
+ }
+
+ switch n.level {
+ case DeprecationError:
+ lintCtx.Log.Errorf("%s: %s", n.name, n.reason)
+ default:
lintCtx.Log.Warnf("%s: %s", n.name, n.reason)
}
+
return nil, nil
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_linter.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_linter.go
index 649a82fd7..c06cd9a03 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_linter.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_linter.go
@@ -3,6 +3,113 @@ package lintersdb
import (
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/golinters"
+ "github.com/golangci/golangci-lint/pkg/golinters/asasalint"
+ "github.com/golangci/golangci-lint/pkg/golinters/asciicheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/bidichk"
+ "github.com/golangci/golangci-lint/pkg/golinters/bodyclose"
+ "github.com/golangci/golangci-lint/pkg/golinters/canonicalheader"
+ "github.com/golangci/golangci-lint/pkg/golinters/containedctx"
+ "github.com/golangci/golangci-lint/pkg/golinters/contextcheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/copyloopvar"
+ "github.com/golangci/golangci-lint/pkg/golinters/cyclop"
+ "github.com/golangci/golangci-lint/pkg/golinters/decorder"
+ "github.com/golangci/golangci-lint/pkg/golinters/depguard"
+ "github.com/golangci/golangci-lint/pkg/golinters/dogsled"
+ "github.com/golangci/golangci-lint/pkg/golinters/dupl"
+ "github.com/golangci/golangci-lint/pkg/golinters/dupword"
+ "github.com/golangci/golangci-lint/pkg/golinters/durationcheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/err113"
+ "github.com/golangci/golangci-lint/pkg/golinters/errcheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/errchkjson"
+ "github.com/golangci/golangci-lint/pkg/golinters/errname"
+ "github.com/golangci/golangci-lint/pkg/golinters/errorlint"
+ "github.com/golangci/golangci-lint/pkg/golinters/execinquery"
+ "github.com/golangci/golangci-lint/pkg/golinters/exhaustive"
+ "github.com/golangci/golangci-lint/pkg/golinters/exhaustruct"
+ "github.com/golangci/golangci-lint/pkg/golinters/exportloopref"
+ "github.com/golangci/golangci-lint/pkg/golinters/fatcontext"
+ "github.com/golangci/golangci-lint/pkg/golinters/forbidigo"
+ "github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert"
+ "github.com/golangci/golangci-lint/pkg/golinters/funlen"
+ "github.com/golangci/golangci-lint/pkg/golinters/gci"
+ "github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter"
+ "github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives"
+ "github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals"
+ "github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits"
+ "github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype"
+ "github.com/golangci/golangci-lint/pkg/golinters/gocognit"
+ "github.com/golangci/golangci-lint/pkg/golinters/goconst"
+ "github.com/golangci/golangci-lint/pkg/golinters/gocritic"
+ "github.com/golangci/golangci-lint/pkg/golinters/gocyclo"
+ "github.com/golangci/golangci-lint/pkg/golinters/godot"
+ "github.com/golangci/golangci-lint/pkg/golinters/godox"
+ "github.com/golangci/golangci-lint/pkg/golinters/gofmt"
+ "github.com/golangci/golangci-lint/pkg/golinters/gofumpt"
+ "github.com/golangci/golangci-lint/pkg/golinters/goheader"
+ "github.com/golangci/golangci-lint/pkg/golinters/goimports"
+ "github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives"
+ "github.com/golangci/golangci-lint/pkg/golinters/gomodguard"
+ "github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname"
+ "github.com/golangci/golangci-lint/pkg/golinters/gosec"
+ "github.com/golangci/golangci-lint/pkg/golinters/gosimple"
+ "github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan"
+ "github.com/golangci/golangci-lint/pkg/golinters/govet"
+ "github.com/golangci/golangci-lint/pkg/golinters/grouper"
+ "github.com/golangci/golangci-lint/pkg/golinters/importas"
+ "github.com/golangci/golangci-lint/pkg/golinters/inamedparam"
+ "github.com/golangci/golangci-lint/pkg/golinters/ineffassign"
+ "github.com/golangci/golangci-lint/pkg/golinters/interfacebloat"
+ "github.com/golangci/golangci-lint/pkg/golinters/intrange"
+ "github.com/golangci/golangci-lint/pkg/golinters/ireturn"
+ "github.com/golangci/golangci-lint/pkg/golinters/lll"
+ "github.com/golangci/golangci-lint/pkg/golinters/loggercheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/maintidx"
+ "github.com/golangci/golangci-lint/pkg/golinters/makezero"
+ "github.com/golangci/golangci-lint/pkg/golinters/mirror"
+ "github.com/golangci/golangci-lint/pkg/golinters/misspell"
+ "github.com/golangci/golangci-lint/pkg/golinters/mnd"
+ "github.com/golangci/golangci-lint/pkg/golinters/musttag"
+ "github.com/golangci/golangci-lint/pkg/golinters/nakedret"
+ "github.com/golangci/golangci-lint/pkg/golinters/nestif"
+ "github.com/golangci/golangci-lint/pkg/golinters/nilerr"
+ "github.com/golangci/golangci-lint/pkg/golinters/nilnil"
+ "github.com/golangci/golangci-lint/pkg/golinters/nlreturn"
+ "github.com/golangci/golangci-lint/pkg/golinters/noctx"
+ "github.com/golangci/golangci-lint/pkg/golinters/nolintlint"
+ "github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns"
+ "github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport"
+ "github.com/golangci/golangci-lint/pkg/golinters/paralleltest"
+ "github.com/golangci/golangci-lint/pkg/golinters/perfsprint"
+ "github.com/golangci/golangci-lint/pkg/golinters/prealloc"
+ "github.com/golangci/golangci-lint/pkg/golinters/predeclared"
+ "github.com/golangci/golangci-lint/pkg/golinters/promlinter"
+ "github.com/golangci/golangci-lint/pkg/golinters/protogetter"
+ "github.com/golangci/golangci-lint/pkg/golinters/reassign"
+ "github.com/golangci/golangci-lint/pkg/golinters/revive"
+ "github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/sloglint"
+ "github.com/golangci/golangci-lint/pkg/golinters/spancheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/staticcheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/stylecheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/tagalign"
+ "github.com/golangci/golangci-lint/pkg/golinters/tagliatelle"
+ "github.com/golangci/golangci-lint/pkg/golinters/tenv"
+ "github.com/golangci/golangci-lint/pkg/golinters/testableexamples"
+ "github.com/golangci/golangci-lint/pkg/golinters/testifylint"
+ "github.com/golangci/golangci-lint/pkg/golinters/testpackage"
+ "github.com/golangci/golangci-lint/pkg/golinters/thelper"
+ "github.com/golangci/golangci-lint/pkg/golinters/tparallel"
+ "github.com/golangci/golangci-lint/pkg/golinters/unconvert"
+ "github.com/golangci/golangci-lint/pkg/golinters/unparam"
+ "github.com/golangci/golangci-lint/pkg/golinters/unused"
+ "github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars"
+ "github.com/golangci/golangci-lint/pkg/golinters/varnamelen"
+ "github.com/golangci/golangci-lint/pkg/golinters/wastedassign"
+ "github.com/golangci/golangci-lint/pkg/golinters/whitespace"
+ "github.com/golangci/golangci-lint/pkg/golinters/wrapcheck"
+ "github.com/golangci/golangci-lint/pkg/golinters/wsl"
+ "github.com/golangci/golangci-lint/pkg/golinters/zerologlint"
"github.com/golangci/golangci-lint/pkg/lint/linter"
)
@@ -16,7 +123,7 @@ func NewLinterBuilder() *LinterBuilder {
// Build loads all the "internal" linters.
// The configuration is use for the linter settings.
-func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
+func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
if cfg == nil {
return nil, nil
}
@@ -26,147 +133,155 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
// The linters are sorted in the alphabetical order (case-insensitive).
// When a new linter is added the version in `WithSince(...)` must be the next minor version of golangci-lint.
return []*linter.Config{
- linter.NewConfig(golinters.NewAsasalint(&cfg.LintersSettings.Asasalint)).
+ linter.NewConfig(asasalint.New(&cfg.LintersSettings.Asasalint)).
WithSince("1.47.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/alingse/asasalint"),
- linter.NewConfig(golinters.NewAsciicheck()).
+ linter.NewConfig(asciicheck.New()).
WithSince("v1.26.0").
WithPresets(linter.PresetBugs, linter.PresetStyle).
WithURL("https://github.com/tdakkota/asciicheck"),
- linter.NewConfig(golinters.NewBiDiChk(&cfg.LintersSettings.BiDiChk)).
+ linter.NewConfig(bidichk.New(&cfg.LintersSettings.BiDiChk)).
WithSince("1.43.0").
WithPresets(linter.PresetBugs).
WithURL("https://github.com/breml/bidichk"),
- linter.NewConfig(golinters.NewBodyclose()).
+ linter.NewConfig(bodyclose.New()).
WithSince("v1.18.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance, linter.PresetBugs).
WithURL("https://github.com/timakin/bodyclose"),
- linter.NewConfig(golinters.NewContainedCtx()).
+ linter.NewConfig(canonicalheader.New()).
+ WithSince("v1.58.0").
+ WithPresets(linter.PresetStyle).
+ WithLoadForGoAnalysis().
+ WithURL("https://github.com/lasiar/canonicalHeader"),
+
+ linter.NewConfig(containedctx.New()).
WithSince("1.44.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/sivchari/containedctx"),
- linter.NewConfig(golinters.NewContextCheck()).
+ linter.NewConfig(contextcheck.New()).
WithSince("v1.43.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/kkHAIKE/contextcheck"),
- linter.NewConfig(golinters.NewCopyLoopVar(&cfg.LintersSettings.CopyLoopVar)).
+ linter.NewConfig(copyloopvar.New(&cfg.LintersSettings.CopyLoopVar)).
WithSince("v1.57.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/karamaru-alpha/copyloopvar").
WithNoopFallback(cfg, linter.IsGoLowerThanGo122()),
- linter.NewConfig(golinters.NewCyclop(&cfg.LintersSettings.Cyclop)).
+ linter.NewConfig(cyclop.New(&cfg.LintersSettings.Cyclop)).
WithSince("v1.37.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetComplexity).
WithURL("https://github.com/bkielbasa/cyclop"),
- linter.NewConfig(golinters.NewDecorder(&cfg.LintersSettings.Decorder)).
+ linter.NewConfig(decorder.New(&cfg.LintersSettings.Decorder)).
WithSince("v1.44.0").
WithPresets(linter.PresetFormatting, linter.PresetStyle).
WithURL("https://gitlab.com/bosi/decorder"),
- linter.NewConfig(linter.NewNoopDeprecated("deadcode", cfg)).
+ linter.NewConfig(linter.NewNoopDeprecated("deadcode", cfg, linter.DeprecationError)).
WithSince("v1.0.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetUnused).
WithURL("https://github.com/remyoudompheng/go-misc/tree/master/deadcode").
- Deprecated("The owner seems to have abandoned the linter.", "v1.49.0", "unused"),
+ DeprecatedError("The owner seems to have abandoned the linter.", "v1.49.0", "unused"),
- linter.NewConfig(golinters.NewDepguard(&cfg.LintersSettings.Depguard)).
+ linter.NewConfig(depguard.New(&cfg.LintersSettings.Depguard)).
WithSince("v1.4.0").
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
WithURL("https://github.com/OpenPeeDeeP/depguard"),
- linter.NewConfig(golinters.NewDogsled(&cfg.LintersSettings.Dogsled)).
+ linter.NewConfig(dogsled.New(&cfg.LintersSettings.Dogsled)).
WithSince("v1.19.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/alexkohler/dogsled"),
- linter.NewConfig(golinters.NewDupl(&cfg.LintersSettings.Dupl)).
+ linter.NewConfig(dupl.New(&cfg.LintersSettings.Dupl)).
WithSince("v1.0.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/mibk/dupl"),
- linter.NewConfig(golinters.NewDupWord(&cfg.LintersSettings.DupWord)).
+ linter.NewConfig(dupword.New(&cfg.LintersSettings.DupWord)).
WithSince("1.50.0").
WithPresets(linter.PresetComment).
WithURL("https://github.com/Abirdcfly/dupword"),
- linter.NewConfig(golinters.NewDurationCheck()).
+ linter.NewConfig(durationcheck.New()).
WithSince("v1.37.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/charithe/durationcheck"),
- linter.NewConfig(golinters.NewErrcheck(&cfg.LintersSettings.Errcheck)).
+ linter.NewConfig(errcheck.New(&cfg.LintersSettings.Errcheck)).
WithEnabledByDefault().
WithSince("v1.0.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs, linter.PresetError).
WithURL("https://github.com/kisielk/errcheck"),
- linter.NewConfig(golinters.NewErrChkJSON(&cfg.LintersSettings.ErrChkJSON)).
+ linter.NewConfig(errchkjson.New(&cfg.LintersSettings.ErrChkJSON)).
WithSince("1.44.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/breml/errchkjson"),
- linter.NewConfig(golinters.NewErrName()).
+ linter.NewConfig(errname.New()).
WithSince("v1.42.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/Antonboom/errname"),
- linter.NewConfig(golinters.NewErrorLint(&cfg.LintersSettings.ErrorLint)).
+ linter.NewConfig(errorlint.New(&cfg.LintersSettings.ErrorLint)).
WithSince("v1.32.0").
WithPresets(linter.PresetBugs, linter.PresetError).
WithLoadForGoAnalysis().
WithURL("https://github.com/polyfloyd/go-errorlint"),
- linter.NewConfig(golinters.NewExecInQuery()).
+ linter.NewConfig(execinquery.New()).
WithSince("v1.46.0").
WithPresets(linter.PresetSQL).
WithLoadForGoAnalysis().
- WithURL("https://github.com/lufeee/execinquery"),
+ WithURL("https://github.com/1uf3/execinquery").
+ DeprecatedWarning("The repository of the linter has been archived by the owner.", "v1.58.0", ""),
- linter.NewConfig(golinters.NewExhaustive(&cfg.LintersSettings.Exhaustive)).
+ linter.NewConfig(exhaustive.New(&cfg.LintersSettings.Exhaustive)).
WithSince(" v1.28.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/nishanths/exhaustive"),
- linter.NewConfig(linter.NewNoopDeprecated("exhaustivestruct", cfg)).
+ linter.NewConfig(linter.NewNoopDeprecated("exhaustivestruct", cfg, linter.DeprecationError)).
WithSince("v1.32.0").
WithPresets(linter.PresetStyle, linter.PresetTest).
WithLoadForGoAnalysis().
WithURL("https://github.com/mbilski/exhaustivestruct").
- Deprecated("The repository of the linter has been deprecated by the owner.", "v1.46.0", "exhaustruct"),
+ DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.46.0", "exhaustruct"),
- linter.NewConfig(golinters.NewExhaustruct(&cfg.LintersSettings.Exhaustruct)).
+ linter.NewConfig(exhaustruct.New(&cfg.LintersSettings.Exhaustruct)).
WithSince("v1.46.0").
WithPresets(linter.PresetStyle, linter.PresetTest).
WithLoadForGoAnalysis().
WithURL("https://github.com/GaijinEntertainment/go-exhaustruct"),
- linter.NewConfig(golinters.NewExportLoopRef()).
+ linter.NewConfig(exportloopref.New()).
WithSince("v1.28.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
- WithURL("https://github.com/kyoh86/exportloopref"),
+ WithURL("https://github.com/kyoh86/exportloopref").
+ DeprecatedWarning("Since Go1.22 (loopvar) this linter is no longer relevant.", "v1.60.2", "copyloopvar"),
- linter.NewConfig(golinters.NewForbidigo(&cfg.LintersSettings.Forbidigo)).
+ linter.NewConfig(forbidigo.New(&cfg.LintersSettings.Forbidigo)).
WithSince("v1.34.0").
WithPresets(linter.PresetStyle).
// Strictly speaking,
@@ -176,147 +291,160 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithLoadForGoAnalysis().
WithURL("https://github.com/ashanbrown/forbidigo"),
- linter.NewConfig(golinters.NewForceTypeAssert()).
+ linter.NewConfig(forcetypeassert.New()).
WithSince("v1.38.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/gostaticanalysis/forcetypeassert"),
- linter.NewConfig(golinters.NewFunlen(&cfg.LintersSettings.Funlen)).
+ linter.NewConfig(fatcontext.New()).
+ WithSince("1.58.0").
+ WithPresets(linter.PresetPerformance).
+ WithLoadForGoAnalysis().
+ WithURL("https://github.com/Crocmagnon/fatcontext"),
+
+ linter.NewConfig(funlen.New(&cfg.LintersSettings.Funlen)).
WithSince("v1.18.0").
WithPresets(linter.PresetComplexity).
WithURL("https://github.com/ultraware/funlen"),
- linter.NewConfig(golinters.NewGci(&cfg.LintersSettings.Gci)).
+ linter.NewConfig(gci.New(&cfg.LintersSettings.Gci)).
WithSince("v1.30.0").
WithPresets(linter.PresetFormatting, linter.PresetImport).
WithAutoFix().
WithURL("https://github.com/daixiang0/gci"),
- linter.NewConfig(golinters.NewGinkgoLinter(&cfg.LintersSettings.GinkgoLinter)).
+ linter.NewConfig(ginkgolinter.New(&cfg.LintersSettings.GinkgoLinter)).
WithSince("v1.51.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/nunnatsa/ginkgolinter"),
- linter.NewConfig(golinters.NewGoCheckCompilerDirectives()).
+ linter.NewConfig(gocheckcompilerdirectives.New()).
WithSince("v1.51.0").
WithPresets(linter.PresetBugs).
WithURL("https://github.com/leighmcculloch/gocheckcompilerdirectives"),
- linter.NewConfig(golinters.NewGochecknoglobals()).
+ linter.NewConfig(gochecknoglobals.New()).
WithSince("v1.12.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/leighmcculloch/gochecknoglobals"),
- linter.NewConfig(golinters.NewGochecknoinits()).
+ linter.NewConfig(gochecknoinits.New()).
WithSince("v1.12.0").
WithPresets(linter.PresetStyle),
- linter.NewConfig(golinters.NewGoCheckSumType()).
+ linter.NewConfig(gochecksumtype.New()).
WithSince("v1.55.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/alecthomas/go-check-sumtype"),
- linter.NewConfig(golinters.NewGocognit(&cfg.LintersSettings.Gocognit)).
+ linter.NewConfig(gocognit.New(&cfg.LintersSettings.Gocognit)).
WithSince("v1.20.0").
WithPresets(linter.PresetComplexity).
WithURL("https://github.com/uudashr/gocognit"),
- linter.NewConfig(golinters.NewGoconst(&cfg.LintersSettings.Goconst)).
+ linter.NewConfig(goconst.New(&cfg.LintersSettings.Goconst)).
WithSince("v1.0.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/jgautheron/goconst"),
- linter.NewConfig(golinters.NewGoCritic(&cfg.LintersSettings.Gocritic)).
+ linter.NewConfig(gocritic.New(&cfg.LintersSettings.Gocritic)).
WithSince("v1.12.0").
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
WithLoadForGoAnalysis().
WithAutoFix().
WithURL("https://github.com/go-critic/go-critic"),
- linter.NewConfig(golinters.NewGocyclo(&cfg.LintersSettings.Gocyclo)).
+ linter.NewConfig(gocyclo.New(&cfg.LintersSettings.Gocyclo)).
WithSince("v1.0.0").
WithPresets(linter.PresetComplexity).
WithURL("https://github.com/fzipp/gocyclo"),
- linter.NewConfig(golinters.NewGodot(&cfg.LintersSettings.Godot)).
+ linter.NewConfig(godot.New(&cfg.LintersSettings.Godot)).
WithSince("v1.25.0").
WithPresets(linter.PresetStyle, linter.PresetComment).
WithAutoFix().
WithURL("https://github.com/tetafro/godot"),
- linter.NewConfig(golinters.NewGodox(&cfg.LintersSettings.Godox)).
+ linter.NewConfig(godox.New(&cfg.LintersSettings.Godox)).
WithSince("v1.19.0").
WithPresets(linter.PresetStyle, linter.PresetComment).
WithURL("https://github.com/matoous/godox"),
- linter.NewConfig(golinters.NewGoerr113()).
+ linter.NewConfig(err113.New()).
WithSince("v1.26.0").
WithPresets(linter.PresetStyle, linter.PresetError).
WithLoadForGoAnalysis().
+ WithAlternativeNames("goerr113").
WithURL("https://github.com/Djarvur/go-err113"),
- linter.NewConfig(golinters.NewGofmt(&cfg.LintersSettings.Gofmt)).
+ linter.NewConfig(gofmt.New(&cfg.LintersSettings.Gofmt)).
WithSince("v1.0.0").
WithPresets(linter.PresetFormatting).
WithAutoFix().
WithURL("https://pkg.go.dev/cmd/gofmt"),
- linter.NewConfig(golinters.NewGofumpt(&cfg.LintersSettings.Gofumpt)).
+ linter.NewConfig(gofumpt.New(&cfg.LintersSettings.Gofumpt)).
WithSince("v1.28.0").
WithPresets(linter.PresetFormatting).
WithAutoFix().
WithURL("https://github.com/mvdan/gofumpt"),
- linter.NewConfig(golinters.NewGoHeader(&cfg.LintersSettings.Goheader)).
+ linter.NewConfig(goheader.New(&cfg.LintersSettings.Goheader)).
WithSince("v1.28.0").
WithPresets(linter.PresetStyle).
WithAutoFix().
WithURL("https://github.com/denis-tingaikin/go-header"),
- linter.NewConfig(golinters.NewGoimports(&cfg.LintersSettings.Goimports)).
+ linter.NewConfig(goimports.New(&cfg.LintersSettings.Goimports)).
WithSince("v1.20.0").
WithPresets(linter.PresetFormatting, linter.PresetImport).
WithAutoFix().
WithURL("https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),
- linter.NewConfig(linter.NewNoopDeprecated("golint", cfg)).
+ linter.NewConfig(linter.NewNoopDeprecated("golint", cfg, linter.DeprecationError)).
WithSince("v1.0.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/golang/lint").
- Deprecated("The repository of the linter has been archived by the owner.", "v1.41.0", "revive"),
+ DeprecatedError("The repository of the linter has been archived by the owner.", "v1.41.0", "revive"),
- linter.NewConfig(golinters.NewGoMND(&cfg.LintersSettings.Gomnd)).
+ linter.NewConfig(mnd.New(&cfg.LintersSettings.Mnd)).
WithSince("v1.22.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/tommy-muehle/go-mnd"),
- linter.NewConfig(golinters.NewGoModDirectives(&cfg.LintersSettings.GoModDirectives)).
+ linter.NewConfig(mnd.NewGoMND(&cfg.LintersSettings.Gomnd)).
+ WithSince("v1.22.0").
+ WithPresets(linter.PresetStyle).
+ WithURL("https://github.com/tommy-muehle/go-mnd").
+ DeprecatedWarning("The linter has been renamed.", "v1.58.0", "mnd"),
+
+ linter.NewConfig(gomoddirectives.New(&cfg.LintersSettings.GoModDirectives)).
WithSince("v1.39.0").
WithPresets(linter.PresetStyle, linter.PresetModule).
WithURL("https://github.com/ldez/gomoddirectives"),
- linter.NewConfig(golinters.NewGomodguard(&cfg.LintersSettings.Gomodguard)).
+ linter.NewConfig(gomodguard.New(&cfg.LintersSettings.Gomodguard)).
WithSince("v1.25.0").
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
WithURL("https://github.com/ryancurrah/gomodguard"),
- linter.NewConfig(golinters.NewGoPrintfFuncName()).
+ linter.NewConfig(goprintffuncname.New()).
WithSince("v1.23.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/jirfag/go-printf-func-name"),
- linter.NewConfig(golinters.NewGosec(&cfg.LintersSettings.Gosec)).
+ linter.NewConfig(gosec.New(&cfg.LintersSettings.Gosec)).
WithSince("v1.0.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs).
WithURL("https://github.com/securego/gosec").
WithAlternativeNames("gas"),
- linter.NewConfig(golinters.NewGosimple(&cfg.LintersSettings.Gosimple)).
+ linter.NewConfig(gosimple.New(&cfg.LintersSettings.Gosimple)).
WithEnabledByDefault().
WithSince("v1.20.0").
WithLoadForGoAnalysis().
@@ -324,13 +452,13 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithAlternativeNames(megacheckName).
WithURL("https://github.com/dominikh/go-tools/tree/master/simple"),
- linter.NewConfig(golinters.NewGosmopolitan(&cfg.LintersSettings.Gosmopolitan)).
+ linter.NewConfig(gosmopolitan.New(&cfg.LintersSettings.Gosmopolitan)).
WithSince("v1.53.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs).
WithURL("https://github.com/xen0n/gosmopolitan"),
- linter.NewConfig(golinters.NewGovet(&cfg.LintersSettings.Govet)).
+ linter.NewConfig(govet.New(&cfg.LintersSettings.Govet)).
WithEnabledByDefault().
WithSince("v1.0.0").
WithLoadForGoAnalysis().
@@ -338,232 +466,234 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithAlternativeNames("vet", "vetshadow").
WithURL("https://pkg.go.dev/cmd/vet"),
- linter.NewConfig(golinters.NewGrouper(&cfg.LintersSettings.Grouper)).
+ linter.NewConfig(grouper.New(&cfg.LintersSettings.Grouper)).
WithSince("v1.44.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/leonklingele/grouper"),
- linter.NewConfig(linter.NewNoopDeprecated("ifshort", cfg)).
+ linter.NewConfig(linter.NewNoopDeprecated("ifshort", cfg, linter.DeprecationError)).
WithSince("v1.36.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/esimonov/ifshort").
- Deprecated("The repository of the linter has been deprecated by the owner.", "v1.48.0", ""),
+ DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.48.0", ""),
- linter.NewConfig(golinters.NewImportAs(&cfg.LintersSettings.ImportAs)).
+ linter.NewConfig(importas.New(&cfg.LintersSettings.ImportAs)).
WithSince("v1.38.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/julz/importas"),
- linter.NewConfig(golinters.NewINamedParam(&cfg.LintersSettings.Inamedparam)).
+ linter.NewConfig(inamedparam.New(&cfg.LintersSettings.Inamedparam)).
WithSince("v1.55.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/macabu/inamedparam"),
- linter.NewConfig(golinters.NewIneffassign()).
+ linter.NewConfig(ineffassign.New()).
WithEnabledByDefault().
WithSince("v1.0.0").
WithPresets(linter.PresetUnused).
WithURL("https://github.com/gordonklaus/ineffassign"),
- linter.NewConfig(golinters.NewInterfaceBloat(&cfg.LintersSettings.InterfaceBloat)).
+ linter.NewConfig(interfacebloat.New(&cfg.LintersSettings.InterfaceBloat)).
WithSince("v1.49.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/sashamelentyev/interfacebloat"),
- linter.NewConfig(linter.NewNoopDeprecated("interfacer", cfg)).
+ linter.NewConfig(linter.NewNoopDeprecated("interfacer", cfg, linter.DeprecationError)).
WithSince("v1.0.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/mvdan/interfacer").
- Deprecated("The repository of the linter has been archived by the owner.", "v1.38.0", ""),
+ DeprecatedError("The repository of the linter has been archived by the owner.", "v1.38.0", ""),
- linter.NewConfig(golinters.NewIntrange()).
+ linter.NewConfig(intrange.New()).
WithSince("v1.57.0").
+ WithLoadForGoAnalysis().
+ WithPresets(linter.PresetStyle).
WithURL("https://github.com/ckaznocha/intrange").
WithNoopFallback(cfg, linter.IsGoLowerThanGo122()),
- linter.NewConfig(golinters.NewIreturn(&cfg.LintersSettings.Ireturn)).
+ linter.NewConfig(ireturn.New(&cfg.LintersSettings.Ireturn)).
WithSince("v1.43.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/butuzov/ireturn"),
- linter.NewConfig(golinters.NewLLL(&cfg.LintersSettings.Lll)).
+ linter.NewConfig(lll.New(&cfg.LintersSettings.Lll)).
WithSince("v1.8.0").
WithPresets(linter.PresetStyle),
- linter.NewConfig(golinters.NewLoggerCheck(&cfg.LintersSettings.LoggerCheck)).
+ linter.NewConfig(loggercheck.New(&cfg.LintersSettings.LoggerCheck)).
WithSince("v1.49.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle, linter.PresetBugs).
WithAlternativeNames("logrlint").
WithURL("https://github.com/timonwong/loggercheck"),
- linter.NewConfig(golinters.NewMaintIdx(&cfg.LintersSettings.MaintIdx)).
+ linter.NewConfig(maintidx.New(&cfg.LintersSettings.MaintIdx)).
WithSince("v1.44.0").
WithPresets(linter.PresetComplexity).
WithURL("https://github.com/yagipy/maintidx"),
- linter.NewConfig(golinters.NewMakezero(&cfg.LintersSettings.Makezero)).
+ linter.NewConfig(makezero.New(&cfg.LintersSettings.Makezero)).
WithSince("v1.34.0").
WithPresets(linter.PresetStyle, linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/ashanbrown/makezero"),
- linter.NewConfig(linter.NewNoopDeprecated("maligned", cfg)).
+ linter.NewConfig(linter.NewNoopDeprecated("maligned", cfg, linter.DeprecationError)).
WithSince("v1.0.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance).
WithURL("https://github.com/mdempsky/maligned").
- Deprecated("The repository of the linter has been archived by the owner.", "v1.38.0", "govet 'fieldalignment'"),
+ DeprecatedError("The repository of the linter has been archived by the owner.", "v1.38.0", "govet 'fieldalignment'"),
- linter.NewConfig(golinters.NewMirror()).
+ linter.NewConfig(mirror.New()).
WithSince("v1.53.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithAutoFix().
WithURL("https://github.com/butuzov/mirror"),
- linter.NewConfig(golinters.NewMisspell(&cfg.LintersSettings.Misspell)).
+ linter.NewConfig(misspell.New(&cfg.LintersSettings.Misspell)).
WithSince("v1.8.0").
WithPresets(linter.PresetStyle, linter.PresetComment).
WithAutoFix().
WithURL("https://github.com/client9/misspell"),
- linter.NewConfig(golinters.NewMustTag(&cfg.LintersSettings.MustTag)).
+ linter.NewConfig(musttag.New(&cfg.LintersSettings.MustTag)).
WithSince("v1.51.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle, linter.PresetBugs).
WithURL("https://github.com/go-simpler/musttag"),
- linter.NewConfig(golinters.NewNakedret(&cfg.LintersSettings.Nakedret)).
+ linter.NewConfig(nakedret.New(&cfg.LintersSettings.Nakedret)).
WithSince("v1.19.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/alexkohler/nakedret"),
- linter.NewConfig(golinters.NewNestif(&cfg.LintersSettings.Nestif)).
+ linter.NewConfig(nestif.New(&cfg.LintersSettings.Nestif)).
WithSince("v1.25.0").
WithPresets(linter.PresetComplexity).
WithURL("https://github.com/nakabonne/nestif"),
- linter.NewConfig(golinters.NewNilErr()).
+ linter.NewConfig(nilerr.New()).
WithSince("v1.38.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs).
WithURL("https://github.com/gostaticanalysis/nilerr"),
- linter.NewConfig(golinters.NewNilNil(&cfg.LintersSettings.NilNil)).
+ linter.NewConfig(nilnil.New(&cfg.LintersSettings.NilNil)).
WithSince("v1.43.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/Antonboom/nilnil"),
- linter.NewConfig(golinters.NewNLReturn(&cfg.LintersSettings.Nlreturn)).
+ linter.NewConfig(nlreturn.New(&cfg.LintersSettings.Nlreturn)).
WithSince("v1.30.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/ssgreg/nlreturn"),
- linter.NewConfig(golinters.NewNoctx()).
+ linter.NewConfig(noctx.New()).
WithSince("v1.28.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance, linter.PresetBugs).
WithURL("https://github.com/sonatard/noctx"),
- linter.NewConfig(golinters.NewNoNamedReturns(&cfg.LintersSettings.NoNamedReturns)).
+ linter.NewConfig(nonamedreturns.New(&cfg.LintersSettings.NoNamedReturns)).
WithSince("v1.46.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/firefart/nonamedreturns"),
- linter.NewConfig(linter.NewNoopDeprecated("nosnakecase", cfg)).
+ linter.NewConfig(linter.NewNoopDeprecated("nosnakecase", cfg, linter.DeprecationError)).
WithSince("v1.47.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/sivchari/nosnakecase").
- Deprecated("The repository of the linter has been deprecated by the owner.", "v1.48.1", "revive 'var-naming'"),
+ DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.48.1", "revive 'var-naming'"),
- linter.NewConfig(golinters.NewNoSprintfHostPort()).
+ linter.NewConfig(nosprintfhostport.New()).
WithSince("v1.46.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/stbenjam/no-sprintf-host-port"),
- linter.NewConfig(golinters.NewParallelTest(&cfg.LintersSettings.ParallelTest)).
+ linter.NewConfig(paralleltest.New(&cfg.LintersSettings.ParallelTest)).
WithSince("v1.33.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle, linter.PresetTest).
WithURL("https://github.com/kunwardeep/paralleltest"),
- linter.NewConfig(golinters.NewPerfSprint(&cfg.LintersSettings.PerfSprint)).
+ linter.NewConfig(perfsprint.New(&cfg.LintersSettings.PerfSprint)).
WithSince("v1.55.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance).
WithURL("https://github.com/catenacyber/perfsprint"),
- linter.NewConfig(golinters.NewPreAlloc(&cfg.LintersSettings.Prealloc)).
+ linter.NewConfig(prealloc.New(&cfg.LintersSettings.Prealloc)).
WithSince("v1.19.0").
WithPresets(linter.PresetPerformance).
WithURL("https://github.com/alexkohler/prealloc"),
- linter.NewConfig(golinters.NewPredeclared(&cfg.LintersSettings.Predeclared)).
+ linter.NewConfig(predeclared.New(&cfg.LintersSettings.Predeclared)).
WithSince("v1.35.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/nishanths/predeclared"),
- linter.NewConfig(golinters.NewPromlinter(&cfg.LintersSettings.Promlinter)).
+ linter.NewConfig(promlinter.New(&cfg.LintersSettings.Promlinter)).
WithSince("v1.40.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/yeya24/promlinter"),
- linter.NewConfig(golinters.NewProtoGetter(&cfg.LintersSettings.ProtoGetter)).
+ linter.NewConfig(protogetter.New(&cfg.LintersSettings.ProtoGetter)).
WithSince("v1.55.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithAutoFix().
WithURL("https://github.com/ghostiam/protogetter"),
- linter.NewConfig(golinters.NewReassign(&cfg.LintersSettings.Reassign)).
+ linter.NewConfig(reassign.New(&cfg.LintersSettings.Reassign)).
WithSince("1.49.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/curioswitch/go-reassign"),
- linter.NewConfig(golinters.NewRevive(&cfg.LintersSettings.Revive)).
+ linter.NewConfig(revive.New(&cfg.LintersSettings.Revive)).
WithSince("v1.37.0").
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
ConsiderSlow().
WithURL("https://github.com/mgechev/revive"),
- linter.NewConfig(golinters.NewRowsErrCheck(&cfg.LintersSettings.RowsErrCheck)).
+ linter.NewConfig(rowserrcheck.New(&cfg.LintersSettings.RowsErrCheck)).
WithSince("v1.23.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs, linter.PresetSQL).
WithURL("https://github.com/jingyugao/rowserrcheck"),
- linter.NewConfig(golinters.NewSlogLint(&cfg.LintersSettings.SlogLint)).
+ linter.NewConfig(sloglint.New(&cfg.LintersSettings.SlogLint)).
WithSince("v1.55.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle, linter.PresetFormatting).
WithURL("https://github.com/go-simpler/sloglint"),
- linter.NewConfig(linter.NewNoopDeprecated("scopelint", cfg)).
+ linter.NewConfig(linter.NewNoopDeprecated("scopelint", cfg, linter.DeprecationError)).
WithSince("v1.12.0").
WithPresets(linter.PresetBugs).
WithURL("https://github.com/kyoh86/scopelint").
- Deprecated("The repository of the linter has been deprecated by the owner.", "v1.39.0", "exportloopref"),
+ DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.39.0", "exportloopref"),
- linter.NewConfig(golinters.NewSQLCloseCheck()).
+ linter.NewConfig(sqlclosecheck.New()).
WithSince("v1.28.0").
WithPresets(linter.PresetBugs, linter.PresetSQL).
WithLoadForGoAnalysis().
WithURL("https://github.com/ryanrolds/sqlclosecheck"),
- linter.NewConfig(golinters.NewSpancheck(&cfg.LintersSettings.Spancheck)).
+ linter.NewConfig(spancheck.New(&cfg.LintersSettings.Spancheck)).
WithSince("v1.56.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs).
WithURL("https://github.com/jjti/go-spancheck"),
- linter.NewConfig(golinters.NewStaticcheck(&cfg.LintersSettings.Staticcheck)).
+ linter.NewConfig(staticcheck.New(&cfg.LintersSettings.Staticcheck)).
WithEnabledByDefault().
WithSince("v1.0.0").
WithLoadForGoAnalysis().
@@ -571,59 +701,59 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithAlternativeNames(megacheckName).
WithURL("https://staticcheck.io/"),
- linter.NewConfig(linter.NewNoopDeprecated("structcheck", cfg)).
+ linter.NewConfig(linter.NewNoopDeprecated("structcheck", cfg, linter.DeprecationError)).
WithSince("v1.0.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetUnused).
WithURL("https://github.com/opennota/check").
- Deprecated("The owner seems to have abandoned the linter.", "v1.49.0", "unused"),
+ DeprecatedError("The owner seems to have abandoned the linter.", "v1.49.0", "unused"),
- linter.NewConfig(golinters.NewStylecheck(&cfg.LintersSettings.Stylecheck)).
+ linter.NewConfig(stylecheck.New(&cfg.LintersSettings.Stylecheck)).
WithSince("v1.20.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/dominikh/go-tools/tree/master/stylecheck"),
- linter.NewConfig(golinters.NewTagAlign(&cfg.LintersSettings.TagAlign)).
+ linter.NewConfig(tagalign.New(&cfg.LintersSettings.TagAlign)).
WithSince("v1.53.0").
WithPresets(linter.PresetStyle, linter.PresetFormatting).
WithAutoFix().
WithURL("https://github.com/4meepo/tagalign"),
- linter.NewConfig(golinters.NewTagliatelle(&cfg.LintersSettings.Tagliatelle)).
+ linter.NewConfig(tagliatelle.New(&cfg.LintersSettings.Tagliatelle)).
WithSince("v1.40.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/ldez/tagliatelle"),
- linter.NewConfig(golinters.NewTenv(&cfg.LintersSettings.Tenv)).
+ linter.NewConfig(tenv.New(&cfg.LintersSettings.Tenv)).
WithSince("v1.43.0").
- WithPresets(linter.PresetStyle).
+ WithPresets(linter.PresetTest).
WithLoadForGoAnalysis().
WithURL("https://github.com/sivchari/tenv"),
- linter.NewConfig(golinters.NewTestableexamples()).
+ linter.NewConfig(testableexamples.New()).
WithSince("v1.50.0").
WithPresets(linter.PresetTest).
WithURL("https://github.com/maratori/testableexamples"),
- linter.NewConfig(golinters.NewTestifylint(&cfg.LintersSettings.Testifylint)).
+ linter.NewConfig(testifylint.New(&cfg.LintersSettings.Testifylint)).
WithSince("v1.55.0").
WithPresets(linter.PresetTest, linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/Antonboom/testifylint"),
- linter.NewConfig(golinters.NewTestpackage(&cfg.LintersSettings.Testpackage)).
+ linter.NewConfig(testpackage.New(&cfg.LintersSettings.Testpackage)).
WithSince("v1.25.0").
WithPresets(linter.PresetStyle, linter.PresetTest).
WithURL("https://github.com/maratori/testpackage"),
- linter.NewConfig(golinters.NewThelper(&cfg.LintersSettings.Thelper)).
+ linter.NewConfig(thelper.New(&cfg.LintersSettings.Thelper)).
WithSince("v1.34.0").
- WithPresets(linter.PresetStyle).
+ WithPresets(linter.PresetTest).
WithLoadForGoAnalysis().
WithURL("https://github.com/kulti/thelper"),
- linter.NewConfig(golinters.NewTparallel()).
+ linter.NewConfig(tparallel.New()).
WithSince("v1.32.0").
WithPresets(linter.PresetStyle, linter.PresetTest).
WithLoadForGoAnalysis().
@@ -632,24 +762,21 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
linter.NewConfig(golinters.NewTypecheck()).
WithInternal().
WithEnabledByDefault().
- WithSince("v1.3.0").
- WithLoadForGoAnalysis().
- WithPresets(linter.PresetBugs).
- WithURL(""),
+ WithSince("v1.3.0"),
- linter.NewConfig(golinters.NewUnconvert(&cfg.LintersSettings.Unconvert)).
+ linter.NewConfig(unconvert.New(&cfg.LintersSettings.Unconvert)).
WithSince("v1.0.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/mdempsky/unconvert"),
- linter.NewConfig(golinters.NewUnparam(&cfg.LintersSettings.Unparam)).
+ linter.NewConfig(unparam.New(&cfg.LintersSettings.Unparam)).
WithSince("v1.9.0").
WithPresets(linter.PresetUnused).
WithLoadForGoAnalysis().
WithURL("https://github.com/mvdan/unparam"),
- linter.NewConfig(golinters.NewUnused(&cfg.LintersSettings.Unused, &cfg.LintersSettings.Staticcheck)).
+ linter.NewConfig(unused.New(&cfg.LintersSettings.Unused)).
WithEnabledByDefault().
WithSince("v1.20.0").
WithLoadForGoAnalysis().
@@ -659,55 +786,55 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithChangeTypes().
WithURL("https://github.com/dominikh/go-tools/tree/master/unused"),
- linter.NewConfig(golinters.NewUseStdlibVars(&cfg.LintersSettings.UseStdlibVars)).
+ linter.NewConfig(usestdlibvars.New(&cfg.LintersSettings.UseStdlibVars)).
WithSince("v1.48.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/sashamelentyev/usestdlibvars"),
- linter.NewConfig(linter.NewNoopDeprecated("varcheck", cfg)).
+ linter.NewConfig(linter.NewNoopDeprecated("varcheck", cfg, linter.DeprecationError)).
WithSince("v1.0.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetUnused).
WithURL("https://github.com/opennota/check").
- Deprecated("The owner seems to have abandoned the linter.", "v1.49.0", "unused"),
+ DeprecatedError("The owner seems to have abandoned the linter.", "v1.49.0", "unused"),
- linter.NewConfig(golinters.NewVarnamelen(&cfg.LintersSettings.Varnamelen)).
+ linter.NewConfig(varnamelen.New(&cfg.LintersSettings.Varnamelen)).
WithSince("v1.43.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/blizzy78/varnamelen"),
- linter.NewConfig(golinters.NewWastedAssign()).
+ linter.NewConfig(wastedassign.New()).
WithSince("v1.38.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/sanposhiho/wastedassign"),
- linter.NewConfig(golinters.NewWhitespace(&cfg.LintersSettings.Whitespace)).
+ linter.NewConfig(whitespace.New(&cfg.LintersSettings.Whitespace)).
WithSince("v1.19.0").
WithPresets(linter.PresetStyle).
WithAutoFix().
WithURL("https://github.com/ultraware/whitespace"),
- linter.NewConfig(golinters.NewWrapcheck(&cfg.LintersSettings.Wrapcheck)).
+ linter.NewConfig(wrapcheck.New(&cfg.LintersSettings.Wrapcheck)).
WithSince("v1.32.0").
WithPresets(linter.PresetStyle, linter.PresetError).
WithLoadForGoAnalysis().
WithURL("https://github.com/tomarrell/wrapcheck"),
- linter.NewConfig(golinters.NewWSL(&cfg.LintersSettings.WSL)).
+ linter.NewConfig(wsl.New(&cfg.LintersSettings.WSL)).
WithSince("v1.20.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/bombsimon/wsl"),
- linter.NewConfig(golinters.NewZerologLint()).
+ linter.NewConfig(zerologlint.New()).
WithSince("v1.53.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/ykadowak/zerologlint"),
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives
- linter.NewConfig(golinters.NewNoLintLint(&cfg.LintersSettings.NoLintLint)).
+ linter.NewConfig(nolintlint.New(&cfg.LintersSettings.NoLintLint)).
WithSince("v1.26.0").
WithPresets(linter.PresetStyle).
WithAutoFix().
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_plugin_go.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_plugin_go.go
index 2a349c956..88f3e2ae3 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_plugin_go.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/builder_plugin_go.go
@@ -43,14 +43,11 @@ func (b *PluginGoBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
continue
}
- settings := settings
-
lc, err := b.loadConfig(cfg, name, &settings)
if err != nil {
return nil, fmt.Errorf("unable to load custom analyzer %q: %s, %w", name, settings.Path, err)
- } else {
- linters = append(linters, lc)
}
+ linters = append(linters, lc)
}
return linters, nil
@@ -128,7 +125,7 @@ func (b *PluginGoBuilder) lookupAnalyzerPlugin(plug *plugin.Plugin) ([]*analysis
}
b.log.Warnf("plugin: 'AnalyzerPlugin' plugins are deprecated, please use the new plugin signature: " +
- "https://golangci-lint.run/contributing/new-linters/#create-a-plugin")
+ "https://golangci-lint.run/plugins/go-plugins#create-a-plugin")
analyzerPlugin, ok := symbol.(AnalyzerPlugin)
if !ok {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/manager.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/manager.go
index 0cd6cec24..75ab53d7c 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/manager.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/manager.go
@@ -162,7 +162,6 @@ func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*li
// --presets can only add linters to default set
for _, p := range m.cfg.Linters.Presets {
for _, lc := range m.GetAllLinterConfigsForPreset(p) {
- lc := lc
resultLintersSet[lc.Name()] = lc
}
}
@@ -204,21 +203,30 @@ func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*li
}
func (m *Manager) combineGoAnalysisLinters(linters map[string]*linter.Config) {
+ mlConfig := &linter.Config{}
+
var goanalysisLinters []*goanalysis.Linter
- goanalysisPresets := map[string]bool{}
+
for _, lc := range linters {
lnt, ok := lc.Linter.(*goanalysis.Linter)
if !ok {
continue
}
+
if lnt.LoadMode() == goanalysis.LoadModeWholeProgram {
// It's ineffective by CPU and memory to run whole-program and incremental analyzers at once.
continue
}
- goanalysisLinters = append(goanalysisLinters, lnt)
- for _, p := range lc.InPresets {
- goanalysisPresets[p] = true
+
+ mlConfig.LoadMode |= lc.LoadMode
+
+ if lc.IsSlowLinter() {
+ mlConfig.ConsiderSlow()
}
+
+ mlConfig.InPresets = append(mlConfig.InPresets, lc.InPresets...)
+
+ goanalysisLinters = append(goanalysisLinters, lnt)
}
if len(goanalysisLinters) <= 1 {
@@ -245,22 +253,13 @@ func (m *Manager) combineGoAnalysisLinters(linters map[string]*linter.Config) {
return a.Name() <= b.Name()
})
- ml := goanalysis.NewMetaLinter(goanalysisLinters)
+ mlConfig.Linter = goanalysis.NewMetaLinter(goanalysisLinters)
- presets := maps.Keys(goanalysisPresets)
- sort.Strings(presets)
-
- mlConfig := &linter.Config{
- Linter: ml,
- EnabledByDefault: false,
- InPresets: presets,
- AlternativeNames: nil,
- OriginalURL: "",
- }
+ sort.Strings(mlConfig.InPresets)
+ mlConfig.InPresets = slices.Compact(mlConfig.InPresets)
- mlConfig = mlConfig.WithLoadForGoAnalysis()
+ linters[mlConfig.Linter.Name()] = mlConfig
- linters[ml.Name()] = mlConfig
m.debugf("Combined %d go/analysis linters into one metalinter", len(goanalysisLinters))
}
@@ -303,6 +302,10 @@ func AllPresets() []string {
func linterConfigsToMap(lcs []*linter.Config) map[string]*linter.Config {
ret := map[string]*linter.Config{}
for _, lc := range lcs {
+ if lc.IsDeprecated() && lc.Deprecation.Level > linter.DeprecationWarning {
+ continue
+ }
+
ret[lc.Name()] = lc
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/validator.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/validator.go
index 364d5082a..264d063aa 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/validator.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/lint/lintersdb/validator.go
@@ -3,10 +3,13 @@ package lintersdb
import (
"errors"
"fmt"
+ "os"
"slices"
"strings"
"github.com/golangci/golangci-lint/pkg/config"
+ "github.com/golangci/golangci-lint/pkg/lint/linter"
+ "github.com/golangci/golangci-lint/pkg/logutils"
)
type Validator struct {
@@ -20,14 +23,10 @@ func NewValidator(m *Manager) *Validator {
// Validate validates the configuration by calling all other validators for different
// sections in the configuration and then some additional linter validation functions.
func (v Validator) Validate(cfg *config.Config) error {
- err := cfg.Validate()
- if err != nil {
- return err
- }
-
validators := []func(cfg *config.Linters) error{
v.validateLintersNames,
v.validatePresets,
+ v.alternativeNamesDeprecation,
}
for _, v := range validators {
@@ -40,17 +39,30 @@ func (v Validator) Validate(cfg *config.Config) error {
}
func (v Validator) validateLintersNames(cfg *config.Linters) error {
- allNames := append([]string{}, cfg.Enable...)
- allNames = append(allNames, cfg.Disable...)
-
var unknownNames []string
- for _, name := range allNames {
+ for _, name := range cfg.Enable {
if v.m.GetLinterConfigs(name) == nil {
unknownNames = append(unknownNames, name)
}
}
+ for _, name := range cfg.Disable {
+ lcs := v.m.GetLinterConfigs(name)
+ if len(lcs) == 0 {
+ unknownNames = append(unknownNames, name)
+ continue
+ }
+
+ for _, lc := range lcs {
+ if lc.IsDeprecated() && lc.Deprecation.Level > linter.DeprecationWarning {
+ v.m.log.Warnf("The linter %q is deprecated (step 2) and deactivated. "+
+ "It should be removed from the list of disabled linters. "+
+ "https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle", lc.Name())
+ }
+ }
+ }
+
if len(unknownNames) > 0 {
return fmt.Errorf("unknown linters: '%v', run 'golangci-lint help linters' to see the list of supported linters",
strings.Join(unknownNames, ","))
@@ -59,7 +71,7 @@ func (v Validator) validateLintersNames(cfg *config.Linters) error {
return nil
}
-func (v Validator) validatePresets(cfg *config.Linters) error {
+func (Validator) validatePresets(cfg *config.Linters) error {
presets := AllPresets()
for _, p := range cfg.Presets {
@@ -75,3 +87,34 @@ func (v Validator) validatePresets(cfg *config.Linters) error {
return nil
}
+
+func (v Validator) alternativeNamesDeprecation(cfg *config.Linters) error {
+ if v.m.cfg.InternalTest || v.m.cfg.InternalCmdTest || os.Getenv(logutils.EnvTestRun) == "1" {
+ return nil
+ }
+
+ altNames := map[string][]string{}
+ for _, lc := range v.m.GetAllSupportedLinterConfigs() {
+ for _, alt := range lc.AlternativeNames {
+ altNames[alt] = append(altNames[alt], lc.Name())
+ }
+ }
+
+ names := cfg.Enable
+ names = append(names, cfg.Disable...)
+
+ for _, name := range names {
+ lc, ok := altNames[name]
+ if !ok {
+ continue
+ }
+
+ if len(lc) > 1 {
+ v.m.log.Warnf("The linter named %q is deprecated. It has been split into: %s.", name, strings.Join(lc, ", "))
+ } else {
+ v.m.log.Warnf("The name %q is deprecated. The linter has been renamed to: %s.", name, lc[0])
+ }
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/package.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/package.go
index 7faa399e9..c314166ca 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/package.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/lint/package.go
@@ -78,8 +78,10 @@ func (l *PackageLoader) loadPackages(ctx context.Context, loadMode packages.Load
// TODO: use fset, parsefile, overlay
}
- args := l.buildArgs()
+ args := buildArgs(l.args)
+
l.debugf("Built loader args are %s", args)
+
pkgs, err := packages.Load(conf, args...)
if err != nil {
return nil, fmt.Errorf("failed to load with go/packages: %w", err)
@@ -103,7 +105,7 @@ func (l *PackageLoader) loadPackages(ctx context.Context, loadMode packages.Load
return l.filterTestMainPackages(pkgs), nil
}
-func (l *PackageLoader) parseLoadedPackagesErrors(pkgs []*packages.Package) error {
+func (*PackageLoader) parseLoadedPackagesErrors(pkgs []*packages.Package) error {
for _, pkg := range pkgs {
var errs []packages.Error
for _, err := range pkg.Errors {
@@ -212,24 +214,6 @@ func (l *PackageLoader) prepareBuildContext() {
build.Default.BuildTags = l.cfg.Run.BuildTags
}
-func (l *PackageLoader) buildArgs() []string {
- if len(l.args) == 0 {
- return []string{"./..."}
- }
-
- var retArgs []string
- for _, arg := range l.args {
- if strings.HasPrefix(arg, ".") || filepath.IsAbs(arg) {
- retArgs = append(retArgs, arg)
- } else {
- // go/packages doesn't work well if we don't have the prefix ./ for local packages
- retArgs = append(retArgs, fmt.Sprintf(".%c%s", filepath.Separator, arg))
- }
- }
-
- return retArgs
-}
-
func (l *PackageLoader) makeBuildFlags() []string {
var buildFlags []string
@@ -247,6 +231,24 @@ func (l *PackageLoader) makeBuildFlags() []string {
return buildFlags
}
+func buildArgs(args []string) []string {
+ if len(args) == 0 {
+ return []string{"./..."}
+ }
+
+ var retArgs []string
+ for _, arg := range args {
+ if strings.HasPrefix(arg, ".") || filepath.IsAbs(arg) {
+ retArgs = append(retArgs, arg)
+ } else {
+ // go/packages doesn't work well if we don't have the prefix ./ for local packages
+ retArgs = append(retArgs, fmt.Sprintf(".%c%s", filepath.Separator, arg))
+ }
+ }
+
+ return retArgs
+}
+
func findLoadMode(linters []*linter.Config) packages.LoadMode {
loadMode := packages.LoadMode(0)
for _, lc := range linters {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/lint/runner.go b/vendor/github.com/golangci/golangci-lint/pkg/lint/runner.go
index b1d604c96..c3b983ff6 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/lint/runner.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/lint/runner.go
@@ -14,7 +14,6 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
"github.com/golangci/golangci-lint/pkg/logutils"
- "github.com/golangci/golangci-lint/pkg/packages"
"github.com/golangci/golangci-lint/pkg/result"
"github.com/golangci/golangci-lint/pkg/result/processors"
"github.com/golangci/golangci-lint/pkg/timeutils"
@@ -48,10 +47,10 @@ func NewRunner(log logutils.Log, cfg *config.Config, args []string, goenv *gouti
skipDirs := cfg.Issues.ExcludeDirs
if cfg.Issues.UseDefaultExcludeDirs {
- skipDirs = append(skipDirs, packages.StdExcludeDirRegexps...)
+ skipDirs = append(skipDirs, processors.StdExcludeDirRegexps...)
}
- skipDirsProcessor, err := processors.NewSkipDirs(skipDirs, log.Child(logutils.DebugKeySkipDirs), args, cfg.Output.PathPrefix)
+ skipDirsProcessor, err := processors.NewSkipDirs(log.Child(logutils.DebugKeySkipDirs), skipDirs, args, cfg.Output.PathPrefix)
if err != nil {
return nil, err
}
@@ -76,23 +75,23 @@ func NewRunner(log logutils.Log, cfg *config.Config, args []string, goenv *gouti
skipFilesProcessor,
skipDirsProcessor, // must be after path prettifier
- processors.NewAutogeneratedExclude(cfg.Issues.ExcludeGeneratedStrict),
+ processors.NewAutogeneratedExclude(cfg.Issues.ExcludeGenerated),
// Must be before exclude because users see already marked output and configure excluding by it.
processors.NewIdentifierMarker(),
- getExcludeProcessor(&cfg.Issues),
- getExcludeRulesProcessor(&cfg.Issues, log, files),
+ processors.NewExclude(&cfg.Issues),
+ processors.NewExcludeRules(log.Child(logutils.DebugKeyExcludeRules), files, &cfg.Issues),
processors.NewNolint(log.Child(logutils.DebugKeyNolint), dbManager, enabledLinters),
processors.NewUniqByLine(cfg),
- processors.NewDiff(cfg.Issues.Diff, cfg.Issues.DiffFromRevision, cfg.Issues.DiffPatchFilePath, cfg.Issues.WholeFiles),
+ processors.NewDiff(&cfg.Issues),
processors.NewMaxPerFileFromLinter(cfg),
processors.NewMaxSameIssues(cfg.Issues.MaxSameIssues, log.Child(logutils.DebugKeyMaxSameIssues), cfg),
processors.NewMaxFromLinter(cfg.Issues.MaxIssuesPerLinter, log.Child(logutils.DebugKeyMaxFromLinter), cfg),
processors.NewSourceCode(lineCache, log.Child(logutils.DebugKeySourceCode)),
processors.NewPathShortener(),
- getSeverityRulesProcessor(&cfg.Severity, log, files),
+ processors.NewSeverity(log.Child(logutils.DebugKeySeverityRules), files, &cfg.Severity),
// The fixer still needs to see paths for the issues that are relative to the current directory.
processors.NewFixer(cfg, log, fileCache),
@@ -116,7 +115,6 @@ func (r *Runner) Run(ctx context.Context, linters []*linter.Config) ([]result.Is
)
for _, lc := range linters {
- lc := lc
sw.TrackStage(lc.Name(), func() {
linterIssues, err := r.runLinterSafe(ctx, r.lintCtx, lc)
if err != nil {
@@ -190,7 +188,6 @@ func (r *Runner) processLintResults(inIssues []result.Issue) []result.Issue {
// finalize processors: logging, clearing, no heavy work here
for _, p := range r.Processors {
- p := p
sw.TrackStage(p.Name(), func() {
p.Finish()
})
@@ -209,11 +206,11 @@ func (r *Runner) printPerProcessorStat(stat map[string]processorStat) {
parts := make([]string, 0, len(stat))
for name, ps := range stat {
if ps.inCount != 0 {
- parts = append(parts, fmt.Sprintf("%s: %d/%d", name, ps.outCount, ps.inCount))
+ parts = append(parts, fmt.Sprintf("%s: %d/%d", name, ps.inCount, ps.outCount))
}
}
if len(parts) != 0 {
- r.Log.Infof("Processors filtering stat (out/in): %s", strings.Join(parts, ", "))
+ r.Log.Infof("Processors filtering stat (in/out): %s", strings.Join(parts, ", "))
}
}
@@ -221,7 +218,6 @@ func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch, s
for _, p := range r.Processors {
var newIssues []result.Issue
var err error
- p := p
sw.TrackStage(p.Name(), func() {
newIssues, err = p.Process(issues)
})
@@ -236,6 +232,7 @@ func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch, s
issues = newIssues
}
+ // This is required by JSON serialization
if issues == nil {
issues = []result.Issue{}
}
@@ -243,72 +240,3 @@ func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch, s
return issues
}
-
-func getExcludeProcessor(cfg *config.Issues) processors.Processor {
- opts := processors.ExcludeOptions{
- CaseSensitive: cfg.ExcludeCaseSensitive,
- }
-
- if len(cfg.ExcludePatterns) != 0 {
- opts.Pattern = fmt.Sprintf("(%s)", strings.Join(cfg.ExcludePatterns, "|"))
- }
-
- return processors.NewExclude(opts)
-}
-
-func getExcludeRulesProcessor(cfg *config.Issues, log logutils.Log, files *fsutils.Files) processors.Processor {
- var excludeRules []processors.ExcludeRule
- for _, r := range cfg.ExcludeRules {
- excludeRules = append(excludeRules, processors.ExcludeRule{
- BaseRule: processors.BaseRule{
- Text: r.Text,
- Source: r.Source,
- Path: r.Path,
- PathExcept: r.PathExcept,
- Linters: r.Linters,
- },
- })
- }
-
- if cfg.UseDefaultExcludes {
- for _, r := range config.GetExcludePatterns(cfg.IncludeDefaultExcludes) {
- excludeRules = append(excludeRules, processors.ExcludeRule{
- BaseRule: processors.BaseRule{
- Text: r.Pattern,
- Linters: []string{r.Linter},
- },
- })
- }
- }
-
- opts := processors.ExcludeRulesOptions{
- Rules: excludeRules,
- CaseSensitive: cfg.ExcludeCaseSensitive,
- }
-
- return processors.NewExcludeRules(log.Child(logutils.DebugKeyExcludeRules), files, opts)
-}
-
-func getSeverityRulesProcessor(cfg *config.Severity, log logutils.Log, files *fsutils.Files) processors.Processor {
- var severityRules []processors.SeverityRule
- for _, r := range cfg.Rules {
- severityRules = append(severityRules, processors.SeverityRule{
- Severity: r.Severity,
- BaseRule: processors.BaseRule{
- Text: r.Text,
- Source: r.Source,
- Path: r.Path,
- PathExcept: r.PathExcept,
- Linters: r.Linters,
- },
- })
- }
-
- severityOpts := processors.SeverityOptions{
- Default: cfg.Default,
- Rules: severityRules,
- CaseSensitive: cfg.CaseSensitive,
- }
-
- return processors.NewSeverity(log.Child(logutils.DebugKeySeverityRules), files, severityOpts)
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/logutils/mock.go b/vendor/github.com/golangci/golangci-lint/pkg/logutils/mock.go
index efda8cc20..bddcf8552 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/logutils/mock.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/logutils/mock.go
@@ -13,28 +13,23 @@ func NewMockLog() *MockLog {
}
func (m *MockLog) Fatalf(format string, args ...any) {
- mArgs := []any{format}
- m.Called(append(mArgs, args...)...)
+ m.Called(append([]any{format}, args...)...)
}
func (m *MockLog) Panicf(format string, args ...any) {
- mArgs := []any{format}
- m.Called(append(mArgs, args...)...)
+ m.Called(append([]any{format}, args...)...)
}
func (m *MockLog) Errorf(format string, args ...any) {
- mArgs := []any{format}
- m.Called(append(mArgs, args...)...)
+ m.Called(append([]any{format}, args...)...)
}
func (m *MockLog) Warnf(format string, args ...any) {
- mArgs := []any{format}
- m.Called(append(mArgs, args...)...)
+ m.Called(append([]any{format}, args...)...)
}
func (m *MockLog) Infof(format string, args ...any) {
- mArgs := []any{format}
- m.Called(append(mArgs, args...)...)
+ m.Called(append([]any{format}, args...)...)
}
func (m *MockLog) Child(name string) Log {
@@ -45,3 +40,43 @@ func (m *MockLog) Child(name string) Log {
func (m *MockLog) SetLevel(level LogLevel) {
m.Called(level)
}
+
+func (m *MockLog) OnFatalf(format string, args ...any) *MockLog {
+ arguments := append([]any{format}, args...)
+
+ m.On("Fatalf", arguments...)
+
+ return m
+}
+
+func (m *MockLog) OnPanicf(format string, args ...any) *MockLog {
+ arguments := append([]any{format}, args...)
+
+ m.On("Panicf", arguments...)
+
+ return m
+}
+
+func (m *MockLog) OnErrorf(format string, args ...any) *MockLog {
+ arguments := append([]any{format}, args...)
+
+ m.On("Errorf", arguments...)
+
+ return m
+}
+
+func (m *MockLog) OnWarnf(format string, args ...any) *MockLog {
+ arguments := append([]any{format}, args...)
+
+ m.On("Warnf", arguments...)
+
+ return m
+}
+
+func (m *MockLog) OnInfof(format string, args ...any) *MockLog {
+ arguments := append([]any{format}, args...)
+
+ m.On("Infof", arguments...)
+
+ return m
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/packages/exclude.go b/vendor/github.com/golangci/golangci-lint/pkg/packages/exclude.go
deleted file mode 100644
index cdd327f5d..000000000
--- a/vendor/github.com/golangci/golangci-lint/pkg/packages/exclude.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package packages
-
-import (
- "fmt"
- "path/filepath"
- "regexp"
-)
-
-func pathElemReImpl(e string, sep rune) string {
- escapedSep := regexp.QuoteMeta(string(sep)) // needed for windows sep '\\'
- return fmt.Sprintf(`(^|%s)%s($|%s)`, escapedSep, e, escapedSep)
-}
-
-func pathElemRe(e string) string {
- return pathElemReImpl(e, filepath.Separator)
-}
-
-var StdExcludeDirRegexps = []string{
- pathElemRe("vendor"),
- pathElemRe("third_party"),
- pathElemRe("testdata"),
- pathElemRe("examples"),
- pathElemRe("Godeps"),
- pathElemRe("builtin"),
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/printers/github.go b/vendor/github.com/golangci/golangci-lint/pkg/printers/githubaction.go
index e396119da..d9cdb1e6e 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/printers/github.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/printers/githubaction.go
@@ -8,20 +8,30 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-type GitHub struct {
+const defaultGithubSeverity = "error"
+
+type GitHubAction struct {
w io.Writer
}
-const defaultGithubSeverity = "error"
+// NewGitHubAction output format outputs issues according to GitHub Action.
+// Deprecated
+func NewGitHubAction(w io.Writer) *GitHubAction {
+ return &GitHubAction{w: w}
+}
-// NewGitHub output format outputs issues according to GitHub actions format:
-// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message
-func NewGitHub(w io.Writer) *GitHub {
- return &GitHub{w: w}
+func (p *GitHubAction) Print(issues []result.Issue) error {
+ for ind := range issues {
+ _, err := fmt.Fprintln(p.w, formatIssueAsGitHub(&issues[ind]))
+ if err != nil {
+ return err
+ }
+ }
+ return nil
}
// print each line as: ::error file=app.js,line=10,col=15::Something went wrong
-func formatIssueAsGithub(issue *result.Issue) string {
+func formatIssueAsGitHub(issue *result.Issue) string {
severity := defaultGithubSeverity
if issue.Severity != "" {
severity = issue.Severity
@@ -40,13 +50,3 @@ func formatIssueAsGithub(issue *result.Issue) string {
ret += fmt.Sprintf("::%s (%s)", issue.Text, issue.FromLinter)
return ret
}
-
-func (p *GitHub) Print(issues []result.Issue) error {
- for ind := range issues {
- _, err := fmt.Fprintln(p.w, formatIssueAsGithub(&issues[ind]))
- if err != nil {
- return err
- }
- }
- return nil
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/printers/junitxml.go b/vendor/github.com/golangci/golangci-lint/pkg/printers/junitxml.go
index 3e3f82f58..7d0a703b0 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/printers/junitxml.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/printers/junitxml.go
@@ -30,6 +30,8 @@ type testCaseXML struct {
Name string `xml:"name,attr"`
ClassName string `xml:"classname,attr"`
Failure failureXML `xml:"failure"`
+ File string `xml:"file,attr,omitempty"`
+ Line int `xml:"line,attr,omitempty"`
}
type failureXML struct {
@@ -39,11 +41,15 @@ type failureXML struct {
}
type JunitXML struct {
- w io.Writer
+ extended bool
+ w io.Writer
}
-func NewJunitXML(w io.Writer) *JunitXML {
- return &JunitXML{w: w}
+func NewJunitXML(extended bool, w io.Writer) *JunitXML {
+ return &JunitXML{
+ extended: extended,
+ w: w,
+ }
}
func (p JunitXML) Print(issues []result.Issue) error {
@@ -68,6 +74,11 @@ func (p JunitXML) Print(issues []result.Issue) error {
},
}
+ if p.extended {
+ tc.File = i.Pos.Filename
+ tc.Line = i.Pos.Line
+ }
+
testSuite.TestCases = append(testSuite.TestCases, tc)
suites[suiteName] = testSuite
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/printers/printer.go b/vendor/github.com/golangci/golangci-lint/pkg/printers/printer.go
index 08c34234a..20be02e01 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/printers/printer.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/printers/printer.go
@@ -115,7 +115,7 @@ func (c *Printer) createPrinter(format string, w io.Writer) (issuePrinter, error
switch format {
case config.OutFormatJSON:
p = NewJSON(c.reportData, w)
- case config.OutFormatColoredLineNumber, config.OutFormatLineNumber:
+ case config.OutFormatLineNumber, config.OutFormatColoredLineNumber:
p = NewText(c.cfg.PrintIssuedLine,
format == config.OutFormatColoredLineNumber, c.cfg.PrintLinterName,
c.log.Child(logutils.DebugKeyTextPrinter), w)
@@ -129,12 +129,14 @@ func (c *Printer) createPrinter(format string, w io.Writer) (issuePrinter, error
p = NewCodeClimate(w)
case config.OutFormatHTML:
p = NewHTML(w)
- case config.OutFormatJunitXML:
- p = NewJunitXML(w)
+ case config.OutFormatJunitXML, config.OutFormatJunitXMLExtended:
+ p = NewJunitXML(format == config.OutFormatJunitXMLExtended, w)
case config.OutFormatGithubActions:
- p = NewGitHub(w)
+ p = NewGitHubAction(w)
case config.OutFormatTeamCity:
p = NewTeamCity(w)
+ case config.OutFormatSarif:
+ p = NewSarif(w)
default:
return nil, fmt.Errorf("unknown output format %q", format)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/printers/sarif.go b/vendor/github.com/golangci/golangci-lint/pkg/printers/sarif.go
new file mode 100644
index 000000000..8b1dd2ee2
--- /dev/null
+++ b/vendor/github.com/golangci/golangci-lint/pkg/printers/sarif.go
@@ -0,0 +1,117 @@
+package printers
+
+import (
+ "encoding/json"
+ "io"
+
+ "github.com/golangci/golangci-lint/pkg/result"
+)
+
+const (
+ sarifVersion = "2.1.0"
+ sarifSchemaURI = "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.6.json"
+)
+
+type SarifOutput struct {
+ Version string `json:"version"`
+ Schema string `json:"$schema"`
+ Runs []sarifRun `json:"runs"`
+}
+
+type sarifRun struct {
+ Tool sarifTool `json:"tool"`
+ Results []sarifResult `json:"results"`
+}
+
+type sarifTool struct {
+ Driver struct {
+ Name string `json:"name"`
+ } `json:"driver"`
+}
+
+type sarifResult struct {
+ RuleID string `json:"ruleId"`
+ Level string `json:"level"`
+ Message sarifMessage `json:"message"`
+ Locations []sarifLocation `json:"locations"`
+}
+
+type sarifMessage struct {
+ Text string `json:"text"`
+}
+
+type sarifLocation struct {
+ PhysicalLocation sarifPhysicalLocation `json:"physicalLocation"`
+}
+
+type sarifPhysicalLocation struct {
+ ArtifactLocation sarifArtifactLocation `json:"artifactLocation"`
+ Region sarifRegion `json:"region"`
+}
+
+type sarifArtifactLocation struct {
+ URI string `json:"uri"`
+ Index int `json:"index"`
+}
+
+type sarifRegion struct {
+ StartLine int `json:"startLine"`
+ StartColumn int `json:"startColumn"`
+}
+
+type Sarif struct {
+ w io.Writer
+}
+
+func NewSarif(w io.Writer) *Sarif {
+ return &Sarif{w: w}
+}
+
+func (p Sarif) Print(issues []result.Issue) error {
+ run := sarifRun{}
+ run.Tool.Driver.Name = "golangci-lint"
+ run.Results = make([]sarifResult, 0)
+
+ for i := range issues {
+ issue := issues[i]
+
+ severity := issue.Severity
+
+ switch severity {
+ // https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/sarif-v2.1.0-errata01-os-complete.html#_Toc141790898
+ case "none", "note", "warning", "error":
+ // Valid levels.
+ default:
+ severity = "error"
+ }
+
+ sr := sarifResult{
+ RuleID: issue.FromLinter,
+ Level: severity,
+ Message: sarifMessage{Text: issue.Text},
+ Locations: []sarifLocation{
+ {
+ PhysicalLocation: sarifPhysicalLocation{
+ ArtifactLocation: sarifArtifactLocation{URI: issue.FilePath()},
+ Region: sarifRegion{
+ StartLine: issue.Line(),
+ // If startColumn is absent, it SHALL default to 1.
+ // https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/sarif-v2.1.0-errata01-os-complete.html#_Toc141790941
+ StartColumn: max(1, issue.Column()),
+ },
+ },
+ },
+ },
+ }
+
+ run.Results = append(run.Results, sr)
+ }
+
+ output := SarifOutput{
+ Version: sarifVersion,
+ Schema: sarifSchemaURI,
+ Runs: []sarifRun{run},
+ }
+
+ return json.NewEncoder(p.w).Encode(output)
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/printers/teamcity.go b/vendor/github.com/golangci/golangci-lint/pkg/printers/teamcity.go
index ae0886912..1d1c9f7d3 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/printers/teamcity.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/printers/teamcity.go
@@ -89,7 +89,7 @@ type InspectionType struct {
func (i InspectionType) Print(w io.Writer, escaper *strings.Replacer) (int, error) {
return fmt.Fprintf(w, "##teamcity[inspectionType id='%s' name='%s' description='%s' category='%s']\n",
- limit(i.id, smallLimit), limit(i.name, smallLimit), limit(escaper.Replace(i.description), largeLimit), limit(i.category, smallLimit))
+ cutVal(i.id, smallLimit), cutVal(i.name, smallLimit), cutVal(escaper.Replace(i.description), largeLimit), cutVal(i.category, smallLimit))
}
// InspectionInstance reports a specific defect, warning, error message.
@@ -105,15 +105,15 @@ type InspectionInstance struct {
func (i InspectionInstance) Print(w io.Writer, replacer *strings.Replacer) (int, error) {
return fmt.Fprintf(w, "##teamcity[inspection typeId='%s' message='%s' file='%s' line='%d' SEVERITY='%s']\n",
- limit(i.typeID, smallLimit),
- limit(replacer.Replace(i.message), largeLimit),
- limit(i.file, largeLimit),
+ cutVal(i.typeID, smallLimit),
+ cutVal(replacer.Replace(i.message), largeLimit),
+ cutVal(i.file, largeLimit),
i.line, strings.ToUpper(i.severity))
}
-func limit(s string, max int) string {
+func cutVal(s string, limit int) string {
var size, count int
- for i := 0; i < max && count < len(s); i++ {
+ for i := 0; i < limit && count < len(s); i++ {
_, size = utf8.DecodeRuneInString(s[count:])
count += size
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/autogenerated_exclude.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/autogenerated_exclude.go
index b5944cd1d..82316f6a0 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/autogenerated_exclude.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/autogenerated_exclude.go
@@ -13,12 +13,27 @@ import (
)
const (
+ AutogeneratedModeLax = "lax"
+ AutogeneratedModeStrict = "strict"
+ AutogeneratedModeDisable = "disable"
+)
+
+// The values must be in lowercase.
+const (
genCodeGenerated = "code generated"
genDoNotEdit = "do not edit"
- genAutoFile = "autogenerated file" // easyjson
+
+ // Related to easyjson.
+ genAutoFile = "autogenerated file"
+
+ //nolint:lll // Long URL
+ // Related to Swagger Codegen.
+ // https://github.com/swagger-api/swagger-codegen/blob/61cfeac3b9d855b4eb8bffa0d118bece117bcb7d/modules/swagger-codegen/src/main/resources/go/partial_header.mustache#L16
+ // https://github.com/swagger-api/swagger-codegen/issues/12358
+ genSwaggerCodegen = "* generated by: swagger codegen "
)
-var _ Processor = &AutogeneratedExclude{}
+var _ Processor = (*AutogeneratedExclude)(nil)
type fileSummary struct {
generated bool
@@ -27,34 +42,37 @@ type fileSummary struct {
type AutogeneratedExclude struct {
debugf logutils.DebugFunc
- strict bool
+ mode string
strictPattern *regexp.Regexp
fileSummaryCache map[string]*fileSummary
}
-func NewAutogeneratedExclude(strict bool) *AutogeneratedExclude {
+func NewAutogeneratedExclude(mode string) *AutogeneratedExclude {
return &AutogeneratedExclude{
debugf: logutils.Debug(logutils.DebugKeyAutogenExclude),
- strict: strict,
+ mode: mode,
strictPattern: regexp.MustCompile(`^// Code generated .* DO NOT EDIT\.$`),
fileSummaryCache: map[string]*fileSummary{},
}
}
-func (p *AutogeneratedExclude) Name() string {
+func (*AutogeneratedExclude) Name() string {
return "autogenerated_exclude"
}
func (p *AutogeneratedExclude) Process(issues []result.Issue) ([]result.Issue, error) {
+ if p.mode == AutogeneratedModeDisable {
+ return issues, nil
+ }
+
return filterIssuesErr(issues, p.shouldPassIssue)
}
-func (p *AutogeneratedExclude) Finish() {}
+func (*AutogeneratedExclude) Finish() {}
func (p *AutogeneratedExclude) shouldPassIssue(issue *result.Issue) (bool, error) {
- if issue.FromLinter == "typecheck" {
- // don't hide typechecking errors in generated files: users expect to see why the project isn't compiling
+ if filepath.Base(issue.FilePath()) == "go.mod" {
return true, nil
}
@@ -67,7 +85,7 @@ func (p *AutogeneratedExclude) shouldPassIssue(issue *result.Issue) (bool, error
fs = &fileSummary{}
p.fileSummaryCache[issue.FilePath()] = fs
- if p.strict {
+ if p.mode == AutogeneratedModeStrict {
var err error
fs.generated, err = p.isGeneratedFileStrict(issue.FilePath())
if err != nil {
@@ -92,7 +110,7 @@ func (p *AutogeneratedExclude) shouldPassIssue(issue *result.Issue) (bool, error
// The function uses a bit laxer rules than isGeneratedFileStrict to match more generated code.
// See https://github.com/golangci/golangci-lint/issues/48 and https://github.com/golangci/golangci-lint/issues/72.
func (p *AutogeneratedExclude) isGeneratedFileLax(doc string) bool {
- markers := []string{genCodeGenerated, genDoNotEdit, genAutoFile}
+ markers := []string{genCodeGenerated, genDoNotEdit, genAutoFile, genSwaggerCodegen}
doc = strings.ToLower(doc)
@@ -157,7 +175,3 @@ func getComments(filePath string) (string, error) {
return strings.Join(docLines, "\n"), nil
}
-
-func isGoFile(name string) bool {
- return filepath.Ext(name) == ".go"
-}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/base_rule.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/base_rule.go
index 12333c898..d7a4f0ec4 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/base_rule.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/base_rule.go
@@ -10,14 +10,6 @@ import (
const caseInsensitivePrefix = "(?i)"
-type BaseRule struct {
- Text string
- Source string
- Path string
- PathExcept string
- Linters []string
-}
-
type baseRule struct {
text *regexp.Regexp
source *regexp.Regexp
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/cgo.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/cgo.go
index 1ad73c31a..0e659f0f3 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/cgo.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/cgo.go
@@ -9,49 +9,51 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
+var _ Processor = (*Cgo)(nil)
+
type Cgo struct {
goCacheDir string
}
-var _ Processor = Cgo{}
-
func NewCgo(goenv *goutil.Env) *Cgo {
return &Cgo{
goCacheDir: goenv.Get(goutil.EnvGoCache),
}
}
-func (p Cgo) Name() string {
+func (Cgo) Name() string {
return "cgo"
}
func (p Cgo) Process(issues []result.Issue) ([]result.Issue, error) {
- return filterIssuesErr(issues, func(issue *result.Issue) (bool, error) {
- // some linters (e.g. gosec, deadcode) return incorrect filepaths for cgo issues,
- // also cgo files have strange issues looking like false positives.
-
- // cache dir contains all preprocessed files including cgo files
-
- issueFilePath := issue.FilePath()
- if !filepath.IsAbs(issue.FilePath()) {
- absPath, err := filepath.Abs(issue.FilePath())
- if err != nil {
- return false, fmt.Errorf("failed to build abs path for %q: %w", issue.FilePath(), err)
- }
- issueFilePath = absPath
- }
+ return filterIssuesErr(issues, p.shouldPassIssue)
+}
- if p.goCacheDir != "" && strings.HasPrefix(issueFilePath, p.goCacheDir) {
- return false, nil
- }
+func (Cgo) Finish() {}
+
+func (p Cgo) shouldPassIssue(issue *result.Issue) (bool, error) {
+ // some linters (e.g. gosec, deadcode) return incorrect filepaths for cgo issues,
+ // also cgo files have strange issues looking like false positives.
+
+ // cache dir contains all preprocessed files including cgo files
- if filepath.Base(issue.FilePath()) == "_cgo_gotypes.go" {
- // skip cgo warning for go1.10
- return false, nil
+ issueFilePath := issue.FilePath()
+ if !filepath.IsAbs(issue.FilePath()) {
+ absPath, err := filepath.Abs(issue.FilePath())
+ if err != nil {
+ return false, fmt.Errorf("failed to build abs path for %q: %w", issue.FilePath(), err)
}
+ issueFilePath = absPath
+ }
- return true, nil
- })
-}
+ if p.goCacheDir != "" && strings.HasPrefix(issueFilePath, p.goCacheDir) {
+ return false, nil
+ }
-func (Cgo) Finish() {}
+ if filepath.Base(issue.FilePath()) == "_cgo_gotypes.go" {
+ // skip cgo warning for go1.10
+ return false, nil
+ }
+
+ return true, nil
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/diff.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/diff.go
index d607b0218..c602cdc65 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/diff.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/diff.go
@@ -9,11 +9,14 @@ import (
"github.com/golangci/revgrep"
+ "github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/result"
)
const envGolangciDiffProcessorPatch = "GOLANGCI_DIFF_PROCESSOR_PATCH"
+var _ Processor = (*Diff)(nil)
+
type Diff struct {
onlyNew bool
fromRev string
@@ -22,19 +25,17 @@ type Diff struct {
patch string
}
-var _ Processor = Diff{}
-
-func NewDiff(onlyNew bool, fromRev, patchFilePath string, wholeFiles bool) *Diff {
+func NewDiff(cfg *config.Issues) *Diff {
return &Diff{
- onlyNew: onlyNew,
- fromRev: fromRev,
- patchFilePath: patchFilePath,
- wholeFiles: wholeFiles,
+ onlyNew: cfg.Diff,
+ fromRev: cfg.DiffFromRevision,
+ patchFilePath: cfg.DiffPatchFilePath,
+ wholeFiles: cfg.WholeFiles,
patch: os.Getenv(envGolangciDiffProcessorPatch),
}
}
-func (p Diff) Name() string {
+func (Diff) Name() string {
return "diff"
}
@@ -64,6 +65,11 @@ func (p Diff) Process(issues []result.Issue) ([]result.Issue, error) {
}
return transformIssues(issues, func(issue *result.Issue) *result.Issue {
+ if issue.FromLinter == typeCheckName {
+ // Never hide typechecking errors.
+ return issue
+ }
+
hunkPos, isNew := c.IsNewIssue(issue)
if !isNew {
return nil
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclude.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclude.go
index 05a56ef96..543120450 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclude.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclude.go
@@ -1,12 +1,15 @@
package processors
import (
+ "fmt"
"regexp"
+ "strings"
+ "github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/result"
)
-var _ Processor = Exclude{}
+var _ Processor = (*Exclude)(nil)
type Exclude struct {
name string
@@ -14,22 +17,22 @@ type Exclude struct {
pattern *regexp.Regexp
}
-type ExcludeOptions struct {
- Pattern string
- CaseSensitive bool
-}
-
-func NewExclude(opts ExcludeOptions) *Exclude {
+func NewExclude(cfg *config.Issues) *Exclude {
p := &Exclude{name: "exclude"}
+ var pattern string
+ if len(cfg.ExcludePatterns) != 0 {
+ pattern = fmt.Sprintf("(%s)", strings.Join(cfg.ExcludePatterns, "|"))
+ }
+
prefix := caseInsensitivePrefix
- if opts.CaseSensitive {
+ if cfg.ExcludeCaseSensitive {
p.name = "exclude-case-sensitive"
prefix = ""
}
- if opts.Pattern != "" {
- p.pattern = regexp.MustCompile(prefix + opts.Pattern)
+ if pattern != "" {
+ p.pattern = regexp.MustCompile(prefix + pattern)
}
return p
@@ -49,4 +52,4 @@ func (p Exclude) Process(issues []result.Issue) ([]result.Issue, error) {
}), nil
}
-func (p Exclude) Finish() {}
+func (Exclude) Finish() {}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclude_rules.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclude_rules.go
index a20d56d05..bf255ae82 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclude_rules.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/exclude_rules.go
@@ -3,21 +3,18 @@ package processors
import (
"regexp"
+ "github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/fsutils"
"github.com/golangci/golangci-lint/pkg/logutils"
"github.com/golangci/golangci-lint/pkg/result"
)
-var _ Processor = ExcludeRules{}
+var _ Processor = (*ExcludeRules)(nil)
type excludeRule struct {
baseRule
}
-type ExcludeRule struct {
- BaseRule
-}
-
type ExcludeRules struct {
name string
@@ -27,12 +24,7 @@ type ExcludeRules struct {
rules []excludeRule
}
-type ExcludeRulesOptions struct {
- Rules []ExcludeRule
- CaseSensitive bool
-}
-
-func NewExcludeRules(log logutils.Log, files *fsutils.Files, opts ExcludeRulesOptions) *ExcludeRules {
+func NewExcludeRules(log logutils.Log, files *fsutils.Files, cfg *config.Issues) *ExcludeRules {
p := &ExcludeRules{
name: "exclude-rules",
files: files,
@@ -40,36 +32,50 @@ func NewExcludeRules(log logutils.Log, files *fsutils.Files, opts ExcludeRulesOp
}
prefix := caseInsensitivePrefix
- if opts.CaseSensitive {
+ if cfg.ExcludeCaseSensitive {
prefix = ""
p.name = "exclude-rules-case-sensitive"
}
- p.rules = createRules(opts.Rules, prefix)
+ excludeRules := cfg.ExcludeRules
+
+ if cfg.UseDefaultExcludes {
+ for _, r := range config.GetExcludePatterns(cfg.IncludeDefaultExcludes) {
+ excludeRules = append(excludeRules, config.ExcludeRule{
+ BaseRule: config.BaseRule{
+ Text: r.Pattern,
+ Linters: []string{r.Linter},
+ },
+ })
+ }
+ }
+
+ p.rules = createRules(excludeRules, prefix)
return p
}
+func (p ExcludeRules) Name() string { return p.name }
+
func (p ExcludeRules) Process(issues []result.Issue) ([]result.Issue, error) {
if len(p.rules) == 0 {
return issues, nil
}
+
return filterIssues(issues, func(issue *result.Issue) bool {
for _, rule := range p.rules {
- rule := rule
if rule.match(issue, p.files, p.log) {
return false
}
}
+
return true
}), nil
}
-func (p ExcludeRules) Name() string { return p.name }
-
func (ExcludeRules) Finish() {}
-func createRules(rules []ExcludeRule, prefix string) []excludeRule {
+func createRules(rules []config.ExcludeRule, prefix string) []excludeRule {
parsedRules := make([]excludeRule, 0, len(rules))
for _, rule := range rules {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/filename_unadjuster.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/filename_unadjuster.go
index adf82c823..6a1387c87 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/filename_unadjuster.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/filename_unadjuster.go
@@ -14,6 +14,8 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
+var _ Processor = (*FilenameUnadjuster)(nil)
+
type posMapper func(pos token.Position) token.Position
type adjustMap struct {
@@ -30,50 +32,6 @@ type FilenameUnadjuster struct {
loggedUnadjustments map[string]bool
}
-var _ Processor = &FilenameUnadjuster{}
-
-func processUnadjusterPkg(m *adjustMap, pkg *packages.Package, log logutils.Log) {
- fset := token.NewFileSet() // it's more memory efficient to not store all in one fset
-
- for _, filename := range pkg.CompiledGoFiles {
- // It's important to call func here to run GC
- processUnadjusterFile(filename, m, log, fset)
- }
-}
-
-func processUnadjusterFile(filename string, m *adjustMap, log logutils.Log, fset *token.FileSet) {
- syntax, err := parser.ParseFile(fset, filename, nil, parser.ParseComments)
- if err != nil {
- // Error will be reported by typecheck
- return
- }
-
- adjustedFilename := fset.PositionFor(syntax.Pos(), true).Filename
- if adjustedFilename == "" {
- return
- }
-
- unadjustedFilename := fset.PositionFor(syntax.Pos(), false).Filename
- if unadjustedFilename == "" || unadjustedFilename == adjustedFilename {
- return
- }
-
- if !strings.HasSuffix(unadjustedFilename, ".go") {
- return // file.go -> /caches/cgo-xxx
- }
-
- m.Lock()
- defer m.Unlock()
- m.m[adjustedFilename] = func(adjustedPos token.Position) token.Position {
- tokenFile := fset.File(syntax.Pos())
- if tokenFile == nil {
- log.Warnf("Failed to get token file for %s", adjustedFilename)
- return adjustedPos
- }
- return fset.PositionFor(tokenFile.Pos(adjustedPos.Offset), false)
- }
-}
-
func NewFilenameUnadjuster(pkgs []*packages.Package, log logutils.Log) *FilenameUnadjuster {
m := adjustMap{m: map[string]posMapper{}}
@@ -97,7 +55,7 @@ func NewFilenameUnadjuster(pkgs []*packages.Package, log logutils.Log) *Filename
}
}
-func (p *FilenameUnadjuster) Name() string {
+func (*FilenameUnadjuster) Name() string {
return "filename_unadjuster"
}
@@ -128,4 +86,48 @@ func (p *FilenameUnadjuster) Process(issues []result.Issue) ([]result.Issue, err
}), nil
}
-func (p *FilenameUnadjuster) Finish() {}
+func (*FilenameUnadjuster) Finish() {}
+
+func processUnadjusterPkg(m *adjustMap, pkg *packages.Package, log logutils.Log) {
+ fset := token.NewFileSet() // it's more memory efficient to not store all in one fset
+
+ for _, filename := range pkg.CompiledGoFiles {
+ // It's important to call func here to run GC
+ processUnadjusterFile(filename, m, log, fset)
+ }
+}
+
+func processUnadjusterFile(filename string, m *adjustMap, log logutils.Log, fset *token.FileSet) {
+ syntax, err := parser.ParseFile(fset, filename, nil, parser.ParseComments)
+ if err != nil {
+ // Error will be reported by typecheck
+ return
+ }
+
+ adjustedFilename := fset.PositionFor(syntax.Pos(), true).Filename
+ if adjustedFilename == "" {
+ return
+ }
+
+ unadjustedFilename := fset.PositionFor(syntax.Pos(), false).Filename
+ if unadjustedFilename == "" || unadjustedFilename == adjustedFilename {
+ return
+ }
+
+ if !strings.HasSuffix(unadjustedFilename, ".go") {
+ return // file.go -> /caches/cgo-xxx
+ }
+
+ m.Lock()
+ defer m.Unlock()
+
+ m.m[adjustedFilename] = func(adjustedPos token.Position) token.Position {
+ tokenFile := fset.File(syntax.Pos())
+ if tokenFile == nil {
+ log.Warnf("Failed to get token file for %s", adjustedFilename)
+ return adjustedPos
+ }
+
+ return fset.PositionFor(tokenFile.Pos(adjustedPos.Offset), false)
+ }
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/fixer.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/fixer.go
index 2879beb48..4915dc479 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/fixer.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/fixer.go
@@ -16,7 +16,7 @@ import (
"github.com/golangci/golangci-lint/pkg/timeutils"
)
-var _ Processor = Fixer{}
+var _ Processor = (*Fixer)(nil)
type Fixer struct {
cfg *config.Config
@@ -34,12 +34,12 @@ func NewFixer(cfg *config.Config, log logutils.Log, fileCache *fsutils.FileCache
}
}
-func (f Fixer) printStat() {
- f.sw.PrintStages()
+func (Fixer) Name() string {
+ return "fixer"
}
-func (f Fixer) Process(issues []result.Issue) ([]result.Issue, error) {
- if !f.cfg.Issues.NeedFix {
+func (p Fixer) Process(issues []result.Issue) ([]result.Issue, error) {
+ if !p.cfg.Issues.NeedFix {
return issues, nil
}
@@ -57,37 +57,36 @@ func (f Fixer) Process(issues []result.Issue) ([]result.Issue, error) {
for file, issuesToFix := range issuesToFixPerFile {
var err error
- f.sw.TrackStage("all", func() {
- err = f.fixIssuesInFile(file, issuesToFix)
+ p.sw.TrackStage("all", func() {
+ err = p.fixIssuesInFile(file, issuesToFix)
})
if err != nil {
- f.log.Errorf("Failed to fix issues in file %s: %s", file, err)
+ p.log.Errorf("Failed to fix issues in file %s: %s", file, err)
// show issues only if can't fix them
outIssues = append(outIssues, issuesToFix...)
}
}
- f.printStat()
- return outIssues, nil
-}
+ p.printStat()
-func (f Fixer) Name() string {
- return "fixer"
+ return outIssues, nil
}
-func (f Fixer) Finish() {}
+func (Fixer) Finish() {}
-func (f Fixer) fixIssuesInFile(filePath string, issues []result.Issue) error {
+func (p Fixer) fixIssuesInFile(filePath string, issues []result.Issue) error {
// TODO: don't read the whole file into memory: read line by line;
// can't just use bufio.scanner: it has a line length limit
- origFileData, err := f.fileCache.GetFileBytes(filePath)
+ origFileData, err := p.fileCache.GetFileBytes(filePath)
if err != nil {
return fmt.Errorf("failed to get file bytes for %s: %w", filePath, err)
}
+
origFileLines := bytes.Split(origFileData, []byte("\n"))
tmpFileName := filepath.Join(filepath.Dir(filePath), fmt.Sprintf(".%s.golangci_fix", filepath.Base(filePath)))
+
tmpOutFile, err := os.Create(tmpFileName)
if err != nil {
return fmt.Errorf("failed to make file %s: %w", tmpFileName, err)
@@ -102,20 +101,21 @@ func (f Fixer) fixIssuesInFile(filePath string, issues []result.Issue) error {
issues = issues[:0] // reuse the same memory
for line, lineIssues := range issuesPerLine {
- if mergedIssue := f.mergeLineIssues(line, lineIssues, origFileLines); mergedIssue != nil {
+ if mergedIssue := p.mergeLineIssues(line, lineIssues, origFileLines); mergedIssue != nil {
issues = append(issues, *mergedIssue)
}
}
- issues = f.findNotIntersectingIssues(issues)
+ issues = p.findNotIntersectingIssues(issues)
- if err = f.writeFixedFile(origFileLines, issues, tmpOutFile); err != nil {
+ if err = p.writeFixedFile(origFileLines, issues, tmpOutFile); err != nil {
tmpOutFile.Close()
_ = robustio.RemoveAll(tmpOutFile.Name())
return err
}
tmpOutFile.Close()
+
if err = robustio.Rename(tmpOutFile.Name(), filePath); err != nil {
_ = robustio.RemoveAll(tmpOutFile.Name())
return fmt.Errorf("failed to rename %s -> %s: %w", tmpOutFile.Name(), filePath, err)
@@ -124,7 +124,7 @@ func (f Fixer) fixIssuesInFile(filePath string, issues []result.Issue) error {
return nil
}
-func (f Fixer) mergeLineIssues(lineNum int, lineIssues []result.Issue, origFileLines [][]byte) *result.Issue {
+func (p Fixer) mergeLineIssues(lineNum int, lineIssues []result.Issue, origFileLines [][]byte) *result.Issue {
origLine := origFileLines[lineNum-1] // lineNum is 1-based
if len(lineIssues) == 1 && lineIssues[0].Replacement.Inline == nil {
@@ -136,27 +136,27 @@ func (f Fixer) mergeLineIssues(lineNum int, lineIssues []result.Issue, origFileL
li := &lineIssues[ind]
if li.LineRange != nil {
- f.log.Infof("Line %d has multiple issues but at least one of them is ranged: %#v", lineNum, lineIssues)
+ p.log.Infof("Line %d has multiple issues but at least one of them is ranged: %#v", lineNum, lineIssues)
return &lineIssues[0]
}
inline := li.Replacement.Inline
if inline == nil || len(li.Replacement.NewLines) != 0 || li.Replacement.NeedOnlyDelete {
- f.log.Infof("Line %d has multiple issues but at least one of them isn't inline: %#v", lineNum, lineIssues)
+ p.log.Infof("Line %d has multiple issues but at least one of them isn't inline: %#v", lineNum, lineIssues)
return li
}
if inline.StartCol < 0 || inline.Length <= 0 || inline.StartCol+inline.Length > len(origLine) {
- f.log.Warnf("Line %d (%q) has invalid inline fix: %#v, %#v", lineNum, origLine, li, inline)
+ p.log.Warnf("Line %d (%q) has invalid inline fix: %#v, %#v", lineNum, origLine, li, inline)
return nil
}
}
- return f.applyInlineFixes(lineIssues, origLine, lineNum)
+ return p.applyInlineFixes(lineIssues, origLine, lineNum)
}
-func (f Fixer) applyInlineFixes(lineIssues []result.Issue, origLine []byte, lineNum int) *result.Issue {
+func (p Fixer) applyInlineFixes(lineIssues []result.Issue, origLine []byte, lineNum int) *result.Issue {
sort.Slice(lineIssues, func(i, j int) bool {
return lineIssues[i].Replacement.Inline.StartCol < lineIssues[j].Replacement.Inline.StartCol
})
@@ -171,7 +171,7 @@ func (f Fixer) applyInlineFixes(lineIssues []result.Issue, origLine []byte, line
for i := range lineIssues {
fix := lineIssues[i].Replacement.Inline
if fix.StartCol < curOrigLinePos {
- f.log.Warnf("Line %d has multiple intersecting issues: %#v", lineNum, lineIssues)
+ p.log.Warnf("Line %d has multiple intersecting issues: %#v", lineNum, lineIssues)
return nil
}
@@ -192,7 +192,7 @@ func (f Fixer) applyInlineFixes(lineIssues []result.Issue, origLine []byte, line
return &mergedIssue
}
-func (f Fixer) findNotIntersectingIssues(issues []result.Issue) []result.Issue {
+func (p Fixer) findNotIntersectingIssues(issues []result.Issue) []result.Issue {
sort.SliceStable(issues, func(i, j int) bool {
a, b := issues[i], issues[j]
return a.Line() < b.Line()
@@ -204,10 +204,10 @@ func (f Fixer) findNotIntersectingIssues(issues []result.Issue) []result.Issue {
issue := &issues[i]
rng := issue.GetLineRange()
if rng.From <= currentEnd {
- f.log.Infof("Skip issue %#v: intersects with end %d", issue, currentEnd)
+ p.log.Infof("Skip issue %#v: intersects with end %d", issue, currentEnd)
continue // skip intersecting issue
}
- f.log.Infof("Fix issue %#v with range %v", issue, issue.GetLineRange())
+ p.log.Infof("Fix issue %#v with range %v", issue, issue.GetLineRange())
ret = append(ret, *issue)
currentEnd = rng.To
}
@@ -215,7 +215,7 @@ func (f Fixer) findNotIntersectingIssues(issues []result.Issue) []result.Issue {
return ret
}
-func (f Fixer) writeFixedFile(origFileLines [][]byte, issues []result.Issue, tmpOutFile *os.File) error {
+func (p Fixer) writeFixedFile(origFileLines [][]byte, issues []result.Issue, tmpOutFile *os.File) error {
// issues aren't intersecting
nextIssueIndex := 0
@@ -234,7 +234,7 @@ func (f Fixer) writeFixedFile(origFileLines [][]byte, issues []result.Issue, tmp
rng := nextIssue.GetLineRange()
if rng.From > rng.To {
// Maybe better decision is to skip such issues, re-evaluate if regressed.
- f.log.Warnf("[fixer]: issue line range is probably invalid, fix can be incorrect (from=%d, to=%d, linter=%s)",
+ p.log.Warnf("[fixer]: issue line range is probably invalid, fix can be incorrect (from=%d, to=%d, linter=%s)",
rng.From, rng.To, nextIssue.FromLinter,
)
}
@@ -255,3 +255,7 @@ func (f Fixer) writeFixedFile(origFileLines [][]byte, issues []result.Issue, tmp
return nil
}
+
+func (p Fixer) printStat() {
+ p.sw.PrintStages()
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/identifier_marker.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/identifier_marker.go
index 1975f6d08..876fd3bd3 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/identifier_marker.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/identifier_marker.go
@@ -6,6 +6,8 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
+var _ Processor = (*IdentifierMarker)(nil)
+
type replacePattern struct {
re string
repl string
@@ -126,16 +128,22 @@ func NewIdentifierMarker() *IdentifierMarker {
}
}
-func (im IdentifierMarker) Process(issues []result.Issue) ([]result.Issue, error) {
+func (IdentifierMarker) Name() string {
+ return "identifier_marker"
+}
+
+func (p IdentifierMarker) Process(issues []result.Issue) ([]result.Issue, error) {
return transformIssues(issues, func(issue *result.Issue) *result.Issue {
newIssue := *issue
- newIssue.Text = im.markIdentifiers(newIssue.Text)
+ newIssue.Text = p.markIdentifiers(newIssue.Text)
return &newIssue
}), nil
}
-func (im IdentifierMarker) markIdentifiers(s string) string {
- for _, rr := range im.replaceRegexps {
+func (IdentifierMarker) Finish() {}
+
+func (p IdentifierMarker) markIdentifiers(s string) string {
+ for _, rr := range p.replaceRegexps {
rs := rr.re.ReplaceAllString(s, rr.repl)
if rs != s {
return rs
@@ -144,8 +152,3 @@ func (im IdentifierMarker) markIdentifiers(s string) string {
return s
}
-
-func (im IdentifierMarker) Name() string {
- return "identifier_marker"
-}
-func (im IdentifierMarker) Finish() {}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/invalid_issue.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/invalid_issue.go
index 3bb0eb639..3f6cfc540 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/invalid_issue.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/invalid_issue.go
@@ -7,7 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-var _ Processor = InvalidIssue{}
+var _ Processor = (*InvalidIssue)(nil)
type InvalidIssue struct {
log logutils.Log
@@ -17,21 +17,25 @@ func NewInvalidIssue(log logutils.Log) *InvalidIssue {
return &InvalidIssue{log: log}
}
-func (p InvalidIssue) Process(issues []result.Issue) ([]result.Issue, error) {
- return filterIssuesErr(issues, p.shouldPassIssue)
-}
-
-func (p InvalidIssue) Name() string {
+func (InvalidIssue) Name() string {
return "invalid_issue"
}
-func (p InvalidIssue) Finish() {}
+func (p InvalidIssue) Process(issues []result.Issue) ([]result.Issue, error) {
+ tcIssues := filterIssuesUnsafe(issues, func(issue *result.Issue) bool {
+ return issue.FromLinter == typeCheckName
+ })
-func (p InvalidIssue) shouldPassIssue(issue *result.Issue) (bool, error) {
- if issue.FromLinter == "typecheck" {
- return true, nil
+ if len(tcIssues) > 0 {
+ return tcIssues, nil
}
+ return filterIssuesErr(issues, p.shouldPassIssue)
+}
+
+func (InvalidIssue) Finish() {}
+
+func (p InvalidIssue) shouldPassIssue(issue *result.Issue) (bool, error) {
if issue.FilePath() == "" {
p.log.Warnf("no file path for the issue: probably a bug inside the linter %q: %#v", issue.FromLinter, issue)
@@ -50,3 +54,7 @@ func (p InvalidIssue) shouldPassIssue(issue *result.Issue) (bool, error) {
return true, nil
}
+
+func isGoFile(name string) bool {
+ return filepath.Ext(name) == ".go"
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/issues.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/issues.go
index a65b0c2b0..ab443b87d 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/issues.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/issues.go
@@ -9,6 +9,23 @@ import (
func filterIssues(issues []result.Issue, filter func(issue *result.Issue) bool) []result.Issue {
retIssues := make([]result.Issue, 0, len(issues))
for i := range issues {
+ if issues[i].FromLinter == typeCheckName {
+ // don't hide typechecking errors in generated files: users expect to see why the project isn't compiling
+ retIssues = append(retIssues, issues[i])
+ continue
+ }
+
+ if filter(&issues[i]) {
+ retIssues = append(retIssues, issues[i])
+ }
+ }
+
+ return retIssues
+}
+
+func filterIssuesUnsafe(issues []result.Issue, filter func(issue *result.Issue) bool) []result.Issue {
+ retIssues := make([]result.Issue, 0, len(issues))
+ for i := range issues {
if filter(&issues[i]) {
retIssues = append(retIssues, issues[i])
}
@@ -20,6 +37,12 @@ func filterIssues(issues []result.Issue, filter func(issue *result.Issue) bool)
func filterIssuesErr(issues []result.Issue, filter func(issue *result.Issue) (bool, error)) ([]result.Issue, error) {
retIssues := make([]result.Issue, 0, len(issues))
for i := range issues {
+ if issues[i].FromLinter == typeCheckName {
+ // don't hide typechecking errors in generated files: users expect to see why the project isn't compiling
+ retIssues = append(retIssues, issues[i])
+ continue
+ }
+
ok, err := filter(&issues[i])
if err != nil {
return nil, fmt.Errorf("can't filter issue %#v: %w", issues[i], err)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_from_linter.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_from_linter.go
index 65b04272b..0680c3f29 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_from_linter.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_from_linter.go
@@ -6,25 +6,25 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
+var _ Processor = (*MaxFromLinter)(nil)
+
type MaxFromLinter struct {
- lc linterToCountMap
- limit int
- log logutils.Log
- cfg *config.Config
+ linterCounter map[string]int
+ limit int
+ log logutils.Log
+ cfg *config.Config
}
-var _ Processor = &MaxFromLinter{}
-
func NewMaxFromLinter(limit int, log logutils.Log, cfg *config.Config) *MaxFromLinter {
return &MaxFromLinter{
- lc: linterToCountMap{},
- limit: limit,
- log: log,
- cfg: cfg,
+ linterCounter: map[string]int{},
+ limit: limit,
+ log: log,
+ cfg: cfg,
}
}
-func (p *MaxFromLinter) Name() string {
+func (*MaxFromLinter) Name() string {
return "max_from_linter"
}
@@ -33,19 +33,20 @@ func (p *MaxFromLinter) Process(issues []result.Issue) ([]result.Issue, error) {
return issues, nil
}
- return filterIssues(issues, func(issue *result.Issue) bool {
+ return filterIssuesUnsafe(issues, func(issue *result.Issue) bool {
if issue.Replacement != nil && p.cfg.Issues.NeedFix {
// we need to fix all issues at once => we need to return all of them
return true
}
- p.lc[issue.FromLinter]++ // always inc for stat
- return p.lc[issue.FromLinter] <= p.limit
+ p.linterCounter[issue.FromLinter]++ // always inc for stat
+
+ return p.linterCounter[issue.FromLinter] <= p.limit
}), nil
}
func (p *MaxFromLinter) Finish() {
- walkStringToIntMapSortedByValue(p.lc, func(linter string, count int) {
+ walkStringToIntMapSortedByValue(p.linterCounter, func(linter string, count int) {
if count > p.limit {
p.log.Infof("%d/%d issues from linter %s were hidden, use --max-issues-per-linter",
count-p.limit, count, linter)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_per_file_from_linter.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_per_file_from_linter.go
index 372f40cc5..a39c98473 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_per_file_from_linter.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_per_file_from_linter.go
@@ -5,18 +5,13 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-type (
- linterToCountMap map[string]int
- fileToLinterToCountMap map[string]linterToCountMap
-)
+var _ Processor = (*MaxPerFileFromLinter)(nil)
type MaxPerFileFromLinter struct {
- flc fileToLinterToCountMap
+ fileLinterCounter fileLinterCounter
maxPerFileFromLinterConfig map[string]int
}
-var _ Processor = &MaxPerFileFromLinter{}
-
func NewMaxPerFileFromLinter(cfg *config.Config) *MaxPerFileFromLinter {
maxPerFileFromLinterConfig := map[string]int{}
@@ -28,34 +23,51 @@ func NewMaxPerFileFromLinter(cfg *config.Config) *MaxPerFileFromLinter {
}
return &MaxPerFileFromLinter{
- flc: fileToLinterToCountMap{},
+ fileLinterCounter: fileLinterCounter{},
maxPerFileFromLinterConfig: maxPerFileFromLinterConfig,
}
}
-func (p *MaxPerFileFromLinter) Name() string {
+func (*MaxPerFileFromLinter) Name() string {
return "max_per_file_from_linter"
}
func (p *MaxPerFileFromLinter) Process(issues []result.Issue) ([]result.Issue, error) {
- return filterIssues(issues, func(issue *result.Issue) bool {
+ return filterIssuesUnsafe(issues, func(issue *result.Issue) bool {
limit := p.maxPerFileFromLinterConfig[issue.FromLinter]
if limit == 0 {
return true
}
- lm := p.flc[issue.FilePath()]
- if lm == nil {
- p.flc[issue.FilePath()] = linterToCountMap{}
- }
- count := p.flc[issue.FilePath()][issue.FromLinter]
- if count >= limit {
+ if p.fileLinterCounter.GetCount(issue) >= limit {
return false
}
- p.flc[issue.FilePath()][issue.FromLinter]++
+ p.fileLinterCounter.Increment(issue)
+
return true
}), nil
}
-func (p *MaxPerFileFromLinter) Finish() {}
+func (*MaxPerFileFromLinter) Finish() {}
+
+type fileLinterCounter map[string]map[string]int
+
+func (f fileLinterCounter) GetCount(issue *result.Issue) int {
+ return f.getCounter(issue)[issue.FromLinter]
+}
+
+func (f fileLinterCounter) Increment(issue *result.Issue) {
+ f.getCounter(issue)[issue.FromLinter]++
+}
+
+func (f fileLinterCounter) getCounter(issue *result.Issue) map[string]int {
+ lc := f[issue.FilePath()]
+
+ if lc == nil {
+ lc = map[string]int{}
+ f[issue.FilePath()] = lc
+ }
+
+ return lc
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_same_issues.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_same_issues.go
index a3ceeb595..1647cace0 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_same_issues.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/max_same_issues.go
@@ -8,27 +8,25 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-type textToCountMap map[string]int
+var _ Processor = (*MaxSameIssues)(nil)
type MaxSameIssues struct {
- tc textToCountMap
- limit int
- log logutils.Log
- cfg *config.Config
+ textCounter map[string]int
+ limit int
+ log logutils.Log
+ cfg *config.Config
}
-var _ Processor = &MaxSameIssues{}
-
func NewMaxSameIssues(limit int, log logutils.Log, cfg *config.Config) *MaxSameIssues {
return &MaxSameIssues{
- tc: textToCountMap{},
- limit: limit,
- log: log,
- cfg: cfg,
+ textCounter: map[string]int{},
+ limit: limit,
+ log: log,
+ cfg: cfg,
}
}
-func (p *MaxSameIssues) Name() string {
+func (*MaxSameIssues) Name() string {
return "max_same_issues"
}
@@ -37,19 +35,19 @@ func (p *MaxSameIssues) Process(issues []result.Issue) ([]result.Issue, error) {
return issues, nil
}
- return filterIssues(issues, func(issue *result.Issue) bool {
+ return filterIssuesUnsafe(issues, func(issue *result.Issue) bool {
if issue.Replacement != nil && p.cfg.Issues.NeedFix {
// we need to fix all issues at once => we need to return all of them
return true
}
- p.tc[issue.Text]++ // always inc for stat
- return p.tc[issue.Text] <= p.limit
+ p.textCounter[issue.Text]++ // always inc for stat
+ return p.textCounter[issue.Text] <= p.limit
}), nil
}
func (p *MaxSameIssues) Finish() {
- walkStringToIntMapSortedByValue(p.tc, func(text string, count int) {
+ walkStringToIntMapSortedByValue(p.textCounter, func(text string, count int) {
if count > p.limit {
p.log.Infof("%d/%d issues with text %q were hidden, use --max-same-issues",
count-p.limit, count, text)
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/nolint.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/nolint.go
index df8e81495..7794bd3ec 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/nolint.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/nolint.go
@@ -10,17 +10,16 @@ import (
"golang.org/x/exp/maps"
- "github.com/golangci/golangci-lint/pkg/golinters"
+ "github.com/golangci/golangci-lint/pkg/golinters/nolintlint"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
"github.com/golangci/golangci-lint/pkg/logutils"
"github.com/golangci/golangci-lint/pkg/result"
)
-var (
- nolintDebugf = logutils.Debug(logutils.DebugKeyNolint)
- nolintRe = regexp.MustCompile(`^nolint( |:|$)`)
-)
+var _ Processor = (*Nolint)(nil)
+
+var nolintDebugf = logutils.Debug(logutils.DebugKeyNolint)
type ignoredRange struct {
linters []string
@@ -36,7 +35,7 @@ func (i *ignoredRange) doesMatch(issue *result.Issue) bool {
}
// only allow selective nolinting of nolintlint
- nolintFoundForLinter := len(i.linters) == 0 && issue.FromLinter != golinters.NoLintLintName
+ nolintFoundForLinter := len(i.linters) == 0 && issue.FromLinter != nolintlint.LinterName
for _, linterName := range i.linters {
if linterName == issue.FromLinter {
@@ -51,7 +50,7 @@ func (i *ignoredRange) doesMatch(issue *result.Issue) bool {
// handle possible unused nolint directives
// nolintlint generates potential issues for every nolint directive, and they are filtered out here
- if issue.FromLinter == golinters.NoLintLintName && issue.ExpectNoLint {
+ if issue.FromLinter == nolintlint.LinterName && issue.ExpectNoLint {
if issue.ExpectedNoLintLinter != "" {
return i.matchedIssueFromLinter[issue.ExpectedNoLintLinter]
}
@@ -65,30 +64,29 @@ type fileData struct {
ignoredRanges []ignoredRange
}
-type filesCache map[string]*fileData
-
type Nolint struct {
- cache filesCache
+ fileCache map[string]*fileData
dbManager *lintersdb.Manager
enabledLinters map[string]*linter.Config
log logutils.Log
unknownLintersSet map[string]bool
+
+ pattern *regexp.Regexp
}
func NewNolint(log logutils.Log, dbManager *lintersdb.Manager, enabledLinters map[string]*linter.Config) *Nolint {
return &Nolint{
- cache: filesCache{},
+ fileCache: map[string]*fileData{},
dbManager: dbManager,
enabledLinters: enabledLinters,
log: log,
unknownLintersSet: map[string]bool{},
+ pattern: regexp.MustCompile(`^nolint( |:|$)`),
}
}
-var _ Processor = &Nolint{}
-
-func (p *Nolint) Name() string {
+func (*Nolint) Name() string {
return "nolint"
}
@@ -98,14 +96,60 @@ func (p *Nolint) Process(issues []result.Issue) ([]result.Issue, error) {
return filterIssuesErr(issues, p.shouldPassIssue)
}
+func (p *Nolint) Finish() {
+ if len(p.unknownLintersSet) == 0 {
+ return
+ }
+
+ unknownLinters := maps.Keys(p.unknownLintersSet)
+ sort.Strings(unknownLinters)
+
+ p.log.Warnf("Found unknown linters in //nolint directives: %s", strings.Join(unknownLinters, ", "))
+}
+
+func (p *Nolint) shouldPassIssue(issue *result.Issue) (bool, error) {
+ nolintDebugf("got issue: %v", *issue)
+
+ // don't expect disabled linters to cover their nolint statements
+ if issue.FromLinter == nolintlint.LinterName && issue.ExpectNoLint && issue.ExpectedNoLintLinter != "" {
+ nolintDebugf("enabled linters: %v", p.enabledLinters)
+
+ if p.enabledLinters[issue.ExpectedNoLintLinter] == nil {
+ return false, nil
+ }
+
+ nolintDebugf("checking that lint issue was used for %s: %v", issue.ExpectedNoLintLinter, issue)
+ }
+
+ fd := p.getOrCreateFileData(issue)
+
+ for _, ir := range fd.ignoredRanges {
+ if !ir.doesMatch(issue) {
+ continue
+ }
+
+ nolintDebugf("found ignored range for issue %v: %v", issue, ir)
+
+ ir.matchedIssueFromLinter[issue.FromLinter] = true
+
+ if ir.originalRange != nil {
+ ir.originalRange.matchedIssueFromLinter[issue.FromLinter] = true
+ }
+
+ return false, nil
+ }
+
+ return true, nil
+}
+
func (p *Nolint) getOrCreateFileData(issue *result.Issue) *fileData {
- fd := p.cache[issue.FilePath()]
+ fd := p.fileCache[issue.FilePath()]
if fd != nil {
return fd
}
fd = &fileData{}
- p.cache[issue.FilePath()] = fd
+ p.fileCache[issue.FilePath()] = fd
// TODO: migrate this parsing to go/analysis facts
// or cache them somehow per file.
@@ -147,76 +191,6 @@ func (p *Nolint) buildIgnoredRangesForFile(f *ast.File, fset *token.FileSet, fil
return allRanges
}
-func (p *Nolint) shouldPassIssue(issue *result.Issue) (bool, error) {
- nolintDebugf("got issue: %v", *issue)
- if issue.FromLinter == golinters.NoLintLintName && issue.ExpectNoLint && issue.ExpectedNoLintLinter != "" {
- // don't expect disabled linters to cover their nolint statements
- nolintDebugf("enabled linters: %v", p.enabledLinters)
- if p.enabledLinters[issue.ExpectedNoLintLinter] == nil {
- return false, nil
- }
- nolintDebugf("checking that lint issue was used for %s: %v", issue.ExpectedNoLintLinter, issue)
- }
-
- fd := p.getOrCreateFileData(issue)
-
- for _, ir := range fd.ignoredRanges {
- if ir.doesMatch(issue) {
- nolintDebugf("found ignored range for issue %v: %v", issue, ir)
- ir.matchedIssueFromLinter[issue.FromLinter] = true
- if ir.originalRange != nil {
- ir.originalRange.matchedIssueFromLinter[issue.FromLinter] = true
- }
- return false, nil
- }
- }
-
- return true, nil
-}
-
-type rangeExpander struct {
- fset *token.FileSet
- inlineRanges []ignoredRange
- expandedRanges []ignoredRange
-}
-
-func (e *rangeExpander) Visit(node ast.Node) ast.Visitor {
- if node == nil {
- return e
- }
-
- nodeStartPos := e.fset.Position(node.Pos())
- nodeStartLine := nodeStartPos.Line
- nodeEndLine := e.fset.Position(node.End()).Line
-
- var foundRange *ignoredRange
- for _, r := range e.inlineRanges {
- if r.To == nodeStartLine-1 && nodeStartPos.Column == r.col {
- r := r
- foundRange = &r
- break
- }
- }
- if foundRange == nil {
- return e
- }
-
- expandedRange := *foundRange
- // store the original unexpanded range for matching nolintlint issues
- if expandedRange.originalRange == nil {
- expandedRange.originalRange = foundRange
- }
- if expandedRange.To < nodeEndLine {
- expandedRange.To = nodeEndLine
- }
-
- nolintDebugf("found range is %v for node %#v [%d;%d], expanded range is %v",
- *foundRange, node, nodeStartLine, nodeEndLine, expandedRange)
- e.expandedRanges = append(e.expandedRanges, expandedRange)
-
- return e
-}
-
func (p *Nolint) extractFileCommentsInlineRanges(fset *token.FileSet, comments ...*ast.CommentGroup) []ignoredRange {
var ret []ignoredRange
for _, g := range comments {
@@ -233,7 +207,7 @@ func (p *Nolint) extractFileCommentsInlineRanges(fset *token.FileSet, comments .
func (p *Nolint) extractInlineRangeFromComment(text string, g ast.Node, fset *token.FileSet) *ignoredRange {
text = strings.TrimLeft(text, "/ ")
- if !nolintRe.MatchString(text) {
+ if !p.pattern.MatchString(text) {
return nil
}
@@ -282,15 +256,47 @@ func (p *Nolint) extractInlineRangeFromComment(text string, g ast.Node, fset *to
return buildRange(linters)
}
-func (p *Nolint) Finish() {
- if len(p.unknownLintersSet) == 0 {
- return
+type rangeExpander struct {
+ fset *token.FileSet
+ inlineRanges []ignoredRange
+ expandedRanges []ignoredRange
+}
+
+func (e *rangeExpander) Visit(node ast.Node) ast.Visitor {
+ if node == nil {
+ return e
}
- unknownLinters := maps.Keys(p.unknownLintersSet)
- sort.Strings(unknownLinters)
+ nodeStartPos := e.fset.Position(node.Pos())
+ nodeStartLine := nodeStartPos.Line
+ nodeEndLine := e.fset.Position(node.End()).Line
- p.log.Warnf("Found unknown linters in //nolint directives: %s", strings.Join(unknownLinters, ", "))
+ var foundRange *ignoredRange
+ for _, r := range e.inlineRanges {
+ if r.To == nodeStartLine-1 && nodeStartPos.Column == r.col {
+ r := r
+ foundRange = &r
+ break
+ }
+ }
+ if foundRange == nil {
+ return e
+ }
+
+ expandedRange := *foundRange
+ // store the original unexpanded range for matching nolintlint issues
+ if expandedRange.originalRange == nil {
+ expandedRange.originalRange = foundRange
+ }
+ if expandedRange.To < nodeEndLine {
+ expandedRange.To = nodeEndLine
+ }
+
+ nolintDebugf("found range is %v for node %#v [%d;%d], expanded range is %v",
+ *foundRange, node, nodeStartLine, nodeEndLine, expandedRange)
+ e.expandedRanges = append(e.expandedRanges, expandedRange)
+
+ return e
}
// put nolintlint last
@@ -301,7 +307,7 @@ func (issues sortWithNolintlintLast) Len() int {
}
func (issues sortWithNolintlintLast) Less(i, j int) bool {
- return issues[i].FromLinter != golinters.NoLintLintName && issues[j].FromLinter == golinters.NoLintLintName
+ return issues[i].FromLinter != nolintlint.LinterName && issues[j].FromLinter == nolintlint.LinterName
}
func (issues sortWithNolintlintLast) Swap(i, j int) {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prefixer.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prefixer.go
index f6b885011..8036e3fd6 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prefixer.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prefixer.go
@@ -5,13 +5,13 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
+var _ Processor = (*PathPrefixer)(nil)
+
// PathPrefixer adds a customizable prefix to every output path
type PathPrefixer struct {
prefix string
}
-var _ Processor = new(PathPrefixer)
-
// NewPathPrefixer returns a new path prefixer for the provided string
func NewPathPrefixer(prefix string) *PathPrefixer {
return &PathPrefixer{prefix: prefix}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prettifier.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prettifier.go
index 79cdd7473..c5c27357c 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prettifier.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_prettifier.go
@@ -1,34 +1,26 @@
package processors
import (
- "fmt"
"path/filepath"
"github.com/golangci/golangci-lint/pkg/fsutils"
"github.com/golangci/golangci-lint/pkg/result"
)
+var _ Processor = (*PathPrettifier)(nil)
+
type PathPrettifier struct {
- root string
}
-var _ Processor = PathPrettifier{}
-
func NewPathPrettifier() *PathPrettifier {
- root, err := fsutils.Getwd()
- if err != nil {
- panic(fmt.Sprintf("Can't get working dir: %s", err))
- }
- return &PathPrettifier{
- root: root,
- }
+ return &PathPrettifier{}
}
-func (p PathPrettifier) Name() string {
+func (PathPrettifier) Name() string {
return "path_prettifier"
}
-func (p PathPrettifier) Process(issues []result.Issue) ([]result.Issue, error) {
+func (PathPrettifier) Process(issues []result.Issue) ([]result.Issue, error) {
return transformIssues(issues, func(issue *result.Issue) *result.Issue {
if !filepath.IsAbs(issue.FilePath()) {
return issue
@@ -45,4 +37,4 @@ func (p PathPrettifier) Process(issues []result.Issue) ([]result.Issue, error) {
}), nil
}
-func (p PathPrettifier) Finish() {}
+func (PathPrettifier) Finish() {}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_shortener.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_shortener.go
index d7fa5ea91..b161e86c2 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_shortener.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/path_shortener.go
@@ -8,23 +8,22 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
+var _ Processor = (*PathShortener)(nil)
+
type PathShortener struct {
wd string
}
-var _ Processor = PathShortener{}
-
func NewPathShortener() *PathShortener {
wd, err := fsutils.Getwd()
if err != nil {
panic(fmt.Sprintf("Can't get working dir: %s", err))
}
- return &PathShortener{
- wd: wd,
- }
+
+ return &PathShortener{wd: wd}
}
-func (p PathShortener) Name() string {
+func (PathShortener) Name() string {
return "path_shortener"
}
@@ -37,4 +36,4 @@ func (p PathShortener) Process(issues []result.Issue) ([]result.Issue, error) {
}), nil
}
-func (p PathShortener) Finish() {}
+func (PathShortener) Finish() {}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/processor.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/processor.go
index 1a7a40434..13e63d604 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/processor.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/processor.go
@@ -4,6 +4,8 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
+const typeCheckName = "typecheck"
+
type Processor interface {
Process(issues []result.Issue) ([]result.Issue, error)
Name() string
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/severity.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/severity.go
index 2568ba45c..93a26586d 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/severity.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/severity.go
@@ -3,6 +3,7 @@ package processors
import (
"regexp"
+ "github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/fsutils"
"github.com/golangci/golangci-lint/pkg/logutils"
"github.com/golangci/golangci-lint/pkg/result"
@@ -10,24 +11,13 @@ import (
const severityFromLinter = "@linter"
-var _ Processor = &Severity{}
+var _ Processor = (*Severity)(nil)
type severityRule struct {
baseRule
severity string
}
-type SeverityRule struct {
- BaseRule
- Severity string
-}
-
-type SeverityOptions struct {
- Default string
- Rules []SeverityRule
- CaseSensitive bool
-}
-
type Severity struct {
name string
@@ -39,25 +29,27 @@ type Severity struct {
rules []severityRule
}
-func NewSeverity(log logutils.Log, files *fsutils.Files, opts SeverityOptions) *Severity {
+func NewSeverity(log logutils.Log, files *fsutils.Files, cfg *config.Severity) *Severity {
p := &Severity{
name: "severity-rules",
files: files,
log: log,
- defaultSeverity: opts.Default,
+ defaultSeverity: cfg.Default,
}
prefix := caseInsensitivePrefix
- if opts.CaseSensitive {
+ if cfg.CaseSensitive {
prefix = ""
p.name = "severity-rules-case-sensitive"
}
- p.rules = createSeverityRules(opts.Rules, prefix)
+ p.rules = createSeverityRules(cfg.Rules, prefix)
return p
}
+func (p *Severity) Name() string { return p.name }
+
func (p *Severity) Process(issues []result.Issue) ([]result.Issue, error) {
if len(p.rules) == 0 && p.defaultSeverity == "" {
return issues, nil
@@ -66,6 +58,8 @@ func (p *Severity) Process(issues []result.Issue) ([]result.Issue, error) {
return transformIssues(issues, p.transform), nil
}
+func (*Severity) Finish() {}
+
func (p *Severity) transform(issue *result.Issue) *result.Issue {
for _, rule := range p.rules {
if rule.match(issue, p.files, p.log) {
@@ -89,11 +83,7 @@ func (p *Severity) transform(issue *result.Issue) *result.Issue {
return issue
}
-func (p *Severity) Name() string { return p.name }
-
-func (*Severity) Finish() {}
-
-func createSeverityRules(rules []SeverityRule, prefix string) []severityRule {
+func createSeverityRules(rules []config.SeverityRule, prefix string) []severityRule {
parsedRules := make([]severityRule, 0, len(rules))
for _, rule := range rules {
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_dirs.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_dirs.go
index 7c4e0b9c0..39dbfd1d3 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_dirs.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_dirs.go
@@ -4,13 +4,23 @@ import (
"fmt"
"path/filepath"
"regexp"
- "strings"
"github.com/golangci/golangci-lint/pkg/fsutils"
"github.com/golangci/golangci-lint/pkg/logutils"
"github.com/golangci/golangci-lint/pkg/result"
)
+var _ Processor = (*SkipDirs)(nil)
+
+var StdExcludeDirRegexps = []string{
+ normalizePathRegex("vendor"),
+ normalizePathRegex("third_party"),
+ normalizePathRegex("testdata"),
+ normalizePathRegex("examples"),
+ normalizePathRegex("Godeps"),
+ normalizePathRegex("builtin"),
+}
+
type skipStat struct {
pattern string
count int
@@ -25,11 +35,7 @@ type SkipDirs struct {
pathPrefix string
}
-var _ Processor = (*SkipDirs)(nil)
-
-const goFileSuffix = ".go"
-
-func NewSkipDirs(patterns []string, log logutils.Log, runArgs []string, pathPrefix string) (*SkipDirs, error) {
+func NewSkipDirs(log logutils.Log, patterns, args []string, pathPrefix string) (*SkipDirs, error) {
var patternsRe []*regexp.Regexp
for _, p := range patterns {
p = fsutils.NormalizePathInRegex(p)
@@ -40,21 +46,9 @@ func NewSkipDirs(patterns []string, log logutils.Log, runArgs []string, pathPref
patternsRe = append(patternsRe, patternRe)
}
- if len(runArgs) == 0 {
- runArgs = append(runArgs, "./...")
- }
- var absArgsDirs []string
- for _, arg := range runArgs {
- base := filepath.Base(arg)
- if base == "..." || strings.HasSuffix(base, goFileSuffix) {
- arg = filepath.Dir(arg)
- }
-
- absArg, err := filepath.Abs(arg)
- if err != nil {
- return nil, fmt.Errorf("failed to abs-ify arg %q: %w", arg, err)
- }
- absArgsDirs = append(absArgsDirs, absArg)
+ absArgsDirs, err := absDirs(args)
+ if err != nil {
+ return nil, err
}
return &SkipDirs{
@@ -67,7 +61,7 @@ func NewSkipDirs(patterns []string, log logutils.Log, runArgs []string, pathPref
}, nil
}
-func (p *SkipDirs) Name() string {
+func (*SkipDirs) Name() string {
return "skip_dirs"
}
@@ -79,6 +73,12 @@ func (p *SkipDirs) Process(issues []result.Issue) ([]result.Issue, error) {
return filterIssues(issues, p.shouldPassIssue), nil
}
+func (p *SkipDirs) Finish() {
+ for dir, stat := range p.skippedDirs {
+ p.log.Infof("Skipped %d issues from dir %s by pattern %s", stat.count, dir, stat.pattern)
+ }
+}
+
func (p *SkipDirs) shouldPassIssue(issue *result.Issue) bool {
if filepath.IsAbs(issue.FilePath()) {
if isGoFile(issue.FilePath()) {
@@ -139,8 +139,34 @@ func (p *SkipDirs) shouldPassIssueDirs(issueRelDir, issueAbsDir string) bool {
return true
}
-func (p *SkipDirs) Finish() {
- for dir, stat := range p.skippedDirs {
- p.log.Infof("Skipped %d issues from dir %s by pattern %s", stat.count, dir, stat.pattern)
+func absDirs(args []string) ([]string, error) {
+ if len(args) == 0 {
+ args = append(args, "./...")
}
+
+ var absArgsDirs []string
+ for _, arg := range args {
+ base := filepath.Base(arg)
+ if base == "..." || isGoFile(base) {
+ arg = filepath.Dir(arg)
+ }
+
+ absArg, err := filepath.Abs(arg)
+ if err != nil {
+ return nil, fmt.Errorf("failed to abs-ify arg %q: %w", arg, err)
+ }
+
+ absArgsDirs = append(absArgsDirs, absArg)
+ }
+
+ return absArgsDirs, nil
+}
+
+func normalizePathRegex(e string) string {
+ return createPathRegex(e, filepath.Separator)
+}
+
+func createPathRegex(e string, sep rune) string {
+ escapedSep := regexp.QuoteMeta(string(sep)) // needed for windows sep '\\'
+ return fmt.Sprintf(`(^|%[1]s)%[2]s($|%[1]s)`, escapedSep, e)
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_files.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_files.go
index f1873a376..3b17a9f32 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_files.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/skip_files.go
@@ -8,21 +8,23 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
+var _ Processor = (*SkipFiles)(nil)
+
type SkipFiles struct {
patterns []*regexp.Regexp
pathPrefix string
}
-var _ Processor = (*SkipFiles)(nil)
-
func NewSkipFiles(patterns []string, pathPrefix string) (*SkipFiles, error) {
var patternsRe []*regexp.Regexp
for _, p := range patterns {
p = fsutils.NormalizePathInRegex(p)
+
patternRe, err := regexp.Compile(p)
if err != nil {
return nil, fmt.Errorf("can't compile regexp %q: %w", p, err)
}
+
patternsRe = append(patternsRe, patternRe)
}
@@ -32,7 +34,7 @@ func NewSkipFiles(patterns []string, pathPrefix string) (*SkipFiles, error) {
}, nil
}
-func (p SkipFiles) Name() string {
+func (SkipFiles) Name() string {
return "skip_files"
}
@@ -43,6 +45,7 @@ func (p SkipFiles) Process(issues []result.Issue) ([]result.Issue, error) {
return filterIssues(issues, func(issue *result.Issue) bool {
path := fsutils.WithPathPrefix(p.pathPrefix, issue.FilePath())
+
for _, pattern := range p.patterns {
if pattern.MatchString(path) {
return false
@@ -53,4 +56,4 @@ func (p SkipFiles) Process(issues []result.Issue) ([]result.Issue, error) {
}), nil
}
-func (p SkipFiles) Finish() {}
+func (SkipFiles) Finish() {}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/sort_results.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/sort_results.go
index 8e4af57e6..4da73c72e 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/sort_results.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/sort_results.go
@@ -45,23 +45,26 @@ func NewSortResults(cfg *config.Config) *SortResults {
}
}
+func (SortResults) Name() string { return "sort_results" }
+
// Process is performing sorting of the result issues.
-func (sr SortResults) Process(issues []result.Issue) ([]result.Issue, error) {
- if !sr.cfg.SortResults {
+func (p SortResults) Process(issues []result.Issue) ([]result.Issue, error) {
+ if !p.cfg.SortResults {
return issues, nil
}
- if len(sr.cfg.SortOrder) == 0 {
- sr.cfg.SortOrder = []string{orderNameFile}
+ if len(p.cfg.SortOrder) == 0 {
+ p.cfg.SortOrder = []string{orderNameFile}
}
var cmps []*comparator
- for _, name := range sr.cfg.SortOrder {
- if c, ok := sr.cmps[name]; ok {
- cmps = append(cmps, c)
- } else {
+ for _, name := range p.cfg.SortOrder {
+ c, ok := p.cmps[name]
+ if !ok {
return nil, fmt.Errorf("unsupported sort-order name %q", name)
}
+
+ cmps = append(cmps, c)
}
cmp, err := mergeComparators(cmps)
@@ -76,9 +79,7 @@ func (sr SortResults) Process(issues []result.Issue) ([]result.Issue, error) {
return issues, nil
}
-func (sr SortResults) Name() string { return "sort_results" }
-
-func (sr SortResults) Finish() {}
+func (SortResults) Finish() {}
type compareResult int
@@ -193,7 +194,7 @@ func mergeComparators(cmps []*comparator) (*comparator, error) {
return nil, errors.New("no comparator")
}
- for i := 0; i < len(cmps)-1; i++ {
+ for i := range len(cmps) - 1 {
findComparatorTip(cmps[i]).SetNext(cmps[i+1])
}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/source_code.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/source_code.go
index 005b3143f..4a89fc73e 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/source_code.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/source_code.go
@@ -6,13 +6,13 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
+var _ Processor = (*SourceCode)(nil)
+
type SourceCode struct {
lineCache *fsutils.LineCache
log logutils.Log
}
-var _ Processor = SourceCode{}
-
func NewSourceCode(lc *fsutils.LineCache, log logutils.Log) *SourceCode {
return &SourceCode{
lineCache: lc,
@@ -20,28 +20,31 @@ func NewSourceCode(lc *fsutils.LineCache, log logutils.Log) *SourceCode {
}
}
-func (p SourceCode) Name() string {
+func (SourceCode) Name() string {
return "source_code"
}
func (p SourceCode) Process(issues []result.Issue) ([]result.Issue, error) {
- return transformIssues(issues, func(issue *result.Issue) *result.Issue {
- newIssue := *issue
-
- lineRange := issue.GetLineRange()
- for lineNumber := lineRange.From; lineNumber <= lineRange.To; lineNumber++ {
- line, err := p.lineCache.GetLine(issue.FilePath(), lineNumber)
- if err != nil {
- p.log.Warnf("Failed to get line %d for file %s: %s",
- lineNumber, issue.FilePath(), err)
- return issue
- }
-
- newIssue.SourceLines = append(newIssue.SourceLines, line)
+ return transformIssues(issues, p.transform), nil
+}
+
+func (SourceCode) Finish() {}
+
+func (p SourceCode) transform(issue *result.Issue) *result.Issue {
+ newIssue := *issue
+
+ lineRange := issue.GetLineRange()
+ for lineNumber := lineRange.From; lineNumber <= lineRange.To; lineNumber++ {
+ line, err := p.lineCache.GetLine(issue.FilePath(), lineNumber)
+ if err != nil {
+ p.log.Warnf("Failed to get line %d for file %s: %s",
+ lineNumber, issue.FilePath(), err)
+
+ return issue
}
- return &newIssue
- }), nil
-}
+ newIssue.SourceLines = append(newIssue.SourceLines, line)
+ }
-func (p SourceCode) Finish() {}
+ return &newIssue
+}
diff --git a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/uniq_by_line.go b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/uniq_by_line.go
index aad1e019e..115196d9a 100644
--- a/vendor/github.com/golangci/golangci-lint/pkg/result/processors/uniq_by_line.go
+++ b/vendor/github.com/golangci/golangci-lint/pkg/result/processors/uniq_by_line.go
@@ -5,26 +5,23 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-type (
- lineToCount map[int]int
- fileToLineToCount map[string]lineToCount
-)
+const uniqByLineLimit = 1
+
+var _ Processor = (*UniqByLine)(nil)
type UniqByLine struct {
- flc fileToLineToCount
- cfg *config.Config
+ fileLineCounter fileLineCounter
+ cfg *config.Config
}
func NewUniqByLine(cfg *config.Config) *UniqByLine {
return &UniqByLine{
- flc: fileToLineToCount{},
- cfg: cfg,
+ fileLineCounter: fileLineCounter{},
+ cfg: cfg,
}
}
-var _ Processor = &UniqByLine{}
-
-func (p *UniqByLine) Name() string {
+func (*UniqByLine) Name() string {
return "uniq_by_line"
}
@@ -33,28 +30,44 @@ func (p *UniqByLine) Process(issues []result.Issue) ([]result.Issue, error) {
return issues, nil
}
- return filterIssues(issues, func(issue *result.Issue) bool {
- if issue.Replacement != nil && p.cfg.Issues.NeedFix {
- // if issue will be auto-fixed we shouldn't collapse issues:
- // e.g. one line can contain 2 misspellings, they will be in 2 issues and misspell should fix both of them.
- return true
- }
-
- lc := p.flc[issue.FilePath()]
- if lc == nil {
- lc = lineToCount{}
- p.flc[issue.FilePath()] = lc
- }
-
- const limit = 1
- count := lc[issue.Line()]
- if count == limit {
- return false
- }
-
- lc[issue.Line()]++
+ return filterIssuesUnsafe(issues, p.shouldPassIssue), nil
+}
+
+func (*UniqByLine) Finish() {}
+
+func (p *UniqByLine) shouldPassIssue(issue *result.Issue) bool {
+ if issue.Replacement != nil && p.cfg.Issues.NeedFix {
+ // if issue will be auto-fixed we shouldn't collapse issues:
+ // e.g. one line can contain 2 misspellings, they will be in 2 issues and misspell should fix both of them.
return true
- }), nil
+ }
+
+ if p.fileLineCounter.GetCount(issue) == uniqByLineLimit {
+ return false
+ }
+
+ p.fileLineCounter.Increment(issue)
+
+ return true
+}
+
+type fileLineCounter map[string]map[int]int
+
+func (f fileLineCounter) GetCount(issue *result.Issue) int {
+ return f.getCounter(issue)[issue.Line()]
+}
+
+func (f fileLineCounter) Increment(issue *result.Issue) {
+ f.getCounter(issue)[issue.Line()]++
}
-func (p *UniqByLine) Finish() {}
+func (f fileLineCounter) getCounter(issue *result.Issue) map[int]int {
+ lc := f[issue.FilePath()]
+
+ if lc == nil {
+ lc = map[int]int{}
+ f[issue.FilePath()] = lc
+ }
+
+ return lc
+}
diff --git a/vendor/github.com/golangci/misspell/.golangci.yml b/vendor/github.com/golangci/misspell/.golangci.yml
index 31c566eab..2cfed442f 100644
--- a/vendor/github.com/golangci/misspell/.golangci.yml
+++ b/vendor/github.com/golangci/misspell/.golangci.yml
@@ -1,13 +1,11 @@
run:
timeout: 2m
- skip-files: []
linters-settings:
govet:
enable-all: true
disable:
- fieldalignment
- - shadow # FIXME(ldez) must be fixed
gocyclo:
min-complexity: 16
goconst:
@@ -97,7 +95,7 @@ linters:
issues:
exclude-use-default: false
- max-per-linter: 0
+ max-issues-per-linter: 0
max-same-issues: 0
exclude:
- 'ST1000: at least one file in a package should have a package comment'
diff --git a/vendor/github.com/golangci/misspell/.pre-commit-hooks.yaml b/vendor/github.com/golangci/misspell/.pre-commit-hooks.yaml
new file mode 100644
index 000000000..5319a75eb
--- /dev/null
+++ b/vendor/github.com/golangci/misspell/.pre-commit-hooks.yaml
@@ -0,0 +1,8 @@
+- id: misspell
+ name: misspell
+ description: Correct commonly misspelled English words... quickly
+ language: golang
+ entry: misspell
+ args:
+ - -w
+ - -error
diff --git a/vendor/github.com/golangci/misspell/Dockerfile b/vendor/github.com/golangci/misspell/Dockerfile
index 788ce3a77..c85cd6875 100644
--- a/vendor/github.com/golangci/misspell/Dockerfile
+++ b/vendor/github.com/golangci/misspell/Dockerfile
@@ -1,4 +1,4 @@
-FROM golang:1.19-alpine
+FROM golang:1.22-alpine
# cache buster
RUN echo 4
diff --git a/vendor/github.com/golangci/misspell/Makefile b/vendor/github.com/golangci/misspell/Makefile
index 783f977cb..fcda870ce 100644
--- a/vendor/github.com/golangci/misspell/Makefile
+++ b/vendor/github.com/golangci/misspell/Makefile
@@ -9,7 +9,7 @@ build: ## build misspell
go build ./cmd/misspell
test: ## run all tests
- go test -v .
+ CGO_ENABLED=1 go test -v -race .
lint: ## run linter
golangci-lint run
diff --git a/vendor/github.com/golangci/misspell/README.md b/vendor/github.com/golangci/misspell/README.md
index cccd04996..d2c3e7527 100644
--- a/vendor/github.com/golangci/misspell/README.md
+++ b/vendor/github.com/golangci/misspell/README.md
@@ -1,39 +1,37 @@
-[![Build Status](https://travis-ci.org/client9/misspell.svg?branch=master)](https://travis-ci.org/client9/misspell) [![Go Report Card](https://goreportcard.com/badge/github.com/client9/misspell)](https://goreportcard.com/report/github.com/client9/misspell) [![GoDoc](https://godoc.org/github.com/client9/misspell?status.svg)](https://godoc.org/github.com/client9/misspell) [![Coverage](http://gocover.io/_badge/github.com/client9/misspell)](http://gocover.io/github.com/client9/misspell) [![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/client9/misspell/master/LICENSE)
+[![Main](https://github.com/golangci/misspell/actions/workflows/ci.yml/badge.svg)](https://github.com/golangci/misspell/actions/workflows/ci.yml)
+[![Go Report Card](https://goreportcard.com/badge/github.com/golangci/misspell)](https://goreportcard.com/report/github.com/golangci/misspell)
+[![Go Reference](https://pkg.go.dev/badge/github.com/golangci/misspell.svg)](https://pkg.go.dev/github.com/golangci/misspell)
+[![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.golangci.com/golangci/misspell/master/LICENSE)
Correct commonly misspelled English words... quickly.
### Install
-
If you just want a binary and to start using `misspell`:
+```bash
+curl -sfL https://raw.githubusercontent.com/golangci/misspell/master/install-misspell.sh | sh -s -- -b ./bin ${MISSPELL_VERSION}
```
-curl -L -o ./install-misspell.sh https://git.io/misspell
-sh ./install-misspell.sh
-```
-
-
-Both will install as `./bin/misspell`. You can adjust the download location using the `-b` flag. File a ticket if you want another platform supported.
+Both will install as `./bin/misspell`.
+You can adjust the download location using the `-b` flag.
+File a ticket if you want another platform supported.
-If you use [Go](https://golang.org/), the best way to run `misspell` is by using [gometalinter](#gometalinter). Otherwise, install `misspell` the old-fashioned way:
+If you use [Go](https://golang.org/), the best way to run `misspell` is by using [golangci-lint](https://github.com/golangci/golangci-lint).
+Otherwise, install `misspell` the old-fashioned way:
+```bash
+go install github.com/golangci/misspell/cmd/misspell@latest
```
-go install github.com/client9/misspell/cmd/misspell@latest
-```
-
-and misspell will be in your `GOPATH`
-
-Also if you like to live dangerously, one could do
+Also, if you like to live dangerously, one could do
```bash
-curl -L https://git.io/misspell | bash
+curl -sfL https://raw.githubusercontent.com/golangci/misspell/master/install-misspell.sh | sh -s -- -b $(go env GOPATH)/bin ${MISSPELL_VERSION}
```
### Usage
-
```bash
$ misspell all.html your.txt important.md files.go
your.txt:42:10 found "langauge" a misspelling of "language"
@@ -41,29 +39,49 @@ your.txt:42:10 found "langauge" a misspelling of "language"
# ^ file, line, column
```
-```
+```console
$ misspell -help
Usage of misspell:
-debug
- Debug matching, very slow
+ Debug matching, very slow
+ -dict string
+ User defined corrections file path (.csv). CSV format: typo,fix
-error
- Exit with 2 if misspelling found
+ Exit with 2 if misspelling found
-f string
- 'csv', 'sqlite3' or custom Golang template for output
+ 'csv', 'sqlite3' or custom Golang template for output
-i string
- ignore the following corrections, comma separated
+ ignore the following corrections, comma-separated
-j int
- Number of workers, 0 = number of CPUs
+ Number of workers, 0 = number of CPUs
-legal
- Show legal information and exit
+ Show legal information and exit
-locale string
- Correct spellings using locale perferances for US or UK. Default is to use a neutral variety of English. Setting locale to US will correct the British spelling of 'colour' to 'color'
+ Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English. Setting locale to US will correct the British spelling of 'colour' to 'color'
-o string
- output file or [stderr|stdout|] (default "stdout")
- -q Do not emit misspelling output
+ output file or [stderr|stdout|] (default "stdout")
+ -q Do not emit misspelling output
-source string
- Source mode: auto=guess, go=golang source, text=plain or markdown-like text (default "auto")
- -w Overwrite file with corrections (default is just to display)
+ Source mode: text (default), go (comments only) (default "text")
+ -v Show version and exit
+ -w Overwrite file with corrections (default is just to display)
+```
+
+### Pre-commit hook
+
+To use misspell with [pre-commit](https://pre-commit.com/), add the following to your `.pre-commit-config.yaml`:
+
+
+```yaml
+- repo: https://github.com/golangci/misspell
+ rev: v0.6.0
+ hooks:
+ - id: misspell
+ # The hook will run on all files by default.
+ # To limit to some files only, use pre-commit patterns/types
+ # files: <pattern>
+ # exclude: <pattern>
+ # types: <types>
```
## FAQ
@@ -72,7 +90,6 @@ Usage of misspell:
* [Converting UK spellings to US](#locale)
* [Using pipes and stdin](#stdin)
* [Golang special support](#golang)
-* [gometalinter support](#gometalinter)
* [CSV Output](#csv)
* [Using SQLite3](#sqlite)
* [Changing output format](#output)
@@ -92,7 +109,7 @@ Usage of misspell:
Just add the `-w` flag!
-```
+```console
$ misspell -w all.html your.txt important.md files.go
your.txt:9:21:corrected "langauge" to "language"
@@ -104,20 +121,19 @@ your.txt:9:21:corrected "langauge" to "language"
Add the `-locale US` flag!
-```bash
+```console
$ misspell -locale US important.txt
important.txt:10:20 found "colour" a misspelling of "color"
```
Add the `-locale UK` flag!
-```bash
+```console
$ echo "My favorite color is blue" | misspell -locale UK
stdin:1:3:found "favorite color" a misspelling of "favourite colour"
```
-Help is appreciated as I'm neither British nor an
-expert in the English language.
+Help is appreciated as I'm neither British nor an expert in the English language.
<a name="recursive"></a>
### How do you check an entire folder recursively?
@@ -141,7 +157,8 @@ or
find . -type f | xargs misspell
```
-You can select a type of file as well. The following examples selects all `.txt` files that are *not* in the `vendor` directory:
+You can select a type of file as well.
+The following examples selects all `.txt` files that are *not* in the `vendor` directory:
```bash
find . -type f -name '*.txt' | grep -v vendor/ | xargs misspell -error
@@ -154,14 +171,14 @@ Yes!
Print messages to `stderr` only:
-```bash
+```console
$ echo "zeebra" | misspell
stdin:1:0:found "zeebra" a misspelling of "zebra"
```
Print messages to `stderr`, and corrected text to `stdout`:
-```bash
+```console
$ echo "zeebra" | misspell -w
stdin:1:0:corrected "zeebra" to "zebra"
zebra
@@ -169,7 +186,7 @@ zebra
Only print the corrected text to `stdout`:
-```bash
+```console
$ echo "zeebra" | misspell -w -q
zebra
```
@@ -177,55 +194,23 @@ zebra
<a name="golang"></a>
### Are there special rules for golang source files?
-Yes! If the file ends in `.go`, then misspell will only check spelling in
-comments.
-
-If you want to force a file to be checked as a golang source, use `-source=go`
-on the command line. Conversely, you can check a golang source as if it were
-pure text by using `-source=text`. You might want to do this since many
-variable names have misspellings in them!
-
-### Can I check only-comments in other other programming languages?
-
-I'm told the using `-source=go` works well for ruby, javascript, java, c and
-c++.
-
-It doesn't work well for python and bash.
-
-<a name="gometalinter"></a>
-### Does this work with gometalinter?
-
-[gometalinter](https://github.com/alecthomas/gometalinter) runs
-multiple golang linters. Starting on [2016-06-12](https://github.com/alecthomas/gometalinter/pull/134)
-gometalinter supports `misspell` natively but it is disabled by default.
-
-```bash
-# update your copy of gometalinter
-go get -u github.com/alecthomas/gometalinter
-
-# install updates and misspell
-gometalinter --install --update
-```
-
-To use, just enable `misspell`
-
-```
-gometalinter --enable misspell ./...
-```
+yes, if you want to force a file to be checked as a golang source, use `-source=go` on the command line.
+Conversely, you can check a golang source as if it were pure text by using `-source=text`.
+You might want to do this since many variable names have misspellings in them!
-Note that gometalinter only checks golang files, and uses the default options
-of `misspell`
+### Can I check only-comments in other programming languages?
-You may wish to run this on your plaintext (.txt) and/or markdown files too.
+I'm told the using `-source=go` works well for Ruby, Javascript, Java, C and C++.
+It doesn't work well for Python and Bash.
<a name="csv"></a>
### How Can I Get CSV Output?
Using `-f csv`, the output is standard comma-seprated values with headers in the first row.
-```
-misspell -f csv *
+```console
+$ misspell -f csv *
file,line,column,typo,corrected
"README.md",9,22,langauge,language
"README.md",47,25,langauge,language
@@ -236,7 +221,7 @@ file,line,column,typo,corrected
Using `-f sqlite`, the output is a [sqlite3](https://www.sqlite.org/index.html) dump-file.
-```bash
+```console
$ misspell -f sqlite * > /tmp/misspell.sql
$ cat /tmp/misspell.sql
@@ -254,7 +239,7 @@ INSERT INTO misspell VALUES("install.txt",202,31,"immediatly","immediately");
COMMIT;
```
-```bash
+```console
$ sqlite3 -init /tmp/misspell.sql :memory: 'select count(*) from misspell'
1
```
@@ -271,20 +256,22 @@ misspell -f sqlite * | sqlite3 -init /dev/stdin -column -cmd '.width 60 15' ':me
Using the `-i "comma,separated,rules"` flag you can specify corrections to ignore.
-For example, if you were to run `misspell -w -error -source=text` against document that contains the string `Guy Finkelshteyn Braswell`, misspell would change the text to `Guy Finkelstheyn Bras well`. You can then
-determine the rules to ignore by reverting the change and running the with the `-debug` flag. You can then see
-that the corrections were `htey -> they` and `aswell -> as well`. To ignore these two rules, you add `-i "htey,aswell"` to
-your command. With debug mode on, you can see it print the corrections, but it will no longer make them.
+For example, if you were to run `misspell -w -error -source=text` against document that contains the string `Guy Finkelshteyn Braswell`,
+misspell would change the text to `Guy Finkelstheyn Bras well`.
+You can then determine the rules to ignore by reverting the change and running the with the `-debug` flag.
+You can then see that the corrections were `htey -> they` and `aswell -> as well`.
+To ignore these two rules, you add `-i "htey,aswell"` to your command.
+With debug mode on, you can see it print the corrections, but it will no longer make them.
<a name="output"></a>
### How can I change the output format?
-Using the `-f template` flag you can pass in a
-[golang text template](https://golang.org/pkg/text/template/) to format the output.
+Using the `-f template` flag you can pass in a [golang text template](https://golang.org/pkg/text/template/) to format the output.
One can use `printf "%q" VALUE` to safely quote a value.
-The default template is compatible with [gometalinter](https://github.com/alecthomas/gometalinter)
+The default template:
+
```
{{ .Filename }}:{{ .Line }}:{{ .Column }}:corrected {{ printf "%q" .Original }} to "{{ printf "%q" .Corrected }}"
```
@@ -298,14 +285,12 @@ To just print probable misspellings:
<a name="problem"></a>
### What problem does this solve?
-This corrects commonly misspelled English words in computer source
-code, and other text-based formats (`.txt`, `.md`, etc).
+This corrects commonly misspelled English words in computer source code, and other text-based formats (`.txt`, `.md`, etc.).
-It is designed to run quickly so it can be
-used as a [pre-commit hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)
-with minimal burden on the developer.
+It is designed to run quickly,
+so it can be used as a [pre-commit hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) with minimal burden on the developer.
-It does not work with binary formats (e.g. Word, etc).
+It does not work with binary formats (e.g. Word, etc.).
It is not a complete spell-checking program nor a grammar checker.
@@ -322,78 +307,71 @@ They all work but had problems that prevented me from using them at scale:
* slow, all of the above check one misspelling at a time (i.e. linear) using regexps
* not MIT/Apache2 licensed (or equivalent)
-* have dependencies that don't work for me (python3, bash, linux sed, etc)
+* have dependencies that don't work for me (python3, bash, linux sed, etc.)
* don't understand American vs. British English and sometimes makes unwelcome "corrections"
-That said, they might be perfect for you and many have more features
-than this project!
+That said, they might be perfect for you and many have more features than this project!
<a name="performance"></a>
### How fast is it?
-Misspell is easily 100x to 1000x faster than other spelling correctors. You
-should be able to check and correct 1000 files in under 250ms.
+Misspell is easily 100x to 1000x faster than other spelling correctors.
+You should be able to check and correct 1000 files in under 250ms.
-This uses the mighty power of golang's
-[strings.Replacer](https://golang.org/pkg/strings/#Replacer) which is
-a implementation or variation of the
-[Aho–Corasick algorithm](https://en.wikipedia.org/wiki/Aho–Corasick_algorithm).
+This uses the mighty power of golang's [strings.Replacer](https://golang.org/pkg/strings/#Replacer)
+which is an implementation or variation of the [Aho–Corasick algorithm](https://en.wikipedia.org/wiki/Aho–Corasick_algorithm).
This makes multiple substring matches *simultaneously*.
-In addition this uses multiple CPU cores to work on multiple files.
+It also uses multiple CPU cores to work on multiple files concurrently.
<a name="issues"></a>
### What problems does it have?
-Unlike the other projects, this doesn't know what a "word" is. There may be
-more false positives and false negatives due to this. On the other hand, it
-sometimes catches things others don't.
+Unlike the other projects, this doesn't know what a "word" is.
+There may be more false positives and false negatives due to this.
+On the other hand, it sometimes catches things others don't.
Either way, please file bugs and we'll fix them!
-Since it operates in parallel to make corrections, it can be non-obvious to
-determine exactly what word was corrected.
+Since it operates in parallel to make corrections,
+it can be non-obvious to determine exactly what word was corrected.
<a name="debug"></a>
### It's making mistakes. How can I debug?
-Run using `-debug` flag on the file you want. It should then print what word
-it is trying to correct. Then [file a
-bug](https://github.com/client9/misspell/issues) describing the problem.
+Run using `-debug` flag on the file you want.
+It should then print what word it is trying to correct.
+Then [file a bug](https://github.com/golangci/misspell/issues) describing the problem.
Thanks!
<a name="missing"></a>
### Why is it making mistakes or missing items in golang files?
-The matching function is *case-sensitive*, so variable names that are multiple
-worlds either in all-upper or all-lower case sometimes can cause false
-positives. For instance a variable named `bodyreader` could trigger a false
-positive since `yrea` is in the middle that could be corrected to `year`.
-Other problems happen if the variable name uses a English contraction that
-should use an apostrophe. The best way of fixing this is to use the
-[Effective Go naming
-conventions](https://golang.org/doc/effective_go.html#mixed-caps) and use
-[camelCase](https://en.wikipedia.org/wiki/CamelCase) for variable names. You
-can check your code using [golint](https://github.com/golang/lint)
+The matching function is *case-sensitive*,
+so variable names that are multiple worlds either in all-uppercase or all-lowercase case sometimes can cause false positives.
+For instance a variable named `bodyreader` could trigger a false positive since `yrea` is in the middle that could be corrected to `year`.
+Other problems happen if the variable name uses an English contraction that should use an apostrophe.
+The best way of fixing this is to use the [Effective Go naming conventions](https://golang.org/doc/effective_go.html#mixed-caps)
+and use [camelCase](https://en.wikipedia.org/wiki/CamelCase) for variable names.
+You can check your code using [golint](https://github.com/golang/lint)
<a name="license"></a>
### What license is this?
-The main code is [MIT](https://github.com/client9/misspell/blob/master/LICENSE).
+The main code is [MIT](https://github.com/golangci/misspell/blob/master/LICENSE).
Misspell also makes uses of the Golang standard library and contains a modified version of Golang's [strings.Replacer](https://golang.org/pkg/strings/#Replacer)
-which are covered under a [BSD License](https://github.com/golang/go/blob/master/LICENSE). Type `misspell -legal` for more details or see [legal.go](https://github.com/client9/misspell/blob/master/legal.go)
+which is covered under a [BSD License](https://github.com/golang/go/blob/master/LICENSE).
+Type `misspell -legal` for more details or see [legal.go](https://github.com/golangci/misspell/blob/master/legal.go)
<a name="words"></a>
### Where do the word lists come from?
It started with a word list from
[Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines).
-Unfortunately, this list had to be highly edited as many of the words are
-obsolete or based from mistakes on mechanical typewriters (I'm guessing).
+Unfortunately, this list had to be highly edited as many of the words are obsolete or based on mistakes on mechanical typewriters (I'm guessing).
-Additional words were added based on actually mistakes seen in
-the wild (meaning self-generated).
+Additional words were added based on actually mistakes seen in the wild (meaning self-generated).
Variations of UK and US spellings are based on many sources including:
@@ -401,24 +379,23 @@ Variations of UK and US spellings are based on many sources including:
* http://www.oxforddictionaries.com/us/words/american-and-british-spelling-american (excellent site but incomplete)
* Diffing US and UK [scowl dictionaries](http://wordlist.aspell.net)
-American English is more accepting of spelling variations than is British
-English, so "what is American or not" is subject to opinion. Corrections and help welcome.
+American English is more accepting of spelling variations than is British English,
+so "what is American or not" is subject to opinion.
+Corrections and help welcome.
<a name="otherideas"></a>
### What are some other enhancements that could be done?
-Here's some ideas for enhancements:
+Here are some ideas for enhancements:
*Capitalization of proper nouns* could be done (e.g. weekday and month names, country names, language names)
-*Opinionated US spellings* US English has a number of words with alternate
-spellings. Think [adviser vs.
-advisor](http://grammarist.com/spelling/adviser-advisor/). While "advisor" is not wrong, the opinionated US
-locale would correct "advisor" to "adviser".
+*Opinionated US spellings* US English has a number of words with alternate spellings.
+Think [adviser vs. advisor](http://grammarist.com/spelling/adviser-advisor/).
+While "advisor" is not wrong, the opinionated US locale would correct "advisor" to "adviser".
*Versioning* Some type of versioning is needed so reporting mistakes and errors is easier.
-*Feedback* Mistakes would be sent to some server for agregation and feedback review.
+*Feedback* Mistakes would be sent to some server for aggregation and feedback review.
-*Contractions and Apostrophes* This would optionally correct "isnt" to
-"isn't", etc.
+*Contractions and Apostrophes* This would optionally correct "isnt" to "isn't", etc.
diff --git a/vendor/github.com/golangci/misspell/goreleaser.yml b/vendor/github.com/golangci/misspell/goreleaser.yml
index 97aa83e5a..2d2be1a75 100644
--- a/vendor/github.com/golangci/misspell/goreleaser.yml
+++ b/vendor/github.com/golangci/misspell/goreleaser.yml
@@ -15,13 +15,14 @@ builds:
- CGO_ENABLED=0
archives:
- - name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
- replacements:
- amd64: 64bit
- 386: 32bit
- darwin: mac
- files:
- - LICENSE
+ - format: tar.gz
+ wrap_in_directory: true
+ format_overrides:
+ - goos: windows
+ format: zip
+ name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
+ files:
+ - LICENSE
checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
diff --git a/vendor/github.com/golangci/misspell/install-misspell.sh b/vendor/github.com/golangci/misspell/install-misspell.sh
index 51e9b3372..d6023e117 100644
--- a/vendor/github.com/golangci/misspell/install-misspell.sh
+++ b/vendor/github.com/golangci/misspell/install-misspell.sh
@@ -1,39 +1,33 @@
#!/bin/sh
set -e
-# Code generated by godownloader. DO NOT EDIT.
-#
usage() {
this=$1
cat <<EOF
$this: download go binaries for golangci/misspell
-Usage: $this [-b] bindir [tag]
+Usage: $this [-b <bindir>] [-d] [<tag>]
-b sets bindir or installation directory, Defaults to ./bin
- [tag] is a tag from
+ -d turns on debug logging
+ <tag> is a tag from
https://github.com/golangci/misspell/releases
- If tag is missing, then an attempt to find the latest will be found.
-
- Consider setting GITHUB_TOKEN to avoid triggering GitHub rate limits.
- See the following for more details:
- https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
-
- Generated by godownloader
- https://github.com/goreleaser/godownloader
+ If tag is missing, then the latest will be used.
EOF
exit 2
}
parse_args() {
- #BINDIR is ./bin unless set be ENV
- # over-ridden by flag below
+ # BINDIR is ./bin unless set be ENV
+ # overridden by flag below
BINDIR=${BINDIR:-./bin}
- while getopts "b:h?" arg; do
+ while getopts "b:dh?x" arg; do
case "$arg" in
b) BINDIR="$OPTARG" ;;
+ d) log_set_priority 10 ;;
h | \?) usage "$0" ;;
+ x) set -x ;;
esac
done
shift $((OPTIND - 1))
@@ -44,72 +38,66 @@ parse_args() {
# network, either nothing will happen or will syntax error
# out preventing half-done work
execute() {
- TMPDIR=$(mktmpdir)
- log_debug "downloading tarball ${TARBALL_URL}"
- http_download "${TMPDIR}/${TARBALL}" "${TARBALL_URL}"
- log_debug "downloading checksum ${CHECKSUM_URL}"
- http_download "${TMPDIR}/${CHECKSUM}" "${CHECKSUM_URL}"
- hash_sha256_verify "${TMPDIR}/${TARBALL}" "${TMPDIR}/${CHECKSUM}"
-
- (cd "${TMPDIR}" && untar "${TARBALL}")
- install -d "${BINDIR}"
- install "${TMPDIR}/${BINARY}" "${BINDIR}/"
- log_info "installed as ${BINDIR}/${BINARY}"
+ tmpdir=$(mktemp -d)
+ log_debug "downloading files into ${tmpdir}"
+ http_download "${tmpdir}/${TARBALL}" "${TARBALL_URL}"
+ http_download "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}"
+ hash_sha256_verify "${tmpdir}/${TARBALL}" "${tmpdir}/${CHECKSUM}"
+ srcdir="${tmpdir}/${NAME}"
+ rm -rf "${srcdir}"
+ (cd "${tmpdir}" && untar "${TARBALL}")
+ test ! -d "${BINDIR}" && install -d "${BINDIR}"
+ for binexe in $BINARIES; do
+ if [ "$OS" = "windows" ]; then
+ binexe="${binexe}.exe"
+ fi
+ install "${srcdir}/${binexe}" "${BINDIR}/"
+ log_info "installed ${BINDIR}/${binexe}"
+ done
+ rm -rf "${tmpdir}"
}
-is_supported_platform() {
- platform=$1
- found=1
- case "$platform" in
- darwin/amd64) found=0 ;;
- linux/amd64) found=0 ;;
- windows/amd64) found=0 ;;
- darwin/arm64) found=0 ;;
- linux/arm64) found=0 ;;
- esac
- case "$platform" in
- darwin/386) found=1 ;;
- windows/386) found=1 ;;
+get_binaries() {
+ case "$PLATFORM" in
+ darwin/amd64) BINARIES="misspell" ;;
+ darwin/arm64) BINARIES="misspell" ;;
+ linux/amd64) BINARIES="misspell" ;;
+ linux/arm64) BINARIES="misspell" ;;
+ windows/amd64) BINARIES="misspell" ;;
+ windows/arm64) BINARIES="misspell" ;;
+ *)
+ log_crit "platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX}/issues/new"
+ exit 1
+ ;;
esac
- return $found
-}
-check_platform() {
- if is_supported_platform "$PLATFORM"; then
- # optional logging goes here
- true
- else
- log_crit "platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX}/issues/new"
- exit 1
- fi
}
tag_to_version() {
if [ -z "${TAG}" ]; then
log_info "checking GitHub for latest tag"
- TAG=$(github_last_release "$OWNER/$REPO")
+ else
+ log_info "checking GitHub for tag '${TAG}'"
+ fi
+ REALTAG=$(github_release "$OWNER/$REPO" "${TAG}") && true
+ if test -z "$REALTAG"; then
+ log_crit "unable to find '${TAG}' - use 'latest' or see https://github.com/${PREFIX}/releases for details"
+ exit 1
fi
# if version starts with 'v', remove it
+ TAG="$REALTAG"
VERSION=${TAG#v}
}
adjust_format() {
- # change format (tar.gz or zip) based on ARCH
+ # change format (tar.gz or zip) based on OS
+ case ${OS} in
+ windows) FORMAT=zip ;;
+ esac
true
}
adjust_os() {
# adjust archive name based on OS
- case ${OS} in
- 386) OS=32bit ;;
- amd64) OS=amd64 ;;
- arm64) OS=64bit ;;
- darwin) OS=mac ;;
- esac
true
}
adjust_arch() {
# adjust archive name based on ARCH
- case ${ARCH} in
- 386) ARCH=32bit ;;
- amd64) ARCH=64bit ;;
- darwin) ARCH=mac ;;
- esac
true
}
@@ -127,9 +115,6 @@ is_command() {
echoerr() {
echo "$@" 1>&2
}
-log_prefix() {
- echo "$0"
-}
_logp=6
log_set_priority() {
_logp="$1"
@@ -139,24 +124,45 @@ log_priority() {
echo "$_logp"
return
fi
- [ "$1" -ge "$_logp" ]
+ [ "$1" -le "$_logp" ]
+}
+log_tag() {
+ case $1 in
+ 0) echo "emerg" ;;
+ 1) echo "alert" ;;
+ 2) echo "crit" ;;
+ 3) echo "err" ;;
+ 4) echo "warning" ;;
+ 5) echo "notice" ;;
+ 6) echo "info" ;;
+ 7) echo "debug" ;;
+ *) echo "$1" ;;
+ esac
}
log_debug() {
- log_priority 7 && echoerr "$(log_prefix)" "DEBUG" "$@"
+ log_priority 7 || return 0
+ echoerr "$(log_prefix)" "$(log_tag 7)" "$@"
}
log_info() {
- log_priority 6 && echoerr "$(log_prefix)" "INFO" "$@"
+ log_priority 6 || return 0
+ echoerr "$(log_prefix)" "$(log_tag 6)" "$@"
}
log_err() {
- log_priority 3 && echoerr "$(log_prefix)" "ERR" "$@"
+ log_priority 3 || return 0
+ echoerr "$(log_prefix)" "$(log_tag 3)" "$@"
}
log_crit() {
- log_priority 2 && echoerr "$(log_prefix)" "CRIT" "$@"
+ log_priority 2 || return 0
+ echoerr "$(log_prefix)" "$(log_tag 2)" "$@"
}
uname_os() {
os=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$os" in
- msys_nt) os="windows" ;;
+ msys*) os="windows" ;;
+ mingw*) os="windows" ;;
+ cygwin*) os="windows" ;;
+ win*) os="windows" ;;
+ sunos) [ "$(uname -o)" = "illumos" ] && os=illumos ;;
esac
echo "$os"
}
@@ -167,12 +173,14 @@ uname_arch() {
x86) arch="386" ;;
i686) arch="386" ;;
i386) arch="386" ;;
+ i86pc) arch="amd64" ;;
aarch64) arch="arm64" ;;
- armv5*) arch="arm5" ;;
- armv6*) arch="arm6" ;;
- armv7*) arch="arm7" ;;
+ armv5*) arch="armv5" ;;
+ armv6*) arch="armv6" ;;
+ armv7*) arch="armv7" ;;
+ loongarch64) arch="loong64" ;;
esac
- echo ${arch}
+ echo "${arch}"
}
uname_os_check() {
os=$(uname_os)
@@ -180,6 +188,7 @@ uname_os_check() {
darwin) return 0 ;;
dragonfly) return 0 ;;
freebsd) return 0 ;;
+ illumos) return 0;;
linux) return 0 ;;
android) return 0 ;;
nacl) return 0 ;;
@@ -189,7 +198,7 @@ uname_os_check() {
solaris) return 0 ;;
windows) return 0 ;;
esac
- log_crit "uname_os_check '$(uname -s)' got converted to '$os' which is not a GOOS value. Please file bug at https://github.com/client9/shlib"
+ log_crit "uname_os_check '$(uname -s)' got converted to '$os' which is not a GOOS value."
return 1
}
uname_arch_check() {
@@ -208,16 +217,18 @@ uname_arch_check() {
mips64) return 0 ;;
mips64le) return 0 ;;
s390x) return 0 ;;
+ riscv64) return 0 ;;
amd64p32) return 0 ;;
+ loong64) return 0 ;;
esac
- log_crit "uname_arch_check '$(uname -m)' got converted to '$arch' which is not a GOARCH value. Please file bug report at https://github.com/client9/shlib"
+ log_crit "uname_arch_check '$(uname -m)' got converted to '$arch' which is not a GOARCH value."
return 1
}
untar() {
tarball=$1
case "${tarball}" in
- *.tar.gz | *.tgz) tar -xzf "${tarball}" ;;
- *.tar) tar -xf "${tarball}" ;;
+ *.tar.gz | *.tgz) tar --no-same-owner -xzf "${tarball}" ;;
+ *.tar) tar --no-same-owner -xf "${tarball}" ;;
*.zip) unzip "${tarball}" ;;
*)
log_err "untar unknown archive format for ${tarball}"
@@ -225,52 +236,57 @@ untar() {
;;
esac
}
-mktmpdir() {
- test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
- mkdir -p "${TMPDIR}"
- echo "${TMPDIR}"
-}
-http_download() {
+http_download_curl() {
local_file=$1
source_url=$2
header=$3
- headerflag=''
- destflag=''
- if is_command curl; then
- cmd='curl --fail -sSL'
- destflag='-o'
- headerflag='-H'
- elif is_command wget; then
- cmd='wget -q'
- destflag='-O'
- headerflag='--header'
+ if [ -z "$header" ]; then
+ code=$(curl -w '%{http_code}' -sL -o "$local_file" "$source_url")
else
- log_crit "http_download unable to find wget or curl"
+ code=$(curl -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url")
+ fi
+ if [ "$code" != "200" ]; then
+ log_debug "http_download_curl received HTTP status $code"
return 1
fi
+ return 0
+}
+http_download_wget() {
+ local_file=$1
+ source_url=$2
+ header=$3
if [ -z "$header" ]; then
- $cmd $destflag "$local_file" "$source_url"
+ wget -q -O "$local_file" "$source_url"
else
- $cmd $headerflag "$header" $destflag "$local_file" "$source_url"
+ wget -q --header "$header" -O "$local_file" "$source_url"
fi
}
-github_api() {
- local_file=$1
- source_url=$2
- header=""
- case "$source_url" in
- https://api.github.com*)
- test -z "$GITHUB_TOKEN" || header="Authorization: token $GITHUB_TOKEN"
- ;;
- esac
- http_download "$local_file" "$source_url" "$header"
+http_download() {
+ log_debug "http_download $2"
+ if is_command curl; then
+ http_download_curl "$@"
+ return
+ elif is_command wget; then
+ http_download_wget "$@"
+ return
+ fi
+ log_crit "http_download unable to find wget or curl"
+ return 1
}
-github_last_release() {
+http_copy() {
+ tmp=$(mktemp)
+ http_download "${tmp}" "$1" "$2" || return 1
+ body=$(cat "$tmp")
+ rm -f "${tmp}"
+ echo "$body"
+}
+github_release() {
owner_repo=$1
version=$2
test -z "$version" && version="latest"
giturl="https://github.com/${owner_repo}/releases/${version}"
- json=$(http_download "-" "$giturl" "Accept:application/json")
+ json=$(http_copy "$giturl" "Accept:application/json")
+ test -z "$json" && return 1
version=$(echo "$json" | tr -s '\n' ' ' | sed 's/.*"tag_name":"//' | sed 's/".*//')
test -z "$version" && return 1
echo "$version"
@@ -319,6 +335,7 @@ End of functions from https://github.com/client9/shlib
------------------------------------------------------------------------
EOF
+PROJECT_NAME="misspell"
OWNER=golangci
REPO="misspell"
BINARY=misspell
@@ -339,7 +356,7 @@ uname_arch_check "$ARCH"
parse_args "$@"
-check_platform
+get_binaries
tag_to_version
@@ -357,9 +374,4 @@ TARBALL_URL=${GITHUB_DOWNLOAD}/${TAG}/${TARBALL}
CHECKSUM=${BINARY}_${VERSION}_checksums.txt
CHECKSUM_URL=${GITHUB_DOWNLOAD}/${TAG}/${CHECKSUM}
-# Adjust binary name if windows
-if [ "$OS" = "windows" ]; then
- BINARY="${BINARY}.exe"
-fi
-
execute
diff --git a/vendor/github.com/golangci/misspell/mime.go b/vendor/github.com/golangci/misspell/mime.go
index 76a96cfd1..19d49e085 100644
--- a/vendor/github.com/golangci/misspell/mime.go
+++ b/vendor/github.com/golangci/misspell/mime.go
@@ -7,6 +7,7 @@ import (
"net/http"
"os"
"path/filepath"
+ "slices"
"strings"
)
@@ -77,13 +78,12 @@ func isSCMPath(s string) bool {
if strings.Contains(filepath.Base(s), "EDITMSG") {
return false
}
+
parts := strings.Split(filepath.Clean(s), string(filepath.Separator))
- for _, dir := range parts {
- if scm[dir] {
- return true
- }
- }
- return false
+
+ return slices.ContainsFunc(parts, func(dir string) bool {
+ return scm[dir]
+ })
}
var magicHeaders = [][]byte{
@@ -174,7 +174,8 @@ func ReadTextFile(filename string) (string, error) {
// if not-text, then exit
isText := false
if fstat.Size() > 50000 {
- fin, err := os.Open(filename)
+ var fin *os.File
+ fin, err = os.Open(filename)
if err != nil {
return "", fmt.Errorf("unable to open large file %q: %w", filename, err)
}
diff --git a/vendor/github.com/golangci/misspell/notwords.go b/vendor/github.com/golangci/misspell/notwords.go
index a250cf7f6..f694f46dc 100644
--- a/vendor/github.com/golangci/misspell/notwords.go
+++ b/vendor/github.com/golangci/misspell/notwords.go
@@ -4,12 +4,17 @@ import (
"bytes"
"regexp"
"strings"
+ "unicode"
)
var (
- reEmail = regexp.MustCompile(`[a-zA-Z0-9_.%+-]+@[a-zA-Z0-9-.]+\.[a-zA-Z]{2,6}[^a-zA-Z]`)
- reHost = regexp.MustCompile(`[a-zA-Z0-9-.]+\.[a-zA-Z]+`)
- reBackslash = regexp.MustCompile(`\\[a-z]`)
+ reEmail = regexp.MustCompile(`[[:alnum:]_.%+-]+@[[:alnum:]-.]+\.[[:alpha:]]{2,6}[^[:alpha:]]`)
+ reBackslash = regexp.MustCompile(`\\[[:lower:]]`)
+
+ // reHost Host name regular expression.
+ // The length of any one label is limited between 1 and 63 octets. (https://www.ietf.org/rfc/rfc2181.txt)
+ // A TLD has at least 2 letters.
+ reHost = regexp.MustCompile(`([[:alnum:]-]+\.)+[[:alpha:]]{2,63}`)
)
// RemovePath attempts to strip away embedded file system paths, e.g.
@@ -20,7 +25,7 @@ var (
func RemovePath(s string) string {
out := bytes.Buffer{}
var idx int
- for len(s) > 0 {
+ for s != "" {
if idx = strings.IndexByte(s, '/'); idx == -1 {
out.WriteString(s)
break
@@ -62,6 +67,18 @@ func replaceWithBlanks(s string) string {
return strings.Repeat(" ", len(s))
}
+// replaceHost same as replaceWithBlanks but if the string contains at least one uppercase letter returns the string.
+// Domain names are case-insensitive but browsers and DNS convert uppercase to lower case. (https://www.ietf.org/rfc/rfc4343.txt)
+func replaceHost(s string) string {
+ for _, r := range s {
+ if unicode.IsUpper(r) {
+ return s
+ }
+ }
+
+ return replaceWithBlanks(s)
+}
+
// RemoveEmail remove email-like strings, e.g. "nickg+junk@xfoobar.com", "nickg@xyz.abc123.biz".
func RemoveEmail(s string) string {
return reEmail.ReplaceAllStringFunc(s, replaceWithBlanks)
@@ -69,7 +86,7 @@ func RemoveEmail(s string) string {
// RemoveHost removes host-like strings "foobar.com" "abc123.fo1231.biz".
func RemoveHost(s string) string {
- return reHost.ReplaceAllStringFunc(s, replaceWithBlanks)
+ return reHost.ReplaceAllStringFunc(s, replaceHost)
}
// RemoveBackslashEscapes removes characters that are preceded by a backslash.
diff --git a/vendor/github.com/golangci/misspell/replace.go b/vendor/github.com/golangci/misspell/replace.go
index bcfcf8deb..b51dfa83b 100644
--- a/vendor/github.com/golangci/misspell/replace.go
+++ b/vendor/github.com/golangci/misspell/replace.go
@@ -5,6 +5,7 @@ import (
"bytes"
"io"
"regexp"
+ "slices"
"strings"
"text/scanner"
)
@@ -17,12 +18,9 @@ func max(x, y int) int {
}
func inArray(haystack []string, needle string) bool {
- for _, word := range haystack {
- if strings.EqualFold(needle, word) {
- return true
- }
- }
- return false
+ return slices.ContainsFunc(haystack, func(word string) bool {
+ return strings.EqualFold(needle, word)
+ })
}
var wordRegexp = regexp.MustCompile(`[a-zA-Z0-9']+`)
@@ -192,7 +190,7 @@ Loop:
return buf.String(), diffs
}
-// Replace is corrects misspellings in input, returning corrected version along with a list of diffs.
+// Replace is correcting misspellings in input, returning corrected version along with a list of diffs.
func (r *Replacer) Replace(input string) (string, []Diff) {
output := r.engine.Replace(input)
if input == output {
diff --git a/vendor/github.com/golangci/misspell/stringreplacer.go b/vendor/github.com/golangci/misspell/stringreplacer.go
index 73ca9a56a..46cb6c4b6 100644
--- a/vendor/github.com/golangci/misspell/stringreplacer.go
+++ b/vendor/github.com/golangci/misspell/stringreplacer.go
@@ -102,7 +102,6 @@ func (t *trieNode) add(key, val string, priority int, r *genericReplacer) {
return
}
- //nolint:nestif // TODO(ldez) must be fixed.
if t.prefix != "" {
// Need to split the prefix among multiple nodes.
var n int // length of the longest common prefix
@@ -111,9 +110,10 @@ func (t *trieNode) add(key, val string, priority int, r *genericReplacer) {
break
}
}
- if n == len(t.prefix) {
+ switch n {
+ case len(t.prefix):
t.next.add(key[n:], val, priority, r)
- } else if n == 0 {
+ case 0:
// First byte differs, start a new lookup table here. Looking up
// what is currently t.prefix[0] will lead to prefixNode, and
// looking up key[0] will lead to keyNode.
@@ -133,7 +133,7 @@ func (t *trieNode) add(key, val string, priority int, r *genericReplacer) {
t.prefix = ""
t.next = nil
keyNode.add(key[1:], val, priority, r)
- } else {
+ default:
// Insert new node after the common section of the prefix.
next := &trieNode{
prefix: t.prefix[n:],
@@ -143,18 +143,22 @@ func (t *trieNode) add(key, val string, priority int, r *genericReplacer) {
t.next = next
next.add(key[n:], val, priority, r)
}
- } else if t.table != nil {
+ return
+ }
+
+ if t.table != nil {
// Insert into existing table.
m := r.mapping[key[0]]
if t.table[m] == nil {
t.table[m] = new(trieNode)
}
t.table[m].add(key[1:], val, priority, r)
- } else {
- t.prefix = key
- t.next = new(trieNode)
- t.next.add("", val, priority, r)
+ return
}
+
+ t.prefix = key
+ t.next = new(trieNode)
+ t.next.add("", val, priority, r)
}
// genericReplacer is the fully generic algorithm.
@@ -242,7 +246,6 @@ func (r *genericReplacer) Replace(s string) string {
return string(buf)
}
-//nolint:gocognit // TODO(ldez) must be fixed.
func (r *genericReplacer) WriteString(w io.Writer, s string) (n int, err error) {
sw := getStringWriter(w)
var last, wn int
diff --git a/vendor/github.com/golangci/misspell/url.go b/vendor/github.com/golangci/misspell/url.go
index 203b91a79..a91d1d967 100644
--- a/vendor/github.com/golangci/misspell/url.go
+++ b/vendor/github.com/golangci/misspell/url.go
@@ -10,7 +10,7 @@ import (
// @(https?|ftp)://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?$@iS.
var reURL = regexp.MustCompile(`(?i)(https?|ftp)://(-\.)?([^\s/?.#]+\.?)+(/\S*)?`)
-// StripURL attemps to replace URLs with blank spaces, e.g.
+// StripURL attempts to replace URLs with blank spaces, e.g.
//
// "xxx http://foo.com/ yyy -> "xxx yyyy".
func StripURL(s string) string {
diff --git a/vendor/github.com/golangci/modinfo/.gitignore b/vendor/github.com/golangci/modinfo/.gitignore
new file mode 100644
index 000000000..9f11b755a
--- /dev/null
+++ b/vendor/github.com/golangci/modinfo/.gitignore
@@ -0,0 +1 @@
+.idea/
diff --git a/vendor/github.com/golangci/modinfo/.golangci.yml b/vendor/github.com/golangci/modinfo/.golangci.yml
new file mode 100644
index 000000000..9698182f2
--- /dev/null
+++ b/vendor/github.com/golangci/modinfo/.golangci.yml
@@ -0,0 +1,157 @@
+run:
+ timeout: 7m
+
+linters-settings:
+ govet:
+ enable:
+ - shadow
+ gocyclo:
+ min-complexity: 12
+ goconst:
+ min-len: 3
+ min-occurrences: 3
+ funlen:
+ lines: -1
+ statements: 50
+ misspell:
+ locale: US
+ depguard:
+ rules:
+ main:
+ deny:
+ - pkg: "github.com/instana/testify"
+ desc: not allowed
+ - pkg: "github.com/pkg/errors"
+ desc: Should be replaced by standard lib errors package
+ tagalign:
+ align: false
+ order:
+ - xml
+ - json
+ - yaml
+ - yml
+ - toml
+ - mapstructure
+ - url
+ godox:
+ keywords:
+ - FIXME
+ gocritic:
+ enabled-tags:
+ - diagnostic
+ - style
+ - performance
+ disabled-checks:
+ - paramTypeCombine # already handle by gofumpt.extra-rules
+ - whyNoLint # already handle by nonolint
+ - unnamedResult
+ - hugeParam
+ - sloppyReassign
+ - rangeValCopy
+ - octalLiteral
+ - ptrToRefParam
+ - appendAssign
+ - ruleguard
+ - httpNoBody
+ - exposedSyncMutex
+ revive:
+ rules:
+ - name: struct-tag
+ - name: blank-imports
+ - name: context-as-argument
+ - name: context-keys-type
+ - name: dot-imports
+ - name: error-return
+ - name: error-strings
+ - name: error-naming
+ - name: exported
+ disabled: true
+ - name: if-return
+ - name: increment-decrement
+ - name: var-naming
+ - name: var-declaration
+ - name: package-comments
+ disabled: true
+ - name: range
+ - name: receiver-naming
+ - name: time-naming
+ - name: unexported-return
+ - name: indent-error-flow
+ - name: errorf
+ - name: empty-block
+ - name: superfluous-else
+ - name: unused-parameter
+ disabled: true
+ - name: unreachable-code
+ - name: redefines-builtin-id
+
+ tagliatelle:
+ case:
+ rules:
+ json: pascal
+ yaml: camel
+ xml: camel
+ header: header
+ mapstructure: camel
+ env: upperSnake
+ envconfig: upperSnake
+
+linters:
+ enable-all: true
+ disable:
+ - deadcode # deprecated
+ - exhaustivestruct # deprecated
+ - golint # deprecated
+ - ifshort # deprecated
+ - interfacer # deprecated
+ - maligned # deprecated
+ - nosnakecase # deprecated
+ - scopelint # deprecated
+ - structcheck # deprecated
+ - varcheck # deprecated
+ - cyclop # duplicate of gocyclo
+ - sqlclosecheck # not relevant (SQL)
+ - rowserrcheck # not relevant (SQL)
+ - execinquery # not relevant (SQL)
+ - lll
+ - gosec
+ - dupl # not relevant
+ - prealloc # too many false-positive
+ - bodyclose # too many false-positive
+ - gomnd
+ - testpackage # not relevant
+ - tparallel # not relevant
+ - paralleltest # not relevant
+ - nestif # too many false-positive
+ - wrapcheck
+ - goerr113 # not relevant
+ - nlreturn # not relevant
+ - wsl # not relevant
+ - exhaustive # not relevant
+ - exhaustruct # not relevant
+ - makezero # not relevant
+ - forbidigo
+ - varnamelen # not relevant
+ - nilnil # not relevant
+ - ireturn # not relevant
+ - contextcheck # too many false-positive
+ - tenv # we already have a test "framework" to handle env vars
+ - noctx
+ - errchkjson
+ - nonamedreturns
+ - gosmopolitan # not relevant
+ - gochecknoglobals
+
+issues:
+ exclude-use-default: false
+ max-issues-per-linter: 0
+ max-same-issues: 0
+ exclude:
+ - 'Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked'
+ - 'ST1000: at least one file in a package should have a package comment'
+ exclude-rules:
+ - path: (.+)_test.go
+ linters:
+ - funlen
+ - goconst
+ - maintidx
diff --git a/vendor/github.com/golangci/modinfo/LICENSE b/vendor/github.com/golangci/modinfo/LICENSE
new file mode 100644
index 000000000..f288702d2
--- /dev/null
+++ b/vendor/github.com/golangci/modinfo/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/vendor/github.com/golangci/modinfo/Makefile b/vendor/github.com/golangci/modinfo/Makefile
new file mode 100644
index 000000000..df91018f1
--- /dev/null
+++ b/vendor/github.com/golangci/modinfo/Makefile
@@ -0,0 +1,12 @@
+.PHONY: clean check test
+
+default: clean check test
+
+clean:
+ rm -rf dist/ cover.out
+
+test: clean
+ go test -v -cover ./...
+
+check:
+ golangci-lint run
diff --git a/vendor/github.com/golangci/modinfo/module.go b/vendor/github.com/golangci/modinfo/module.go
new file mode 100644
index 000000000..ff0b21b9b
--- /dev/null
+++ b/vendor/github.com/golangci/modinfo/module.go
@@ -0,0 +1,157 @@
+package modinfo
+
+import (
+ "bytes"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "reflect"
+ "sort"
+ "strings"
+ "sync"
+
+ "golang.org/x/mod/modfile"
+ "golang.org/x/tools/go/analysis"
+)
+
+type ModInfo struct {
+ Path string `json:"Path"`
+ Dir string `json:"Dir"`
+ GoMod string `json:"GoMod"`
+ GoVersion string `json:"GoVersion"`
+ Main bool `json:"Main"`
+}
+
+var (
+ once sync.Once
+ information []ModInfo
+ errInfo error
+)
+
+var Analyzer = &analysis.Analyzer{
+ Name: "modinfo",
+ Doc: "Module information",
+ URL: "https://github.com/golangci/modinfo",
+ Run: runOnce,
+ ResultType: reflect.TypeOf([]ModInfo(nil)),
+}
+
+func runOnce(pass *analysis.Pass) (any, error) {
+ _, ok := os.LookupEnv("MODINFO_DEBUG_DISABLE_ONCE")
+ if ok {
+ return GetModuleInfo(pass)
+ }
+
+ once.Do(func() {
+ information, errInfo = GetModuleInfo(pass)
+ })
+
+ return information, errInfo
+}
+
+// GetModuleInfo gets modules information.
+// Always returns 1 element except for workspace (returns all the modules of the workspace).
+// Based on `go list -m -json` behavior.
+func GetModuleInfo(pass *analysis.Pass) ([]ModInfo, error) {
+ // https://github.com/golang/go/issues/44753#issuecomment-790089020
+ cmd := exec.Command("go", "list", "-m", "-json")
+ for _, file := range pass.Files {
+ name := pass.Fset.File(file.Pos()).Name()
+ if filepath.Ext(name) != ".go" {
+ continue
+ }
+
+ cmd.Dir = filepath.Dir(name)
+ break
+ }
+
+ out, err := cmd.Output()
+ if err != nil {
+ return nil, fmt.Errorf("command go list: %w: %s", err, string(out))
+ }
+
+ var infos []ModInfo
+
+ for dec := json.NewDecoder(bytes.NewBuffer(out)); dec.More(); {
+ var v ModInfo
+ if err := dec.Decode(&v); err != nil {
+ return nil, fmt.Errorf("unmarshaling error: %w: %s", err, string(out))
+ }
+
+ if v.GoMod == "" {
+ return nil, errors.New("working directory is not part of a module")
+ }
+
+ if !v.Main || v.Dir == "" {
+ continue
+ }
+
+ infos = append(infos, v)
+ }
+
+ if len(infos) == 0 {
+ return nil, errors.New("go.mod file not found")
+ }
+
+ sort.Slice(infos, func(i, j int) bool {
+ return len(infos[i].Path) > len(infos[j].Path)
+ })
+
+ return infos, nil
+}
+
+// FindModuleFromPass finds the module related to the files of the pass.
+func FindModuleFromPass(pass *analysis.Pass) (ModInfo, error) {
+ infos, ok := pass.ResultOf[Analyzer].([]ModInfo)
+ if !ok {
+ return ModInfo{}, errors.New("no modinfo analyzer result")
+ }
+
+ var name string
+ for _, file := range pass.Files {
+ f := pass.Fset.File(file.Pos()).Name()
+ if filepath.Ext(f) != ".go" {
+ continue
+ }
+
+ name = f
+ break
+ }
+
+ // no Go file found in analysis pass
+ if name == "" {
+ name, _ = os.Getwd()
+ }
+
+ for _, info := range infos {
+ if !strings.HasPrefix(name, info.Dir) {
+ continue
+ }
+ return info, nil
+ }
+
+ return ModInfo{}, errors.New("module information not found")
+}
+
+// ReadModuleFileFromPass read the `go.mod` file from the pass result.
+func ReadModuleFileFromPass(pass *analysis.Pass) (*modfile.File, error) {
+ info, err := FindModuleFromPass(pass)
+ if err != nil {
+ return nil, err
+ }
+
+ return ReadModuleFile(info)
+}
+
+// ReadModuleFile read the `go.mod` file.
+func ReadModuleFile(info ModInfo) (*modfile.File, error) {
+ raw, err := os.ReadFile(info.GoMod)
+ if err != nil {
+ return nil, fmt.Errorf("reading go.mod file: %w", err)
+ }
+
+ return modfile.Parse("go.mod", raw, nil)
+}
diff --git a/vendor/github.com/golangci/modinfo/readme.md b/vendor/github.com/golangci/modinfo/readme.md
new file mode 100644
index 000000000..2175de8eb
--- /dev/null
+++ b/vendor/github.com/golangci/modinfo/readme.md
@@ -0,0 +1,73 @@
+# modinfo
+
+This module contains:
+- an analyzer that returns module information.
+- methods to find and read `go.mod` file
+
+## Examples
+
+```go
+package main
+
+import (
+ "fmt"
+
+ "github.com/golangci/modinfo"
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+)
+
+var Analyzer = &analysis.Analyzer{
+ Name: "example",
+ Doc: "Example",
+ Run: func(pass *analysis.Pass) (interface{}, error) {
+ file, err := modinfo.ReadModuleFileFromPass(pass)
+ if err != nil {
+ return nil, err
+ }
+
+ fmt.Println("go.mod", file)
+
+ // TODO
+
+ return nil, nil
+ },
+ Requires: []*analysis.Analyzer{
+ inspect.Analyzer,
+ modinfo.Analyzer,
+ },
+}
+```
+
+```go
+package main
+
+import (
+ "fmt"
+
+ "github.com/golangci/modinfo"
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+)
+
+var Analyzer = &analysis.Analyzer{
+ Name: "example",
+ Doc: "Example",
+ Run: func(pass *analysis.Pass) (interface{}, error) {
+ info, err := modinfo.FindModuleFromPass(pass)
+ if err != nil {
+ return nil, err
+ }
+
+ fmt.Println("Module", info.Dir)
+
+ // TODO
+
+ return nil, nil
+ },
+ Requires: []*analysis.Analyzer{
+ inspect.Analyzer,
+ modinfo.Analyzer,
+ },
+}
+```
diff --git a/vendor/github.com/golangci/revgrep/.golangci.yml b/vendor/github.com/golangci/revgrep/.golangci.yml
index 02ed5ec84..5239720ac 100644
--- a/vendor/github.com/golangci/revgrep/.golangci.yml
+++ b/vendor/github.com/golangci/revgrep/.golangci.yml
@@ -3,7 +3,6 @@ run:
linters-settings:
govet:
- check-shadowing: true
enable-all: true
disable:
- fieldalignment
@@ -47,7 +46,6 @@ linters:
- nestif
- gomnd
- goerr113
-# - wrapcheck
- nlreturn
- wsl
- exhaustive
@@ -66,7 +64,7 @@ linters:
issues:
exclude-use-default: false
- max-per-linter: 0
+ max-issues-per-linter: 0
max-same-issues: 0
exclude:
- 'ST1000: at least one file in a package should have a package comment'
diff --git a/vendor/github.com/golangci/revgrep/revgrep.go b/vendor/github.com/golangci/revgrep/revgrep.go
index 7796b1c01..1ef81b203 100644
--- a/vendor/github.com/golangci/revgrep/revgrep.go
+++ b/vendor/github.com/golangci/revgrep/revgrep.go
@@ -334,10 +334,13 @@ func (c *Checker) linesChanged() map[string][]pos {
return changes
}
-// GitPatch returns a patch from a git repository,
-// if no git repository was found and no errors occurred, nil is returned, else an error is returned revisionFrom and revisionTo defines the git diff parameters,
-// if left blank and there are unstaged changes or untracked files, only those will be returned else only check changes since HEAD~.
-// If revisionFrom is set but revisionTo is not, untracked files will be included, to exclude untracked files set revisionTo to HEAD~.
+// GitPatch returns a patch from a git repository.
+// If no git repository was found and no errors occurred, nil is returned,
+// else an error is returned revisionFrom and revisionTo defines the git diff parameters,
+// if left blank and there are unstaged changes or untracked files,
+// only those will be returned else only check changes since HEAD~.
+// If revisionFrom is set but revisionTo is not,
+// untracked files will be included, to exclude untracked files set revisionTo to HEAD~.
// It's incorrect to specify revisionTo without a revisionFrom.
func GitPatch(revisionFrom, revisionTo string) (io.Reader, []string, error) {
// check if git repo exists
@@ -356,59 +359,59 @@ func GitPatch(revisionFrom, revisionTo string) (io.Reader, []string, error) {
for _, file := range bytes.Split(ls, []byte{'\n'}) {
if len(file) == 0 || bytes.HasSuffix(file, []byte{'/'}) {
// ls-files was sometimes showing directories when they were ignored
- // I couldn't create a test case for this as I couldn't reproduce correctly
- // for the moment, just exclude files with trailing /
+ // I couldn't create a test case for this as I couldn't reproduce correctly for the moment,
+ // just exclude files with trailing /
continue
}
+
newFiles = append(newFiles, string(file))
}
- var patch bytes.Buffer
if revisionFrom != "" {
- cmd := gitDiff(revisionFrom)
+ args := []string{revisionFrom}
+
if revisionTo != "" {
- cmd.Args = append(cmd.Args, revisionTo)
+ args = append(args, revisionTo)
}
- cmd.Args = append(cmd.Args, "--")
- cmd.Stdout = &patch
- if err := cmd.Run(); err != nil {
- return nil, nil, fmt.Errorf("error executing git diff %q %q: %w", revisionFrom, revisionTo, err)
+ args = append(args, "--")
+
+ patch, errDiff := gitDiff(args...)
+ if errDiff != nil {
+ return nil, nil, errDiff
}
if revisionTo == "" {
- return &patch, newFiles, nil
+ return patch, newFiles, nil
}
- return &patch, nil, nil
+ return patch, nil, nil
}
// make a patch for unstaged changes
- cmd := gitDiff("--")
- cmd.Stdout = &patch
- if err := cmd.Run(); err != nil {
- return nil, nil, fmt.Errorf("error executing git diff: %w", err)
+ patch, err := gitDiff("--")
+ if err != nil {
+ return nil, nil, err
}
+
unstaged := patch.Len() > 0
- // If there's unstaged changes OR untracked changes (or both), then this is
- // a suitable patch
+ // If there's unstaged changes OR untracked changes (or both),
+ // then this is a suitable patch
if unstaged || newFiles != nil {
- return &patch, newFiles, nil
+ return patch, newFiles, nil
}
// check for changes in recent commit
-
- cmd = gitDiff("HEAD~", "--")
- cmd.Stdout = &patch
- if err := cmd.Run(); err != nil {
- return nil, nil, fmt.Errorf("error executing git diff HEAD~: %w", err)
+ patch, err = gitDiff("HEAD~", "--")
+ if err != nil {
+ return nil, nil, err
}
- return &patch, nil, nil
+ return patch, nil, nil
}
-func gitDiff(extraArgs ...string) *exec.Cmd {
+func gitDiff(extraArgs ...string) (*bytes.Buffer, error) {
cmd := exec.Command("git", "diff", "--color=never", "--no-ext-diff")
if isSupportedByGit(2, 41, 0) {
@@ -418,7 +421,26 @@ func gitDiff(extraArgs ...string) *exec.Cmd {
cmd.Args = append(cmd.Args, "--relative")
cmd.Args = append(cmd.Args, extraArgs...)
- return cmd
+ patch := new(bytes.Buffer)
+ errBuff := new(bytes.Buffer)
+
+ cmd.Stdout = patch
+ cmd.Stderr = errBuff
+
+ if err := cmd.Run(); err != nil {
+ return nil, fmt.Errorf("error executing %q: %w: %w", strings.Join(cmd.Args, " "), err, readAsError(errBuff))
+ }
+
+ return patch, nil
+}
+
+func readAsError(buff io.Reader) error {
+ output, err := io.ReadAll(buff)
+ if err != nil {
+ return fmt.Errorf("read stderr: %w", err)
+ }
+
+ return errors.New(string(output))
}
func isSupportedByGit(major, minor, patch int) bool {