dev: minor clean up (#4577)
This commit is contained in:
parent
840ef6229a
commit
085ac85a4e
@ -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"
|
||||
}
|
||||
|
@ -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{}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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{}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
18
test/testdata/decorder.go
vendored
18
test/testdata/decorder.go
vendored
@ -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() {}
|
||||
|
21
test/testdata/decorder_custom.go
vendored
Normal file
21
test/testdata/decorder_custom.go
vendored
Normal 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"
|
21
test/testdata/decorder_default.go
vendored
21
test/testdata/decorder_default.go
vendored
@ -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() {}
|
2
test/testdata/errcheck_exclude_functions.go
vendored
2
test/testdata/errcheck_exclude_functions.go
vendored
@ -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 (
|
||||
|
2
test/testdata/errcheck_ignore.go
vendored
2
test/testdata/errcheck_ignore.go
vendored
@ -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 (
|
||||
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
2
test/testdata/ireturn_allow.go
vendored
2
test/testdata/ireturn_allow.go
vendored
@ -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
|
||||
|
||||
|
2
test/testdata/nonamedreturns_custom.go
vendored
2
test/testdata/nonamedreturns_custom.go
vendored
@ -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"
|
||||
|
2
test/testdata/paralleltest_custom.go
vendored
2
test/testdata/paralleltest_custom.go
vendored
@ -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
|
||||
|
||||
|
2
test/testdata/predeclared_custom.go
vendored
2
test/testdata/predeclared_custom.go
vendored
@ -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() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
//golangcitest:config_path configs/enable_all.yml
|
||||
//golangcitest:config_path configs/spancheck_enable_all.yml
|
||||
//golangcitest:args -Espancheck
|
||||
package spancheck
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
//go:build go1.18
|
||||
|
||||
//golangcitest:args -Etenv
|
||||
package testdata
|
||||
|
@ -1,5 +1,3 @@
|
||||
//go:build go1.18
|
||||
|
||||
//golangcitest:args -Ethelper
|
||||
package testdata
|
||||
|
Loading…
x
Reference in New Issue
Block a user