Skip to content

Commit 1b0c407

Browse files
committed
fix pr review changes
use interface{} (not any)for go 1.17 test fix interface\{\}
1 parent 2d02f03 commit 1b0c407

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

.golangci.reference.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ linters-settings:
112112
exclude:
113113
- Append
114114
- Log
115+
# ignore found case in *_test.go file
116+
ignore-in-test: false
115117
# if true, will disable the default exclude see https://github.com/alingse/asasalint/blob/main/asasalint.go#L15 like: Printf,Println,Errorf,Debugf ...
116-
no_default_exclude: false
117-
ignore_in_test: false
118+
no-default-exclude: false
118119
bidichk:
119120
# The following configurations check for all mentioned invisible unicode runes.
120121
# All runes are enabled by default.

pkg/config/linters_settings.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ type LintersSettings struct {
187187

188188
type AsasalintSettings struct {
189189
Exclude []string `mapstructure:"exclude"`
190-
NoDefaultExclude bool `mapstructure:"no_default_exclude"`
191-
IgnoreInTest bool `mapstructure:"ignore_in_test"`
190+
IgnoreInTest bool `mapstructure:"ignore-in-test"`
191+
NoDefaultExclude bool `mapstructure:"no-default-exclude"`
192192
}
193193

194194
type BiDiChkSettings struct {

pkg/golinters/asasalint.go

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

11-
func NewAsasalint(cfg *config.AsasalintSettings) *goanalysis.Linter {
12-
setting := asasalint.LinterSetting{}
13-
if cfg != nil {
14-
setting.Exclude = cfg.Exclude
15-
setting.NoDefaultExclude = cfg.NoDefaultExclude
16-
setting.IgnoreInTest = cfg.IgnoreInTest
11+
func NewAsasalint(setting *config.AsasalintSettings) *goanalysis.Linter {
12+
cfg := asasalint.LinterSetting{}
13+
if setting != nil {
14+
cfg.Exclude = setting.Exclude
15+
cfg.IgnoreInTest = setting.IgnoreInTest
16+
cfg.NoDefaultExclude = setting.NoDefaultExclude
1717
}
18-
a := asasalint.NewAnalyzer(setting)
18+
19+
a := asasalint.NewAnalyzer(cfg)
1920

2021
return goanalysis.NewLinter(
2122
a.Name,

test/testdata/asasalint.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
//args: -Easasalint
12
package testdata
23

34
import "fmt"
45

5-
func getArgsLength(args ...any) int {
6+
func getArgsLength(args ...interface{}) int {
67
return len(args)
78
}
89

9-
func checkArgsLength(args ...any) int {
10-
return getArgsLength(args)
10+
func checkArgsLength(args ...interface{}) int {
11+
return getArgsLength(args) // ERROR `pass \[\]any as any to func getArgsLength func\(args \.\.\.interface\{\}\)`
1112
}
1213

1314
func someCall() {
14-
var a = []any{1, 2, 3}
15-
fmt.Println(checkArgsLength(a...) == getArgsLength(a))
15+
var a = []interface{}{1, 2, 3}
16+
fmt.Println(checkArgsLength(a...) == getArgsLength(a)) // ERROR `pass \[\]any as any to func getArgsLength func\(args \.\.\.interface\{\}\)`
1617
fmt.Println(checkArgsLength(a...) == getArgsLength(a...))
1718
}

0 commit comments

Comments
 (0)