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

rename default to builtin #9

Merged
merged 1 commit into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions asasalint.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"golang.org/x/tools/go/ast/inspector"
)

const DefaultExclude = `Printf,Println,Errorf,Fprintf,Fprintln,Fatal,Fatalf,Panic,Panicf,Panicln,Print,Printf,Println,Sprintf,Sprintln,Error,Errorf,Info,Infof,Warn,Warnf,Debug,Debugf`
const BuiltinExclude = `Printf,Println,Fprintf,Fprintln,Fatal,Fatalf,Panic,Panicf,Panicln,Print,Printf,Println,Sprintf,Sprintln,Error,Errorf,Info,Infof,Warn,Warnf,Debug,Debugf`

type LinterSetting struct {
Exclude []string
NoDefaultExclude bool
NoBuiltinExclude bool
IgnoreInTest bool
}

Expand All @@ -41,8 +41,8 @@ func newAnalyzer(setting LinterSetting) *analyzer {
setting: setting,
}

if !a.setting.NoDefaultExclude {
for _, exclude := range strings.Split(DefaultExclude, `,`) {
if !a.setting.NoBuiltinExclude {
for _, exclude := range strings.Split(BuiltinExclude, `,`) {
a.excludes[exclude] = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion asasalint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestNewAnalyzer(t *testing.T) {
_ = NewAnalyzer(LinterSetting{})
_ = NewAnalyzer(LinterSetting{
Exclude: []string{"hello"},
NoDefaultExclude: true,
NoBuiltinExclude: true,
IgnoreInTest: true,
})
}
10 changes: 5 additions & 5 deletions cmd/asasalint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import (

func main() {
var extraExclude string
var noDefaultExclude bool
var noBuiltinExclude bool
var ignoreInTest bool
flag.StringVar(&extraExclude,
"e",
"",
"Extra Exclude Func Names, like: FuncA,append,Append",
"extra exclude func names, like: FuncA,append,Append",
)
flag.BoolVar(&noDefaultExclude, "no-default-exclude", false,
"disbale the default exclude func names: "+asasalint.DefaultExclude)
flag.BoolVar(&noBuiltinExclude, "no-builtin-exclude", false,
"disbale the builtin exclude func names: "+asasalint.BuiltinExclude)
flag.BoolVar(&ignoreInTest, "ignore-in-test", false,
"ingore case in *_test.go")
flag.Parse()

setting := asasalint.LinterSetting{
Exclude: strings.Split(extraExclude, ","),
NoDefaultExclude: noDefaultExclude,
NoBuiltinExclude: noBuiltinExclude,
IgnoreInTest: ignoreInTest,
}
singlechecker.Main(asasalint.NewAnalyzer(setting))
Expand Down