dev: minor clean up (#4577)

This commit is contained in:
Ludovic Fernandez 2024-03-26 15:50:23 +01:00 committed by GitHub
parent 840ef6229a
commit 085ac85a4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
41 changed files with 68 additions and 58 deletions

View File

@ -353,6 +353,7 @@
], ],
"originalURL": "https://github.com/daixiang0/gci", "originalURL": "https://github.com/daixiang0/gci",
"internal": false, "internal": false,
"canAutoFix": true,
"isSlow": false, "isSlow": false,
"since": "v1.30.0" "since": "v1.30.0"
}, },
@ -449,6 +450,7 @@
], ],
"originalURL": "https://github.com/go-critic/go-critic", "originalURL": "https://github.com/go-critic/go-critic",
"internal": false, "internal": false,
"canAutoFix": true,
"isSlow": true, "isSlow": true,
"since": "v1.12.0" "since": "v1.12.0"
}, },
@ -539,6 +541,7 @@
], ],
"originalURL": "https://github.com/denis-tingaikin/go-header", "originalURL": "https://github.com/denis-tingaikin/go-header",
"internal": false, "internal": false,
"canAutoFix": true,
"isSlow": false, "isSlow": false,
"since": "v1.28.0" "since": "v1.28.0"
}, },
@ -877,6 +880,7 @@
], ],
"originalURL": "https://github.com/butuzov/mirror", "originalURL": "https://github.com/butuzov/mirror",
"internal": false, "internal": false,
"canAutoFix": true,
"isSlow": true, "isSlow": true,
"since": "v1.53.0" "since": "v1.53.0"
}, },
@ -1500,6 +1504,7 @@
], ],
"originalURL": "https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md", "originalURL": "https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md",
"internal": false, "internal": false,
"canAutoFix": true,
"isSlow": false, "isSlow": false,
"since": "v1.26.0" "since": "v1.26.0"
} }

View File

