Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix pr review changes
use interface{} (not any)for go 1.17 test

fix interface\{\}
  • Loading branch information
alingse committed Jul 15, 2022
commit 4c6506b1215b388a00ba47dca11018052041f2a6
5 changes: 3 additions & 2 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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...))
}