From 306e53048ce35b2cfa1213653ae9343a8b8cff7d Mon Sep 17 00:00:00 2001 From: alingse Date: Sun, 10 Jul 2022 13:58:09 +0800 Subject: [PATCH 01/10] Feature: Add asasalint to lint pass []any as any update go.mod --- go.mod | 1 + go.sum | 2 ++ pkg/config/linters_settings.go | 7 +++++++ pkg/golinters/asasalint.go | 26 ++++++++++++++++++++++++++ pkg/lint/lintersdb/manager.go | 8 ++++++++ test/testdata/asasalint.go | 17 +++++++++++++++++ 6 files changed, 61 insertions(+) create mode 100644 pkg/golinters/asasalint.go create mode 100644 test/testdata/asasalint.go diff --git a/go.mod b/go.mod index 87001c2ac3a8..5be3ff50b755 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/GaijinEntertainment/go-exhaustruct/v2 v2.2.0 github.com/OpenPeeDeeP/depguard v1.1.0 github.com/alexkohler/prealloc v1.0.0 + github.com/alingse/asasalint v0.0.5 github.com/ashanbrown/forbidigo v1.3.0 github.com/ashanbrown/makezero v1.1.1 github.com/bkielbasa/cyclop v1.2.0 diff --git a/go.sum b/go.sum index 859cc373e0f5..2e9cd410ea81 100644 --- a/go.sum +++ b/go.sum @@ -70,6 +70,8 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pOcUuw= github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= +github.com/alingse/asasalint v0.0.5 h1:/U8o+wtkyc9wsmDiyvCAcGr5uskgM2tVLNlqZJouid0= +github.com/alingse/asasalint v0.0.5/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index e696e54b887b..e37f13b9ab18 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -113,6 +113,7 @@ var defaultLintersSettings = LintersSettings{ } type LintersSettings struct { + Asasalint AsasalintSettings BiDiChk BiDiChkSettings Cyclop Cyclop Decorder DecorderSettings @@ -184,6 +185,12 @@ type LintersSettings struct { Custom map[string]CustomLinterSettings } +type AsasalintSettings struct { + Exclude []string `mapstructure:"exclude"` + NoDefaultExclude bool `mapstructure:"no_default_exclude"` + IgnoreInTest bool `mapstructure:"ignore_in_test"` +} + type BiDiChkSettings struct { LeftToRightEmbedding bool `mapstructure:"left-to-right-embedding"` RightToLeftEmbedding bool `mapstructure:"right-to-left-embedding"` diff --git a/pkg/golinters/asasalint.go b/pkg/golinters/asasalint.go new file mode 100644 index 000000000000..e3d0ac9cabbf --- /dev/null +++ b/pkg/golinters/asasalint.go @@ -0,0 +1,26 @@ +package golinters + +import ( + "github.com/alingse/asasalint" + "golang.org/x/tools/go/analysis" + + "github.com/golangci/golangci-lint/pkg/config" + "github.com/golangci/golangci-lint/pkg/golinters/goanalysis" +) + +func NewAsasalint(cfg *config.AsasalintSettings) *goanalysis.Linter { + setting := asasalint.LinterSetting{} + if cfg != nil { + setting.Exclude = cfg.Exclude + setting.NoDefaultExclude = cfg.NoDefaultExclude + setting.IgnoreInTest = cfg.IgnoreInTest + } + a := asasalint.NewAnalyzer(setting) + + return goanalysis.NewLinter( + a.Name, + a.Doc, + []*analysis.Analyzer{a}, + nil, + ).WithLoadMode(goanalysis.LoadModeTypesInfo) +} diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index f85a0b16681e..b55d05a4ead7 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -101,6 +101,7 @@ func enableLinterConfigs(lcs []*linter.Config, isEnabled func(lc *linter.Config) //nolint:funlen func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { var ( + asasalintCfg *config.AsasalintSettings bidichkCfg *config.BiDiChkSettings cyclopCfg *config.Cyclop decorderCfg *config.DecorderSettings @@ -171,6 +172,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { ) if m.cfg != nil { + asasalintCfg = &m.cfg.LintersSettings.Asasalint bidichkCfg = &m.cfg.LintersSettings.BiDiChk cyclopCfg = &m.cfg.LintersSettings.Cyclop decorderCfg = &m.cfg.LintersSettings.Decorder @@ -266,6 +268,12 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { // 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. lcs := []*linter.Config{ + linter.NewConfig(golinters.NewAsasalint(asasalintCfg)). + WithSince("1.47.0"). + WithPresets(linter.PresetBugs). + WithLoadForGoAnalysis(). + WithURL("https://github.com/alingse/asasalint"), + linter.NewConfig(golinters.NewAsciicheck()). WithSince("v1.26.0"). WithPresets(linter.PresetBugs, linter.PresetStyle). diff --git a/test/testdata/asasalint.go b/test/testdata/asasalint.go new file mode 100644 index 000000000000..ed2af407e9af --- /dev/null +++ b/test/testdata/asasalint.go @@ -0,0 +1,17 @@ +package testdata + +import "fmt" + +func getArgsLength(args ...any) int { + return len(args) +} + +func checkArgsLength(args ...any) int { + return getArgsLength(args) +} + +func someCall() { + var a = []any{1, 2, 3} + fmt.Println(checkArgsLength(a...) == getArgsLength(a)) + fmt.Println(checkArgsLength(a...) == getArgsLength(a...)) +} From 2164d05901cdb5a681dcc02b88fc9458779cdaf5 Mon Sep 17 00:00:00 2001 From: alingse Date: Sun, 10 Jul 2022 14:41:08 +0800 Subject: [PATCH 02/10] add asasalint to exmaple yml --- .golangci.reference.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 0b09a14d5324..fb0ecd34e310 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -107,6 +107,14 @@ output: # All available settings of specific linters. linters-settings: + asasalint: + # Add FuncName to exclude for some bad case report. + exclude: + - Append + - Log + # if true, will disable the default exclude see https://github.com/alingse/asasalint/blob/main/asasalint.go#L15 like: Printf,Println,Errorf,Debugf ... + no_default_exclude: false + ignore_in_test: false bidichk: # The following configurations check for all mentioned invisible unicode runes. # All runes are enabled by default. @@ -1823,6 +1831,7 @@ linters: # Enable specific linter # https://golangci-lint.run/usage/linters/#enabled-by-default-linters enable: + - asasalint - asciicheck - bidichk - bodyclose @@ -1922,6 +1931,7 @@ linters: # Disable specific linter # https://golangci-lint.run/usage/linters/#disabled-by-default-linters--e--enable disable: + - asasalint - asciicheck - bidichk - bodyclose From 4c6506b1215b388a00ba47dca11018052041f2a6 Mon Sep 17 00:00:00 2001 From: alingse Date: Sun, 10 Jul 2022 15:30:16 +0800 Subject: [PATCH 03/10] fix pr review changes use interface{} (not any)for go 1.17 test fix interface\{\} --- .golangci.reference.yml | 5 +++-- pkg/config/linters_settings.go | 4 ++-- pkg/golinters/asasalint.go | 15 ++++++++------- test/testdata/asasalint.go | 11 ++++++----- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index fb0ecd34e310..d60b6ff7a6e5 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -112,9 +112,10 @@ linters-settings: exclude: - Append - Log + # ignore found case in *_test.go file + ignore-in-test: false # if true, will disable the default exclude see https://github.com/alingse/asasalint/blob/main/asasalint.go#L15 like: Printf,Println,Errorf,Debugf ... - no_default_exclude: false - ignore_in_test: false + no-default-exclude: false bidichk: # The following configurations check for all mentioned invisible unicode runes. # All runes are enabled by default. diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index e37f13b9ab18..37e88c24bc02 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -187,8 +187,8 @@ type LintersSettings struct { type AsasalintSettings struct { Exclude []string `mapstructure:"exclude"` - NoDefaultExclude bool `mapstructure:"no_default_exclude"` - IgnoreInTest bool `mapstructure:"ignore_in_test"` + IgnoreInTest bool `mapstructure:"ignore-in-test"` + NoDefaultExclude bool `mapstructure:"no-default-exclude"` } type BiDiChkSettings struct { diff --git a/pkg/golinters/asasalint.go b/pkg/golinters/asasalint.go index e3d0ac9cabbf..07d1f1112dc8 100644 --- a/pkg/golinters/asasalint.go +++ b/pkg/golinters/asasalint.go @@ -8,14 +8,15 @@ import ( "github.com/golangci/golangci-lint/pkg/golinters/goanalysis" ) -func NewAsasalint(cfg *config.AsasalintSettings) *goanalysis.Linter { - setting := asasalint.LinterSetting{} - if cfg != nil { - setting.Exclude = cfg.Exclude - setting.NoDefaultExclude = cfg.NoDefaultExclude - setting.IgnoreInTest = cfg.IgnoreInTest +func NewAsasalint(setting *config.AsasalintSettings) *goanalysis.Linter { + cfg := asasalint.LinterSetting{} + if setting != nil { + cfg.Exclude = setting.Exclude + cfg.IgnoreInTest = setting.IgnoreInTest + cfg.NoDefaultExclude = setting.NoDefaultExclude } - a := asasalint.NewAnalyzer(setting) + + a := asasalint.NewAnalyzer(cfg) return goanalysis.NewLinter( a.Name, diff --git a/test/testdata/asasalint.go b/test/testdata/asasalint.go index ed2af407e9af..562e0a9f2a82 100644 --- a/test/testdata/asasalint.go +++ b/test/testdata/asasalint.go @@ -1,17 +1,18 @@ +//args: -Easasalint package testdata import "fmt" -func getArgsLength(args ...any) int { +func getArgsLength(args ...interface{}) int { return len(args) } -func checkArgsLength(args ...any) int { - return getArgsLength(args) +func checkArgsLength(args ...interface{}) int { + return getArgsLength(args) // ERROR `pass \[\]any as any to func getArgsLength func\(args \.\.\.interface\{\}\)` } func someCall() { - var a = []any{1, 2, 3} - fmt.Println(checkArgsLength(a...) == getArgsLength(a)) + var a = []interface{}{1, 2, 3} + fmt.Println(checkArgsLength(a...) == getArgsLength(a)) // ERROR `pass \[\]any as any to func getArgsLength func\(args \.\.\.interface\{\}\)` fmt.Println(checkArgsLength(a...) == getArgsLength(a...)) } From 83cb1857bddac835091a24111bc3d0316ca09023 Mon Sep 17 00:00:00 2001 From: alingse Date: Sun, 10 Jul 2022 22:16:25 +0800 Subject: [PATCH 04/10] add Default: on yml config --- .golangci.reference.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index d60b6ff7a6e5..45ff697efd81 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -109,12 +109,15 @@ output: linters-settings: asasalint: # Add FuncName to exclude for some bad case report. + # Default: [] exclude: - Append - Log # ignore found case in *_test.go file + # Default: false ignore-in-test: false # if true, will disable the default exclude see https://github.com/alingse/asasalint/blob/main/asasalint.go#L15 like: Printf,Println,Errorf,Debugf ... + # Default: false no-default-exclude: false bidichk: # The following configurations check for all mentioned invisible unicode runes. From 6341671ad05b9c56fffebd745a234ccd53e6e7cd Mon Sep 17 00:00:00 2001 From: alingse Date: Mon, 11 Jul 2022 21:08:04 +0800 Subject: [PATCH 05/10] upgarde asasalint v0.0.6, and add some note in reference.yml --- .golangci.reference.yml | 12 ++++++++---- go.mod | 2 +- go.sum | 2 ++ pkg/config/linters_settings.go | 2 +- pkg/golinters/asasalint.go | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 45ff697efd81..0919399184d2 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -108,17 +108,21 @@ output: # All available settings of specific linters. linters-settings: asasalint: - # Add FuncName to exclude for some bad case report. + # Add FuncName to exclude for avoid some bad case report. + # the asasalint has also some builtin exclude func names, not need to config here, + # and can disabled by `no-builtin-exclude` option. + # they are `Printf,Println,Fprintf,Fprintln,Fatal,Fatalf,Panic,Panicf,Panicln,Print,Printf,Println,Sprintf,Sprintln,Error,Errorf,Info,Infof,Warn,Warnf,Debug,Debugf`. # Default: [] exclude: - Append - Log # ignore found case in *_test.go file # Default: false - ignore-in-test: false - # if true, will disable the default exclude see https://github.com/alingse/asasalint/blob/main/asasalint.go#L15 like: Printf,Println,Errorf,Debugf ... + ignore-in-test: true + # if true, will disable the builtin exclude see https://github.com/alingse/asasalint/blob/main/asasalint.go#L15 like: Printf,Println,Errorf,Debugf ... # Default: false - no-default-exclude: false + no-builtin-exclude: true + bidichk: # The following configurations check for all mentioned invisible unicode runes. # All runes are enabled by default. diff --git a/go.mod b/go.mod index 5be3ff50b755..5c7679958a1a 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/GaijinEntertainment/go-exhaustruct/v2 v2.2.0 github.com/OpenPeeDeeP/depguard v1.1.0 github.com/alexkohler/prealloc v1.0.0 - github.com/alingse/asasalint v0.0.5 + github.com/alingse/asasalint v0.0.6 github.com/ashanbrown/forbidigo v1.3.0 github.com/ashanbrown/makezero v1.1.1 github.com/bkielbasa/cyclop v1.2.0 diff --git a/go.sum b/go.sum index 2e9cd410ea81..6c144d1282ca 100644 --- a/go.sum +++ b/go.sum @@ -72,6 +72,8 @@ github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pO github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= github.com/alingse/asasalint v0.0.5 h1:/U8o+wtkyc9wsmDiyvCAcGr5uskgM2tVLNlqZJouid0= github.com/alingse/asasalint v0.0.5/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= +github.com/alingse/asasalint v0.0.6 h1:UMyvWrkrDHm9y3MhC9sVxnTIY8MwxhgxSs6ZilB6Inc= +github.com/alingse/asasalint v0.0.6/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 37e88c24bc02..0ee9e2a58162 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -188,7 +188,7 @@ type LintersSettings struct { type AsasalintSettings struct { Exclude []string `mapstructure:"exclude"` IgnoreInTest bool `mapstructure:"ignore-in-test"` - NoDefaultExclude bool `mapstructure:"no-default-exclude"` + NoBuiltinExclude bool `mapstructure:"no-builtin-exclude"` } type BiDiChkSettings struct { diff --git a/pkg/golinters/asasalint.go b/pkg/golinters/asasalint.go index 07d1f1112dc8..9658d244f31d 100644 --- a/pkg/golinters/asasalint.go +++ b/pkg/golinters/asasalint.go @@ -13,7 +13,7 @@ func NewAsasalint(setting *config.AsasalintSettings) *goanalysis.Linter { if setting != nil { cfg.Exclude = setting.Exclude cfg.IgnoreInTest = setting.IgnoreInTest - cfg.NoDefaultExclude = setting.NoDefaultExclude + cfg.NoBuiltinExclude = setting.NoBuiltinExclude } a := asasalint.NewAnalyzer(cfg) From 483d87aceb1328464f5bb85d659b9fe6bf2f6074 Mon Sep 17 00:00:00 2001 From: alingse Date: Fri, 15 Jul 2022 22:35:26 +0800 Subject: [PATCH 06/10] use golangcitest comment --- test/testdata/asasalint.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testdata/asasalint.go b/test/testdata/asasalint.go index 562e0a9f2a82..14114b408e6a 100644 --- a/test/testdata/asasalint.go +++ b/test/testdata/asasalint.go @@ -1,4 +1,4 @@ -//args: -Easasalint +//golangcitest:args -Easasalint package testdata import "fmt" From 976ba2c97c1c51eb2f1fb2724cf23c8855bbc1a4 Mon Sep 17 00:00:00 2001 From: alingse Date: Fri, 15 Jul 2022 22:39:34 +0800 Subject: [PATCH 07/10] use 0.0.7 and add more case --- go.mod | 2 +- go.sum | 6 ++---- test/testdata/asasalint.go | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 5c7679958a1a..93053511aea1 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/GaijinEntertainment/go-exhaustruct/v2 v2.2.0 github.com/OpenPeeDeeP/depguard v1.1.0 github.com/alexkohler/prealloc v1.0.0 - github.com/alingse/asasalint v0.0.6 + github.com/alingse/asasalint v0.0.7 github.com/ashanbrown/forbidigo v1.3.0 github.com/ashanbrown/makezero v1.1.1 github.com/bkielbasa/cyclop v1.2.0 diff --git a/go.sum b/go.sum index 6c144d1282ca..8f9f07e69aa8 100644 --- a/go.sum +++ b/go.sum @@ -70,10 +70,8 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pOcUuw= github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= -github.com/alingse/asasalint v0.0.5 h1:/U8o+wtkyc9wsmDiyvCAcGr5uskgM2tVLNlqZJouid0= -github.com/alingse/asasalint v0.0.5/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= -github.com/alingse/asasalint v0.0.6 h1:UMyvWrkrDHm9y3MhC9sVxnTIY8MwxhgxSs6ZilB6Inc= -github.com/alingse/asasalint v0.0.6/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= +github.com/alingse/asasalint v0.0.7 h1:8DKtvyhyd6208936/2bFBFDNOuvzeXEkp7Cqj/i5f/A= +github.com/alingse/asasalint v0.0.7/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= diff --git a/test/testdata/asasalint.go b/test/testdata/asasalint.go index 14114b408e6a..7dcc68397249 100644 --- a/test/testdata/asasalint.go +++ b/test/testdata/asasalint.go @@ -4,6 +4,8 @@ package testdata import "fmt" func getArgsLength(args ...interface{}) int { + // this line will not report as error + fmt.Println(args) return len(args) } From a91c3571e05cbaaf1a6a5be6a580c34b61a81ac8 Mon Sep 17 00:00:00 2001 From: alingse Date: Sat, 16 Jul 2022 16:26:17 +0800 Subject: [PATCH 08/10] upgrade to v0.0.8 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 93053511aea1..3eddd8755814 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/GaijinEntertainment/go-exhaustruct/v2 v2.2.0 github.com/OpenPeeDeeP/depguard v1.1.0 github.com/alexkohler/prealloc v1.0.0 - github.com/alingse/asasalint v0.0.7 + github.com/alingse/asasalint v0.0.8 github.com/ashanbrown/forbidigo v1.3.0 github.com/ashanbrown/makezero v1.1.1 github.com/bkielbasa/cyclop v1.2.0 diff --git a/go.sum b/go.sum index 8f9f07e69aa8..c526b532fcbe 100644 --- a/go.sum +++ b/go.sum @@ -72,6 +72,8 @@ github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pO github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= github.com/alingse/asasalint v0.0.7 h1:8DKtvyhyd6208936/2bFBFDNOuvzeXEkp7Cqj/i5f/A= github.com/alingse/asasalint v0.0.7/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= +github.com/alingse/asasalint v0.0.8 h1:yc4Gfk4SE5SW2fDDWdQJYS9+XXDA+DBzyRkaQktR/0g= +github.com/alingse/asasalint v0.0.8/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= From f0160cda6c208595996a28efacc3f9d448f943ff Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 17 Jul 2022 12:28:33 +0200 Subject: [PATCH 09/10] review --- .golangci.reference.yml | 22 +++++++++++----------- go.mod | 2 +- go.sum | 6 ++---- pkg/config/linters_settings.go | 9 ++++++--- pkg/golinters/asasalint.go | 9 ++++++--- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 0919399184d2..13647bb36c32 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -108,20 +108,20 @@ output: # All available settings of specific linters. linters-settings: asasalint: - # Add FuncName to exclude for avoid some bad case report. - # the asasalint has also some builtin exclude func names, not need to config here, - # and can disabled by `no-builtin-exclude` option. - # they are `Printf,Println,Fprintf,Fprintln,Fatal,Fatalf,Panic,Panicf,Panicln,Print,Printf,Println,Sprintf,Sprintln,Error,Errorf,Info,Infof,Warn,Warnf,Debug,Debugf`. - # Default: [] + # To specify a set of function names to exclude. + # The values are merged with the builtin exclusions. + # The builtin exclusions can be disabled by setting `use-builtin-exclusions` to `false`. + # Default: ["^(fmt|log|logger)\.(Print|Fprint|Sprint|Fatal|Panic|Error|Warn|Warning|Info|Debug)(|f|ln)$"] exclude: - Append - - Log - # ignore found case in *_test.go file - # Default: false - ignore-in-test: true - # if true, will disable the builtin exclude see https://github.com/alingse/asasalint/blob/main/asasalint.go#L15 like: Printf,Println,Errorf,Debugf ... + - \.Wrapf + # To enable/disable the asasalint builtin exclusions of function names. + # See the default value of `exclude` to get the builtin exclusions. + # Default: true + use-builtin-exclusions: false + # Ignore *_test.go files. # Default: false - no-builtin-exclude: true + ignore-test: true bidichk: # The following configurations check for all mentioned invisible unicode runes. diff --git a/go.mod b/go.mod index 3eddd8755814..3fd6223a5c90 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/GaijinEntertainment/go-exhaustruct/v2 v2.2.0 github.com/OpenPeeDeeP/depguard v1.1.0 github.com/alexkohler/prealloc v1.0.0 - github.com/alingse/asasalint v0.0.8 + github.com/alingse/asasalint v0.0.10 github.com/ashanbrown/forbidigo v1.3.0 github.com/ashanbrown/makezero v1.1.1 github.com/bkielbasa/cyclop v1.2.0 diff --git a/go.sum b/go.sum index c526b532fcbe..5fb3be70ba81 100644 --- a/go.sum +++ b/go.sum @@ -70,10 +70,8 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pOcUuw= github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= -github.com/alingse/asasalint v0.0.7 h1:8DKtvyhyd6208936/2bFBFDNOuvzeXEkp7Cqj/i5f/A= -github.com/alingse/asasalint v0.0.7/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= -github.com/alingse/asasalint v0.0.8 h1:yc4Gfk4SE5SW2fDDWdQJYS9+XXDA+DBzyRkaQktR/0g= -github.com/alingse/asasalint v0.0.8/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= +github.com/alingse/asasalint v0.0.10 h1:qqGPDTV0ff0tWHN/nnIlSdjlU/EwRPaUY4SfpE1rnms= +github.com/alingse/asasalint v0.0.10/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 0ee9e2a58162..b0bc1ac82ffd 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -7,6 +7,9 @@ import ( ) var defaultLintersSettings = LintersSettings{ + Asasalint: AsasalintSettings{ + UseBuiltinExclusions: true, + }, Decorder: DecorderSettings{ DecOrder: []string{"type", "const", "var", "func"}, DisableDecNumCheck: true, @@ -186,9 +189,9 @@ type LintersSettings struct { } type AsasalintSettings struct { - Exclude []string `mapstructure:"exclude"` - IgnoreInTest bool `mapstructure:"ignore-in-test"` - NoBuiltinExclude bool `mapstructure:"no-builtin-exclude"` + Exclude []string `mapstructure:"exclude"` + UseBuiltinExclusions bool `mapstructure:"use-builtin-exclusions"` + IgnoreTest bool `mapstructure:"ignore-test"` } type BiDiChkSettings struct { diff --git a/pkg/golinters/asasalint.go b/pkg/golinters/asasalint.go index 9658d244f31d..a63f7a14e329 100644 --- a/pkg/golinters/asasalint.go +++ b/pkg/golinters/asasalint.go @@ -12,11 +12,14 @@ func NewAsasalint(setting *config.AsasalintSettings) *goanalysis.Linter { cfg := asasalint.LinterSetting{} if setting != nil { cfg.Exclude = setting.Exclude - cfg.IgnoreInTest = setting.IgnoreInTest - cfg.NoBuiltinExclude = setting.NoBuiltinExclude + cfg.NoBuiltinExclusions = !setting.UseBuiltinExclusions + cfg.IgnoreTest = setting.IgnoreTest } - a := asasalint.NewAnalyzer(cfg) + a, err := asasalint.NewAnalyzer(cfg) + if err != nil { + linterLogger.Fatalf("asasalint: create analyzer") + } return goanalysis.NewLinter( a.Name, From 6bc21d25dfbe98e994afcb97358b6745c14365a0 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 17 Jul 2022 13:26:33 +0200 Subject: [PATCH 10/10] review --- pkg/golinters/asasalint.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/golinters/asasalint.go b/pkg/golinters/asasalint.go index a63f7a14e329..67dde79918b2 100644 --- a/pkg/golinters/asasalint.go +++ b/pkg/golinters/asasalint.go @@ -18,7 +18,7 @@ func NewAsasalint(setting *config.AsasalintSettings) *goanalysis.Linter { a, err := asasalint.NewAnalyzer(cfg) if err != nil { - linterLogger.Fatalf("asasalint: create analyzer") + linterLogger.Fatalf("asasalint: create analyzer: %v", err) } return goanalysis.NewLinter(