Skip to content

Commit 085ac85

Browse files
authored
dev: minor clean up (#4577)
1 parent 840ef62 commit 085ac85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+68
-58
lines changed

assets/linters-info.json

+5
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@
353353
],
354354
"originalURL": "https://github.com/daixiang0/gci",
355355
"internal": false,
356+
"canAutoFix": true,
356357
"isSlow": false,
357358
"since": "v1.30.0"
358359
},
@@ -449,6 +450,7 @@
449450
],
450451
"originalURL": "https://github.com/go-critic/go-critic",
451452
"internal": false,
453+
"canAutoFix": true,
452454
"isSlow": true,
453455
"since": "v1.12.0"
454456
},
@@ -539,6 +541,7 @@
539541
],
540542
"originalURL": "https://github.com/denis-tingaikin/go-header",
541543
"internal": false,
544+
"canAutoFix": true,
542545
"isSlow": false,
543546
"since": "v1.28.0"
544547
},
@@ -877,6 +880,7 @@
877880
],
878881
"originalURL": "https://github.com/butuzov/mirror",
879882
"internal": false,
883+
"canAutoFix": true,
880884
"isSlow": true,
881885
"since": "v1.53.0"
882886
},
@@ -1500,6 +1504,7 @@
15001504
],
15011505
"originalURL": "https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md",
15021506
"internal": false,
1507+
"canAutoFix": true,
15031508
"isSlow": false,
15041509
"since": "v1.26.0"
15051510
}

pkg/golinters/bidichk.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
1111
)
1212

