Skip to content

Commit

Permalink
Merge pull request #9 from alingse/rename-default-to-builtin
Browse files Browse the repository at this point in the history
rename default to builtin
  • Loading branch information
alingse authored Jul 11, 2022
2 parents ebef320 + b24cbae commit e2e5312
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
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

0 comments on commit e2e5312

Please sign in to comment.