diff --git a/assets/linters-info.json b/assets/linters-info.json index 9717b9fbfa39..b7f7d0ff720c 100644 --- a/assets/linters-info.json +++ b/assets/linters-info.json @@ -353,6 +353,7 @@ ], "originalURL": "https://github.com/daixiang0/gci", "internal": false, + "canAutoFix": true, "isSlow": false, "since": "v1.30.0" }, @@ -449,6 +450,7 @@ ], "originalURL": "https://github.com/go-critic/go-critic", "internal": false, + "canAutoFix": true, "isSlow": true, "since": "v1.12.0" }, @@ -539,6 +541,7 @@ ], "originalURL": "https://github.com/denis-tingaikin/go-header", "internal": false, + "canAutoFix": true, "isSlow": false, "since": "v1.28.0" }, @@ -877,6 +880,7 @@ ], "originalURL": "https://github.com/butuzov/mirror", "internal": false, + "canAutoFix": true, "isSlow": true, "since": "v1.53.0" }, @@ -1500,6 +1504,7 @@ ], "originalURL": "https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md", "internal": false, + "canAutoFix": true, "isSlow": false, "since": "v1.26.0" } diff --git a/pkg/golinters/bidichk.go b/pkg/golinters/bidichk.go index ef266f55ca37..2c2c7dba6218 100644 --- a/pkg/golinters/bidichk.go +++ b/pkg/golinters/bidichk.go @@ -10,7 +10,7 @@ import ( "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() cfgMap := map[string]map[string]any{} diff --git a/pkg/golinters/bodyclose.go b/pkg/golinters/bodyclose.go index e56bd83f28cb..aab364d963ac 100644 --- a/pkg/golinters/bodyclose.go +++ b/pkg/golinters/bodyclose.go @@ -8,10 +8,12 @@ import ( ) func NewBodyclose() *goanalysis.Linter { + a := bodyclose.Analyzer + return goanalysis.NewLinter( - "bodyclose", + a.Name, "checks whether HTTP response body is closed successfully", - []*analysis.Analyzer{bodyclose.Analyzer}, + []*analysis.Analyzer{a}, nil, ).WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/errchkjson.go b/pkg/golinters/errchkjson.go index 1af4450b4e72..578b0e2e0ea2 100644 --- a/pkg/golinters/errchkjson.go +++ b/pkg/golinters/errchkjson.go @@ -8,7 +8,7 @@ import ( "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() cfgMap := map[string]map[string]any{} diff --git a/pkg/golinters/grouper.go b/pkg/golinters/grouper.go index 41761f2ae019..81afb0c7fca0 100644 --- a/pkg/golinters/grouper.go +++ b/pkg/golinters/grouper.go @@ -9,9 +9,11 @@ import ( ) func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter { + a := grouper.New() + linterCfg := map[string]map[string]any{} if settings != nil { - linterCfg["grouper"] = map[string]any{ + linterCfg[a.Name] = map[string]any{ "const-require-single-const": settings.ConstRequireSingleConst, "const-require-grouping": settings.ConstRequireGrouping, "import-require-single-import": settings.ImportRequireSingleImport, @@ -24,9 +26,9 @@ func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - "grouper", + a.Name, "Analyze expression groups.", - []*analysis.Analyzer{grouper.New()}, + []*analysis.Analyzer{a}, linterCfg, ).WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 08041dc58f95..649a82fd7545 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -37,7 +37,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithPresets(linter.PresetBugs, linter.PresetStyle). WithURL("https://github.com/tdakkota/asciicheck"), - linter.NewConfig(golinters.NewBiDiChkFuncName(&cfg.LintersSettings.BiDiChk)). + linter.NewConfig(golinters.NewBiDiChk(&cfg.LintersSettings.BiDiChk)). WithSince("1.43.0"). WithPresets(linter.PresetBugs). 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). WithURL("https://github.com/kisielk/errcheck"), - linter.NewConfig(golinters.NewErrChkJSONFuncName(&cfg.LintersSettings.ErrChkJSON)). + linter.NewConfig(golinters.NewErrChkJSON(&cfg.LintersSettings.ErrChkJSON)). WithSince("1.44.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). @@ -189,6 +189,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { linter.NewConfig(golinters.NewGci(&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)). @@ -232,6 +233,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { 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)). @@ -271,6 +273,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { linter.NewConfig(golinters.NewGoHeader(&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)). @@ -419,6 +422,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithSince("v1.53.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). + WithAutoFix(). WithURL("https://github.com/butuzov/mirror"), 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)). WithSince("v1.26.0"). WithPresets(linter.PresetStyle). + WithAutoFix(). WithURL("https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md"), }, nil } diff --git a/test/testdata/configs/decorder.yml b/test/testdata/configs/decorder_custom.yml similarity index 100% rename from test/testdata/configs/decorder.yml rename to test/testdata/configs/decorder_custom.yml diff --git a/test/testdata/configs/exclude_functions.yml b/test/testdata/configs/errcheck_exclude_functions.yml similarity index 100% rename from test/testdata/configs/exclude_functions.yml rename to test/testdata/configs/errcheck_exclude_functions.yml diff --git a/test/testdata/configs/ignore_config.yml b/test/testdata/configs/errcheck_ignore_config.yml similarity index 100% rename from test/testdata/configs/ignore_config.yml rename to test/testdata/configs/errcheck_ignore_config.yml diff --git a/test/testdata/configs/go-header-fix.yml b/test/testdata/configs/goheader-fix.yml similarity index 100% rename from test/testdata/configs/go-header-fix.yml rename to test/testdata/configs/goheader-fix.yml diff --git a/test/testdata/configs/go-header.yml b/test/testdata/configs/goheader.yml similarity index 100% rename from test/testdata/configs/go-header.yml rename to test/testdata/configs/goheader.yml diff --git a/test/testdata/configs/ireturn.yml b/test/testdata/configs/ireturn_allow.yml similarity index 100% rename from test/testdata/configs/ireturn.yml rename to test/testdata/configs/ireturn_allow.yml diff --git a/test/testdata/configs/nonamedreturns.yml b/test/testdata/configs/nonamedreturns_custom.yml similarity index 100% rename from test/testdata/configs/nonamedreturns.yml rename to test/testdata/configs/nonamedreturns_custom.yml diff --git a/test/testdata/configs/paralleltest.yml b/test/testdata/configs/paralleltest_custom.yml similarity index 100% rename from test/testdata/configs/paralleltest.yml rename to test/testdata/configs/paralleltest_custom.yml diff --git a/test/testdata/configs/predeclared.yml b/test/testdata/configs/predeclared_custom.yml similarity index 100% rename from test/testdata/configs/predeclared.yml rename to test/testdata/configs/predeclared_custom.yml diff --git a/test/testdata/decorder.go b/test/testdata/decorder.go index 5936289d42fb..04736ec32074 100644 --- a/test/testdata/decorder.go +++ b/test/testdata/decorder.go @@ -1,21 +1,21 @@ //golangcitest:args -Edecorder -//golangcitest:config_path testdata/configs/decorder.yml +//golangcitest:expected_exitcode 0 package testdata import "math" const ( - decoc = math.MaxInt64 - decod = 1 + decoh = math.MaxInt64 + decoi = 1 ) -var decoa = 1 -var decob = 1 // want "multiple \"var\" declarations are not allowed; use parentheses instead" +var decoj = 1 +var decok = 1 -type decoe int // want "type must not be placed after const" +type decol int -func decof() { - const decog = 1 +func decom() { + const decon = 1 } -func init() {} // want "init func must be the first function in file" +func init() {} diff --git a/test/testdata/decorder_custom.go b/test/testdata/decorder_custom.go new file mode 100644 index 000000000000..4379df50bc37 --- /dev/null +++ b/test/testdata/decorder_custom.go @@ -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" diff --git a/test/testdata/decorder_default.go b/test/testdata/decorder_default.go deleted file mode 100644 index 04736ec32074..000000000000 --- a/test/testdata/decorder_default.go +++ /dev/null @@ -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() {} diff --git a/test/testdata/errcheck_exclude_functions.go b/test/testdata/errcheck_exclude_functions.go index db05a34bf6e8..787b84c6a808 100644 --- a/test/testdata/errcheck_exclude_functions.go +++ b/test/testdata/errcheck_exclude_functions.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrcheck -//golangcitest:config_path testdata/configs/exclude_functions.yml +//golangcitest:config_path testdata/configs/errcheck_exclude_functions.yml package testdata import ( diff --git a/test/testdata/errcheck_ignore.go b/test/testdata/errcheck_ignore.go index ffc064775fb6..0f8e2dcd27e1 100644 --- a/test/testdata/errcheck_ignore.go +++ b/test/testdata/errcheck_ignore.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrcheck -//golangcitest:config_path testdata/configs/ignore_config.yml +//golangcitest:config_path testdata/configs/errcheck_ignore_config.yml package testdata import ( diff --git a/test/testdata/fix/in/go-header_1.go b/test/testdata/fix/in/goheader_1.go similarity index 66% rename from test/testdata/fix/in/go-header_1.go rename to test/testdata/fix/in/goheader_1.go index 7fd59b97a29c..ab8b9b3e7b02 100644 --- a/test/testdata/fix/in/go-header_1.go +++ b/test/testdata/fix/in/goheader_1.go @@ -2,5 +2,5 @@ //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/go-header-fix.yml +//golangcitest:config_path testdata/configs/goheader-fix.yml package p diff --git a/test/testdata/fix/in/go-header_2.go b/test/testdata/fix/in/goheader_2.go similarity index 72% rename from test/testdata/fix/in/go-header_2.go rename to test/testdata/fix/in/goheader_2.go index ed70ffd4ee24..f00b31ab09b6 100644 --- a/test/testdata/fix/in/go-header_2.go +++ b/test/testdata/fix/in/goheader_2.go @@ -4,5 +4,5 @@ Use of this source code is governed */ //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/go-header-fix.yml +//golangcitest:config_path testdata/configs/goheader-fix.yml package p diff --git a/test/testdata/fix/in/go-header_3.go b/test/testdata/fix/in/goheader_3.go similarity index 71% rename from test/testdata/fix/in/go-header_3.go rename to test/testdata/fix/in/goheader_3.go index 2961f0d5a9ab..4d6012bb3e6a 100644 --- a/test/testdata/fix/in/go-header_3.go +++ b/test/testdata/fix/in/goheader_3.go @@ -6,5 +6,5 @@ Use of this source code is governed by LICENSE //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/go-header-fix.yml +//golangcitest:config_path testdata/configs/goheader-fix.yml package p diff --git a/test/testdata/fix/out/go-header_1.go b/test/testdata/fix/out/goheader_1.go similarity index 74% rename from test/testdata/fix/out/go-header_1.go rename to test/testdata/fix/out/goheader_1.go index e8f7529b627c..61288e337eeb 100644 --- a/test/testdata/fix/out/go-header_1.go +++ b/test/testdata/fix/out/goheader_1.go @@ -4,5 +4,5 @@ //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/go-header-fix.yml +//golangcitest:config_path testdata/configs/goheader-fix.yml package p diff --git a/test/testdata/fix/out/go-header_2.go b/test/testdata/fix/out/goheader_2.go similarity index 73% rename from test/testdata/fix/out/go-header_2.go rename to test/testdata/fix/out/goheader_2.go index 80a336a47a8e..a09a0ba01a3a 100644 --- a/test/testdata/fix/out/go-header_2.go +++ b/test/testdata/fix/out/goheader_2.go @@ -4,5 +4,5 @@ Use of this source code is governed by LICENSE */ //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/go-header-fix.yml +//golangcitest:config_path testdata/configs/goheader-fix.yml package p diff --git a/test/testdata/fix/out/go-header_3.go b/test/testdata/fix/out/goheader_3.go similarity index 73% rename from test/testdata/fix/out/go-header_3.go rename to test/testdata/fix/out/goheader_3.go index 040cad6e8758..8b2f9c4e9f68 100644 --- a/test/testdata/fix/out/go-header_3.go +++ b/test/testdata/fix/out/goheader_3.go @@ -6,5 +6,5 @@ Use of this source code is governed by LICENSE //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/go-header-fix.yml +//golangcitest:config_path testdata/configs/goheader-fix.yml package p diff --git a/test/testdata/go-header_bad.go b/test/testdata/goheader_bad.go similarity index 64% rename from test/testdata/go-header_bad.go rename to test/testdata/goheader_bad.go index fbcf828e360e..079e803d961f 100644 --- a/test/testdata/go-header_bad.go +++ b/test/testdata/goheader_bad.go @@ -1,5 +1,5 @@ /*MY TITLE!*/ // want `Expected:TITLE\., Actual: TITLE!` //golangcitest:args -Egoheader -//golangcitest:config_path testdata/configs/go-header.yml +//golangcitest:config_path testdata/configs/goheader.yml package testdata diff --git a/test/testdata/go-header_good.go b/test/testdata/goheader_good.go similarity index 62% rename from test/testdata/go-header_good.go rename to test/testdata/goheader_good.go index 4bc199d0d6a4..e003b9491fd2 100644 --- a/test/testdata/go-header_good.go +++ b/test/testdata/goheader_good.go @@ -1,6 +1,6 @@ /*MY TITLE.*/ //golangcitest:args -Egoheader -//golangcitest:config_path testdata/configs/go-header.yml +//golangcitest:config_path testdata/configs/goheader.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/ireturn_default.go b/test/testdata/ireturn.go similarity index 100% rename from test/testdata/ireturn_default.go rename to test/testdata/ireturn.go diff --git a/test/testdata/ireturn_allow.go b/test/testdata/ireturn_allow.go index 0ffc4d75f85a..8a7c6075d098 100644 --- a/test/testdata/ireturn_allow.go +++ b/test/testdata/ireturn_allow.go @@ -1,5 +1,5 @@ //golangcitest:args -Eireturn -//golangcitest:config_path testdata/configs/ireturn.yml +//golangcitest:config_path testdata/configs/ireturn_allow.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/lll_multi_import.go b/test/testdata/lll_import_multi.go similarity index 100% rename from test/testdata/lll_multi_import.go rename to test/testdata/lll_import_multi.go diff --git a/test/testdata/lll_single_import.go b/test/testdata/lll_import_single.go similarity index 100% rename from test/testdata/lll_single_import.go rename to test/testdata/lll_import_single.go diff --git a/test/testdata/nonamedreturns_custom.go b/test/testdata/nonamedreturns_custom.go index b42927086be6..3218f6ea8f9b 100644 --- a/test/testdata/nonamedreturns_custom.go +++ b/test/testdata/nonamedreturns_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Enonamedreturns -//golangcitest:config_path testdata/configs/nonamedreturns.yml +//golangcitest:config_path testdata/configs/nonamedreturns_custom.yml package testdata import "fmt" diff --git a/test/testdata/paralleltest_custom.go b/test/testdata/paralleltest_custom.go index 01ed6b610894..f896edf279ba 100644 --- a/test/testdata/paralleltest_custom.go +++ b/test/testdata/paralleltest_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Eparalleltest -//golangcitest:config_path testdata/configs/paralleltest.yml +//golangcitest:config_path testdata/configs/paralleltest_custom.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/predeclared_custom.go b/test/testdata/predeclared_custom.go index 6b54b5b8d3c5..560f63da0633 100644 --- a/test/testdata/predeclared_custom.go +++ b/test/testdata/predeclared_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Epredeclared -//golangcitest:config_path testdata/configs/predeclared.yml +//golangcitest:config_path testdata/configs/predeclared_custom.yml package testdata func hello() { diff --git a/test/testdata/spancheck/configs/enable_all.yml b/test/testdata/spancheck/configs/spancheck_enable_all.yml similarity index 100% rename from test/testdata/spancheck/configs/enable_all.yml rename to test/testdata/spancheck/configs/spancheck_enable_all.yml diff --git a/test/testdata/spancheck/spancheck_enable_all.go b/test/testdata/spancheck/spancheck_enable_all.go index 382e714043e4..38cce01900d2 100644 --- a/test/testdata/spancheck/spancheck_enable_all.go +++ b/test/testdata/spancheck/spancheck_enable_all.go @@ -1,4 +1,4 @@ -//golangcitest:config_path configs/enable_all.yml +//golangcitest:config_path configs/spancheck_enable_all.yml //golangcitest:args -Espancheck package spancheck diff --git a/test/testdata/tenv_go118.go b/test/testdata/tenv_fuzz.go similarity index 95% rename from test/testdata/tenv_go118.go rename to test/testdata/tenv_fuzz.go index 97a3489319bd..02d2ca48ae86 100644 --- a/test/testdata/tenv_go118.go +++ b/test/testdata/tenv_fuzz.go @@ -1,5 +1,3 @@ -//go:build go1.18 - //golangcitest:args -Etenv package testdata diff --git a/test/testdata/testifylint_bool_compare.go b/test/testdata/testifylint_bool_compare_only.go similarity index 100% rename from test/testdata/testifylint_bool_compare.go rename to test/testdata/testifylint_bool_compare_only.go diff --git a/test/testdata/testifylint_require_error.go b/test/testdata/testifylint_require_error_only.go similarity index 100% rename from test/testdata/testifylint_require_error.go rename to test/testdata/testifylint_require_error_only.go diff --git a/test/testdata/thelper_go118.go b/test/testdata/thelper_fuzz.go similarity index 96% rename from test/testdata/thelper_go118.go rename to test/testdata/thelper_fuzz.go index e83a387a5b0c..014cf4bf05bd 100644 --- a/test/testdata/thelper_go118.go +++ b/test/testdata/thelper_fuzz.go @@ -1,5 +1,3 @@ -//go:build go1.18 - //golangcitest:args -Ethelper package testdata