13-
func NewBiDiChkFuncName(cfg *config.BiDiChkSettings) *goanalysis.Linter {
13+
func NewBiDiChk(cfg *config.BiDiChkSettings) *goanalysis.Linter {
1414
a := bidichk.NewAnalyzer()
1515

1616
cfgMap := map[string]map[string]any{}

pkg/golinters/bodyclose.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import (
88
)
99

1010
func NewBodyclose() *goanalysis.Linter {
11+
a := bodyclose.Analyzer
12+
1113
return goanalysis.NewLinter(
12-
"bodyclose",
14+
a.Name,
1315
"checks whether HTTP response body is closed successfully",
14-
[]*analysis.Analyzer{bodyclose.Analyzer},
16+
[]*analysis.Analyzer{a},
1517
nil,
1618
).WithLoadMode(goanalysis.LoadModeTypesInfo)
1719
}

pkg/golinters/errchkjson.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
99
)
1010

11-
func NewErrChkJSONFuncName(cfg *config.ErrChkJSONSettings) *goanalysis.Linter {
11+
func NewErrChkJSON(cfg *config.ErrChkJSONSettings) *goanalysis.Linter {
1212
a := errchkjson.NewAnalyzer()
1313

1414
cfgMap := map[string]map[string]any{}

pkg/golinters/grouper.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import (
99
)
1010

1111
func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter {
12+
a := grouper.New()
13+
1214
linterCfg := map[string]map[string]any{}
1315
if settings != nil {
14-
linterCfg["grouper"] = map[string]any{
16+
linterCfg[a.Name] = map[string]any{
1517
"const-require-single-const": settings.ConstRequireSingleConst,
1618
"const-require-grouping": settings.ConstRequireGrouping,
1719
"import-require-single-import": settings.ImportRequireSingleImport,
@@ -24,9 +26,9 @@ func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter {
2426
}
2527

2628
return goanalysis.NewLinter(
27-
"grouper",
29+
a.Name,
2830
"Analyze expression groups.",
29-
[]*analysis.Analyzer{grouper.New()},
31+
[]*analysis.Analyzer{a},
3032
linterCfg,
3133
).WithLoadMode(goanalysis.LoadModeSyntax)
3234
}

pkg/lint/lintersdb/builder_linter.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
3737
WithPresets(linter.PresetBugs, linter.PresetStyle).
3838
WithURL("https://github.com/tdakkota/asciicheck"),
3939

40-
linter.NewConfig(golinters.NewBiDiChkFuncName(&cfg.LintersSettings.BiDiChk)).
40+
linter.NewConfig(golinters.NewBiDiChk(&cfg.LintersSettings.BiDiChk)).
4141
WithSince("1.43.0").
4242
WithPresets(linter.PresetBugs).
4343
WithURL("https://github.com/breml/bidichk"),
@@ -117,7 +117,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
117117
WithPresets(linter.PresetBugs, linter.PresetError).
118118
WithURL("https://github.com/kisielk/errcheck"),
119119

120-
linter.NewConfig(golinters.NewErrChkJSONFuncName(&cfg.LintersSettings.ErrChkJSON)).
120+
linter.NewConfig(golinters.NewErrChkJSON(&cfg.LintersSettings.ErrChkJSON)).
121121
WithSince("1.44.0").
122122
WithPresets(linter.PresetBugs).
123123
WithLoadForGoAnalysis().
@@ -189,6 +189,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
189189
linter.NewConfig(golinters.NewGci(&cfg.LintersSettings.Gci)).
190190
WithSince("v1.30.0").
191191
WithPresets(linter.PresetFormatting, linter.PresetImport).
192+
WithAutoFix().
192193
WithURL("https://github.com/daixiang0/gci"),
193194

194195
linter.NewConfig(golinters.NewGinkgoLinter(&cfg.LintersSettings.GinkgoLinter)).
@@ -232,6 +233,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
232233
WithSince("v1.12.0").
233234
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
234235
WithLoadForGoAnalysis().
236+
WithAutoFix().
235237
WithURL("https://github.com/go-critic/go-critic"),
236238

237239
linter.NewConfig(golinters.NewGocyclo(&cfg.LintersSettings.Gocyclo)).
@@ -271,6 +273,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
271273
linter.NewConfig(golinters.NewGoHeader(&cfg.LintersSettings.Goheader)).
272274
WithSince("v1.28.0").
273275
WithPresets(linter.PresetStyle).
276+
WithAutoFix().
274277
WithURL("https://github.com/denis-tingaikin/go-header"),
275278

276279
linter.NewConfig(golinters.NewGoimports(&cfg.LintersSettings.Goimports)).
@@ -419,6 +422,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
419422
WithSince("v1.53.0").
420423
WithPresets(linter.PresetStyle).
421424
WithLoadForGoAnalysis().
425+
WithAutoFix().
422426
WithURL("https://github.com/butuzov/mirror"),
423427

424428
linter.NewConfig(golinters.NewMisspell(&cfg.LintersSettings.Misspell)).
@@ -706,6 +710,7 @@ func (b LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
706710
linter.NewConfig(golinters.NewNoLintLint(&cfg.LintersSettings.NoLintLint)).
707711
WithSince("v1.26.0").
708712
WithPresets(linter.PresetStyle).
713+
WithAutoFix().
709714
WithURL("https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md"),
710715
}, nil
711716
}

test/testdata/decorder.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
//golangcitest:args -Edecorder
2-
//golangcitest:config_path testdata/configs/decorder.yml
2+
//golangcitest:expected_exitcode 0
33
package testdata
44

55
import "math"
66

77
const (
8-
decoc = math.MaxInt64
9-
decod = 1
8+
decoh = math.MaxInt64
9+
decoi = 1
1010
)
1111

12-
var decoa = 1
13-
var decob = 1 // want "multiple \"var\" declarations are not allowed; use parentheses instead"
12+
var decoj = 1
13+
var decok = 1
1414

15-
type decoe int // want "type must not be placed after const"
15+
type decol int
1616

17-
func decof() {
18-
const decog = 1
17+
func decom() {
18+
const decon = 1
1919
}
2020

21-
func init() {} // want "init func must be the first function in file"
21+
func init() {}

test/testdata/decorder_custom.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//golangcitest:args -Edecorder
2+
//golangcitest:config_path testdata/configs/decorder_custom.yml
3+
package testdata
4+
5+
import "math"
6+
7+
const (
8+
decoc = math.MaxInt64
9+
decod = 1
10+
)
11+
12+
var decoa = 1
13+
var decob = 1 // want "multiple \"var\" declarations are not allowed; use parentheses instead"
14+
15+
type decoe int // want "type must not be placed after const"
16+
17+
func decof() {
18+
const decog = 1
19+
}
20+
21+
func init() {} // want "init func must be the first function in file"

test/testdata/decorder_default.go

-21
This file was deleted.

test/testdata/errcheck_exclude_functions.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Eerrcheck
2-
//golangcitest:config_path testdata/configs/exclude_functions.yml
2+
//golangcitest:config_path testdata/configs/errcheck_exclude_functions.yml
33
package testdata
44

55
import (

test/testdata/errcheck_ignore.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Eerrcheck
2-
//golangcitest:config_path testdata/configs/ignore_config.yml
2+
//golangcitest:config_path testdata/configs/errcheck_ignore_config.yml
33
package testdata
44

55
import (

test/testdata/fix/in/go-header_1.go renamed to test/testdata/fix/in/goheader_1.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
//golangcitest:args -Egoheader
44
//golangcitest:expected_exitcode 0
5-
//golangcitest:config_path testdata/configs/go-header-fix.yml
5+
//golangcitest:config_path testdata/configs/goheader-fix.yml
66
package p

test/testdata/fix/in/go-header_2.go renamed to test/testdata/fix/in/goheader_2.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Use of this source code is governed */
44

55
//golangcitest:args -Egoheader
66
//golangcitest:expected_exitcode 0
7-
//golangcitest:config_path testdata/configs/go-header-fix.yml
7+
//golangcitest:config_path testdata/configs/goheader-fix.yml
88
package p

test/testdata/fix/in/go-header_3.go renamed to test/testdata/fix/in/goheader_3.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ Use of this source code is governed by LICENSE
66

77
//golangcitest:args -Egoheader
88
//golangcitest:expected_exitcode 0
9-
//golangcitest:config_path testdata/configs/go-header-fix.yml
9+
//golangcitest:config_path testdata/configs/goheader-fix.yml
1010
package p

test/testdata/fix/out/go-header_1.go renamed to test/testdata/fix/out/goheader_1.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
//golangcitest:args -Egoheader
66
//golangcitest:expected_exitcode 0
7-
//golangcitest:config_path testdata/configs/go-header-fix.yml
7+
//golangcitest:config_path testdata/configs/goheader-fix.yml
88
package p

test/testdata/fix/out/go-header_2.go renamed to test/testdata/fix/out/goheader_2.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Use of this source code is governed by LICENSE */
44

55
//golangcitest:args -Egoheader
66
//golangcitest:expected_exitcode 0
7-
//golangcitest:config_path testdata/configs/go-header-fix.yml
7+
//golangcitest:config_path testdata/configs/goheader-fix.yml
88
package p

test/testdata/fix/out/go-header_3.go renamed to test/testdata/fix/out/goheader_3.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ Use of this source code is governed by LICENSE
66

77
//golangcitest:args -Egoheader
88
//golangcitest:expected_exitcode 0
9-
//golangcitest:config_path testdata/configs/go-header-fix.yml
9+
//golangcitest:config_path testdata/configs/goheader-fix.yml
1010
package p
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*MY TITLE!*/ // want `Expected:TITLE\., Actual: TITLE!`
22

33
//golangcitest:args -Egoheader
4-
//golangcitest:config_path testdata/configs/go-header.yml
4+
//golangcitest:config_path testdata/configs/goheader.yml
55
package testdata
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*MY TITLE.*/
22

33
//golangcitest:args -Egoheader
4-
//golangcitest:config_path testdata/configs/go-header.yml
4+
//golangcitest:config_path testdata/configs/goheader.yml
55
//golangcitest:expected_exitcode 0
66
package testdata
File renamed without changes.

test/testdata/ireturn_allow.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Eireturn
2-
//golangcitest:config_path testdata/configs/ireturn.yml
2+
//golangcitest:config_path testdata/configs/ireturn_allow.yml
33
//golangcitest:expected_exitcode 0
44
package testdata
55

File renamed without changes.

test/testdata/nonamedreturns_custom.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Enonamedreturns
2-
//golangcitest:config_path testdata/configs/nonamedreturns.yml
2+
//golangcitest:config_path testdata/configs/nonamedreturns_custom.yml
33
package testdata
44

55
import "fmt"

test/testdata/paralleltest_custom.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Eparalleltest
2-
//golangcitest:config_path testdata/configs/paralleltest.yml
2+
//golangcitest:config_path testdata/configs/paralleltest_custom.yml
33
//golangcitest:expected_exitcode 0
44
package testdata
55

test/testdata/predeclared_custom.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Epredeclared
2-
//golangcitest:config_path testdata/configs/predeclared.yml
2+
//golangcitest:config_path testdata/configs/predeclared_custom.yml
33
package testdata
44

55
func hello() {

test/testdata/spancheck/spancheck_enable_all.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//golangcitest:config_path configs/enable_all.yml
1+
//golangcitest:config_path configs/spancheck_enable_all.yml
22
//golangcitest:args -Espancheck
33
package spancheck
44

test/testdata/tenv_go118.go renamed to test/testdata/tenv_fuzz.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build go1.18
2-
31
//golangcitest:args -Etenv
42
package testdata
53

test/testdata/thelper_go118.go renamed to test/testdata/thelper_fuzz.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build go1.18
2-
31
//golangcitest:args -Ethelper
42
package testdata
53

0 commit comments

Comments
 (0)