@ -10,7 +10,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis" "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
) )
func NewBiDiChkFuncName(cfg *config.BiDiChkSettings) *goanalysis.Linter { func NewBiDiChk(cfg *config.BiDiChkSettings) *goanalysis.Linter {
a := bidichk.NewAnalyzer() a := bidichk.NewAnalyzer()
cfgMap := map[string]map[string]any{} cfgMap := map[string]map[string]any{}

View File

@ -8,10 +8,12 @@ import (
) )
func NewBodyclose() *goanalysis.Linter { func NewBodyclose() *goanalysis.Linter {
a := bodyclose.Analyzer
return goanalysis.NewLinter( return goanalysis.NewLinter(
"bodyclose", a.Name,
"checks whether HTTP response body is closed successfully", "checks whether HTTP response body is closed successfully",
[]*analysis.Analyzer{bodyclose.Analyzer}, []*analysis.Analyzer{a},
nil, nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo) ).WithLoadMode(goanalysis.LoadModeTypesInfo)
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis" "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
) )
func NewErrChkJSONFuncName(cfg *config.ErrChkJSONSettings) *goanalysis.Linter { func NewErrChkJSON(cfg *config.ErrChkJSONSettings) *goanalysis.Linter {
a := errchkjson.NewAnalyzer() a := errchkjson.NewAnalyzer()
cfgMap := map[string]map[string]any{} cfgMap := map[string]map[string]any{}

View File

@ -9,9 +9,11 @@ import (
) )
func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter { func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter {
a := grouper.New()
linterCfg := map[string]map[string]any{} linterCfg := map[string]map[string]any{}
if settings != nil { if settings != nil {
linterCfg["grouper"] = map[string]any{ linterCfg[a.Name] = map[string]any{
"const-require-single-const": settings.ConstRequireSingleConst, "const-require-single-const": settings.ConstRequireSingleConst,
"const-require-grouping": settings.ConstRequireGrouping, "const-require-grouping": settings.ConstRequireGrouping,
"import-require-single-import": settings.ImportRequireSingleImport, "import-require-single-import": settings.ImportRequireSingleImport,
@ -24,9 +26,9 @@ func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter {
} }
return goanalysis.NewLinter( return goanalysis.NewLinter(
"grouper", a.Name,
"Analyze expression groups.", "Analyze expression groups.",
[]*analysis.Analyzer{grouper.New()}, []*analysis.Analyzer{a},
linterCfg, linterCfg,
).WithLoadMode(goanalysis.LoadModeSyntax) ).WithLoadMode(goanalysis.LoadModeSyntax)
} }

View File

@ -37,7 +37,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithPresets(linter.PresetBugs, linter.PresetStyle). WithPresets(linter.PresetBugs, linter.PresetStyle).
WithURL("https://github.com/tdakkota/asciicheck"), WithURL("https://github.com/tdakkota/asciicheck"),
linter.NewConfig(golinters.NewBiDiChkFuncName(&cfg.LintersSettings.BiDiChk)). linter.NewConfig(golinters.NewBiDiChk(&cfg.LintersSettings.BiDiChk)).
WithSince("1.43.0"). WithSince("1.43.0").
WithPresets(linter.PresetBugs). WithPresets(linter.PresetBugs).
WithURL("https://github.com/breml/bidichk"), WithURL("https://github.com/breml/bidichk"),
@ -117,7 +117,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithPresets(linter.PresetBugs, linter.PresetError). WithPresets(linter.PresetBugs, linter.PresetError).
WithURL("https://github.com/kisielk/errcheck"), WithURL("https://github.com/kisielk/errcheck"),
linter.NewConfig(golinters.NewErrChkJSONFuncName(&cfg.LintersSettings.ErrChkJSON)). linter.NewConfig(golinters.NewErrChkJSON(&cfg.LintersSettings.ErrChkJSON)).
WithSince("1.44.0"). WithSince("1.44.0").
WithPresets(linter.PresetBugs). WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis(). WithLoadForGoAnalysis().
@ -189,6 +189,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
linter.NewConfig(golinters.NewGci(&cfg.LintersSettings.Gci)). linter.NewConfig(golinters.NewGci(&cfg.LintersSettings.Gci)).
WithSince("v1.30.0"). WithSince("v1.30.0").
WithPresets(linter.PresetFormatting, linter.PresetImport). WithPresets(linter.PresetFormatting, linter.PresetImport).
WithAutoFix().
WithURL("https://github.com/daixiang0/gci"), WithURL("https://github.com/daixiang0/gci"),
linter.NewConfig(golinters.NewGinkgoLinter(&cfg.LintersSettings.GinkgoLinter)). linter.NewConfig(golinters.NewGinkgoLinter(&cfg.LintersSettings.GinkgoLinter)).
@ -232,6 +233,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithSince("v1.12.0"). WithSince("v1.12.0").
WithPresets(linter.PresetStyle, linter.PresetMetaLinter). WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
WithLoadForGoAnalysis(). WithLoadForGoAnalysis().
WithAutoFix().
WithURL("https://github.com/go-critic/go-critic"), WithURL("https://github.com/go-critic/go-critic"),
linter.NewConfig(golinters.NewGocyclo(&cfg.LintersSettings.Gocyclo)). linter.NewConfig(golinters.NewGocyclo(&cfg.LintersSettings.Gocyclo)).
@ -271,6 +273,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
linter.NewConfig(golinters.NewGoHeader(&cfg.LintersSettings.Goheader)). linter.NewConfig(golinters.NewGoHeader(&cfg.LintersSettings.Goheader)).
WithSince("v1.28.0"). WithSince("v1.28.0").
WithPresets(linter.PresetStyle). WithPresets(linter.PresetStyle).
WithAutoFix().
WithURL("https://github.com/denis-tingaikin/go-header"), WithURL("https://github.com/denis-tingaikin/go-header"),
linter.NewConfig(golinters.NewGoimports(&cfg.LintersSettings.Goimports)). linter.NewConfig(golinters.NewGoimports(&cfg.LintersSettings.Goimports)).
@ -419,6 +422,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithSince("v1.53.0"). WithSince("v1.53.0").
WithPresets(linter.PresetStyle). WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis(). WithLoadForGoAnalysis().
WithAutoFix().
WithURL("https://github.com/butuzov/mirror"), WithURL("https://github.com/butuzov/mirror"),
linter.NewConfig(golinters.NewMisspell(&cfg.LintersSettings.Misspell)). linter.NewConfig(golinters.NewMisspell(&cfg.LintersSettings.Misspell)).
@ -706,6 +710,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
linter.NewConfig(golinters.NewNoLintLint(&cfg.LintersSettings.NoLintLint)). linter.NewConfig(golinters.NewNoLintLint(&cfg.LintersSettings.NoLintLint)).
WithSince("v1.26.0"). WithSince("v1.26.0").
WithPresets(linter.PresetStyle). WithPresets(linter.PresetStyle).
WithAutoFix().
WithURL("https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md"), WithURL("https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md"),
}, nil }, nil
} }

View File

@ -1,21 +1,21 @@
//golangcitest:args -Edecorder //golangcitest:args -Edecorder
//golangcitest:config_path testdata/configs/decorder.yml //golangcitest:expected_exitcode 0
package testdata package testdata
import "math" import "math"
const ( const (
decoc = math.MaxInt64 decoh = math.MaxInt64
decod = 1 decoi = 1
) )
var decoa = 1 var decoj = 1
var decob = 1 // want "multiple \"var\" declarations are not allowed; use parentheses instead" var decok = 1
type decoe int // want "type must not be placed after const" type decol int
func decof() { func decom() {
const decog = 1 const decon = 1
} }
func init() {} // want "init func must be the first function in file" func init() {}

21
test/testdata/decorder_custom.go vendored Normal file
View File

@ -0,0 +1,21 @@
//golangcitest:args -Edecorder
//golangcitest:config_path testdata/configs/decorder_custom.yml
package testdata
import "math"
const (
decoc = math.MaxInt64
decod = 1
)
var decoa = 1
var decob = 1 // want "multiple \"var\" declarations are not allowed; use parentheses instead"
type decoe int // want "type must not be placed after const"
func decof() {
const decog = 1
}
func init() {} // want "init func must be the first function in file"

View File

@ -1,21 +0,0 @@
//golangcitest:args -Edecorder
//golangcitest:expected_exitcode 0
package testdata
import "math"
const (
decoh = math.MaxInt64
decoi = 1
)
var decoj = 1
var decok = 1
type decol int
func decom() {
const decon = 1
}
func init() {}

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrcheck //golangcitest:args -Eerrcheck
//golangcitest:config_path testdata/configs/exclude_functions.yml //golangcitest:config_path testdata/configs/errcheck_exclude_functions.yml
package testdata package testdata
import ( import (

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eerrcheck //golangcitest:args -Eerrcheck
//golangcitest:config_path testdata/configs/ignore_config.yml //golangcitest:config_path testdata/configs/errcheck_ignore_config.yml
package testdata package testdata
import ( import (

View File

@ -2,5 +2,5 @@
//golangcitest:args -Egoheader //golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml //golangcitest:config_path testdata/configs/goheader-fix.yml
package p package p

View File

@ -4,5 +4,5 @@ Use of this source code is governed */
//golangcitest:args -Egoheader //golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml //golangcitest:config_path testdata/configs/goheader-fix.yml
package p package p

View File

@ -6,5 +6,5 @@ Use of this source code is governed by LICENSE
//golangcitest:args -Egoheader //golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml //golangcitest:config_path testdata/configs/goheader-fix.yml
package p package p

View File

@ -4,5 +4,5 @@
//golangcitest:args -Egoheader //golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml //golangcitest:config_path testdata/configs/goheader-fix.yml
package p package p

View File

@ -4,5 +4,5 @@ Use of this source code is governed by LICENSE */
//golangcitest:args -Egoheader //golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml //golangcitest:config_path testdata/configs/goheader-fix.yml
package p package p

View File

@ -6,5 +6,5 @@ Use of this source code is governed by LICENSE
//golangcitest:args -Egoheader //golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml //golangcitest:config_path testdata/configs/goheader-fix.yml
package p package p

View File

@ -1,5 +1,5 @@
/*MY TITLE!*/ // want `Expected:TITLE\., Actual: TITLE!` /*MY TITLE!*/ // want `Expected:TITLE\., Actual: TITLE!`
//golangcitest:args -Egoheader //golangcitest:args -Egoheader
//golangcitest:config_path testdata/configs/go-header.yml //golangcitest:config_path testdata/configs/goheader.yml
package testdata package testdata

View File

@ -1,6 +1,6 @@
/*MY TITLE.*/ /*MY TITLE.*/
//golangcitest:args -Egoheader //golangcitest:args -Egoheader
//golangcitest:config_path testdata/configs/go-header.yml //golangcitest:config_path testdata/configs/goheader.yml
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
package testdata package testdata

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eireturn //golangcitest:args -Eireturn
//golangcitest:config_path testdata/configs/ireturn.yml //golangcitest:config_path testdata/configs/ireturn_allow.yml
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
package testdata package testdata

View File

@ -1,5 +1,5 @@
//golangcitest:args -Enonamedreturns //golangcitest:args -Enonamedreturns
//golangcitest:config_path testdata/configs/nonamedreturns.yml //golangcitest:config_path testdata/configs/nonamedreturns_custom.yml
package testdata package testdata
import "fmt" import "fmt"

View File

@ -1,5 +1,5 @@
//golangcitest:args -Eparalleltest //golangcitest:args -Eparalleltest
//golangcitest:config_path testdata/configs/paralleltest.yml //golangcitest:config_path testdata/configs/paralleltest_custom.yml
//golangcitest:expected_exitcode 0 //golangcitest:expected_exitcode 0
package testdata package testdata

View File

@ -1,5 +1,5 @@
//golangcitest:args -Epredeclared //golangcitest:args -Epredeclared
//golangcitest:config_path testdata/configs/predeclared.yml //golangcitest:config_path testdata/configs/predeclared_custom.yml
package testdata package testdata
func hello() { func hello() {

View File

@ -1,4 +1,4 @@
//golangcitest:config_path configs/enable_all.yml //golangcitest:config_path configs/spancheck_enable_all.yml
//golangcitest:args -Espancheck //golangcitest:args -Espancheck
package spancheck package spancheck

View File

@ -1,5 +1,3 @@
//go:build go1.18
//golangcitest:args -Etenv //golangcitest:args -Etenv
package testdata package testdata

View File

@ -1,5 +1,3 @@
//go:build go1.18
//golangcitest:args -Ethelper //golangcitest:args -Ethelper
package testdata package testdata