diff --git a/README.md b/README.md index ce4171a..e1e9729 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ forbidigo is a Go static analysis tool to forbidigo use of particular identifier forbidigo [flags...] patterns... -- packages... -If no patterns are specified, the default pattern of `^fmt\.Print.*$` is used to eliminate debug statememts. By default, +If no patterns are specified, the default pattern of `^(fmt\.Print.*|print|println)$` is used to eliminate debug statements. By default, functions (and whole files), that are identifies as Godoc examples (https://blog.golang.org/examples) are excluded from checking. diff --git a/examples/example.go b/examples/example.go index 249d49d..c8c591e 100644 --- a/examples/example.go +++ b/examples/example.go @@ -5,4 +5,6 @@ import "fmt" func Foo() { fmt.Println("here I am") fmt.Printf("this is ok") //permit:fmt.Printf // this is ok + print("not ok") + println("also not ok") } diff --git a/examples/expected_results.txt b/examples/expected_results.txt index 2285cf0..7bedf18 100644 --- a/examples/expected_results.txt +++ b/examples/expected_results.txt @@ -1 +1,3 @@ -use of `fmt.Println` forbidden by pattern `^fmt\.Print(|f|ln)$` at CURDIR/examples/example.go:6:2 +use of `fmt.Println` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` at CURDIR/examples/example.go:6:2 +use of `print` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` at CURDIR/examples/example.go:8:2 +use of `println` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` at CURDIR/examples/example.go:9:2 diff --git a/forbidigo/forbidigo.go b/forbidigo/forbidigo.go index e77c2c6..2337404 100644 --- a/forbidigo/forbidigo.go +++ b/forbidigo/forbidigo.go @@ -46,7 +46,7 @@ type Linter struct { } func DefaultPatterns() []string { - return []string{`^fmt\.Print(|f|ln)$`} + return []string{`^(fmt\.Print(|f|ln)|print|println)$`} } //go:generate go-options config