From 9291379441d40b27c7b560378b9c6fb09cb4c721 Mon Sep 17 00:00:00 2001 From: alingse Date: Sun, 10 Jul 2022 15:30:16 +0800 Subject: [PATCH] fix pr review changes --- .golangci.reference.yml | 5 +++-- pkg/config/linters_settings.go | 4 ++-- pkg/golinters/asasalint.go | 15 ++++++++------- test/testdata/asasalint.go | 5 +++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 1c8ab3b94aa8..337291c2ec10 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 64ecc01836f4..39a76dcc4912 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..ff49f71ea5f6 100644 --- a/test/testdata/asasalint.go +++ b/test/testdata/asasalint.go @@ -1,3 +1,4 @@ +//args: -Easasalint package testdata import "fmt" @@ -7,11 +8,11 @@ func getArgsLength(args ...any) int { } func checkArgsLength(args ...any) int { - return getArgsLength(args) + return getArgsLength(args) // ERROR `pass \[\]any as any to func getArgsLength func\(args \.\.\.any\) int` } func someCall() { var a = []any{1, 2, 3} - fmt.Println(checkArgsLength(a...) == getArgsLength(a)) + fmt.Println(checkArgsLength(a...) == getArgsLength(a)) // ERROR `pass \[\]any as any to func getArgsLength func\(args \.\.\.any\) int` fmt.Println(checkArgsLength(a...) == getArgsLength(a...)) }