Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linter asasalint to lint pass []any as any #2968

Merged
merged 10 commits into from Jul 18, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions .golangci.reference.yml
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions pkg/config/linters_settings.go
Expand Up @@ -7,6 +7,9 @@ import (
)

var defaultLintersSettings = LintersSettings{
Asasalint: AsasalintSettings{
UseBuiltinExclusions: true,
},
Decorder: DecorderSettings{
DecOrder: []string{"type", "const", "var", "func"},
DisableDecNumCheck: true,
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions pkg/golinters/asasalint.go
Expand Up @@ -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")
}
alingse marked this conversation as resolved.
Show resolved Hide resolved

return goanalysis.NewLinter(
a.Name,
Expand Down