Skip to content

Commit

Permalink
fix pr review changes
Browse files Browse the repository at this point in the history
use interface{} (not any)for go 1.17 test

fix interface\{\}
  • Loading branch information
alingse committed Jul 10, 2022
1 parent 2d02f03 commit 1b0c407
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
5 changes: 3 additions & 2 deletions .golangci.reference.yml
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/linters_settings.go
Expand Up @@ -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 {
Expand Down
15 changes: 8 additions & 7 deletions pkg/golinters/asasalint.go
Expand Up @@ -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,
Expand Down
11 changes: 6 additions & 5 deletions 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...))
}

0 comments on commit 1b0c407

Please sign in to comment.