Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
feat: improve condition for test case (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
sivchari authored Jul 20, 2022
1 parent 99e6890 commit 941c1cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nosnakecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func report(pass *analysis.Pass, pos token.Pos, name string) {

// If prefix is Test or Benchmark, Fuzz, skip
// FYI https://go.dev/blog/examples
if strings.Contains(name, "Test") || strings.Contains(name, "Benchmark") || strings.Contains(name, "Fuzz") {
if strings.HasPrefix(name, "Test") || strings.HasPrefix(name, "Benchmark") || strings.HasPrefix(name, "Fuzz") {
return
}

Expand Down
12 changes: 12 additions & 0 deletions testdata/src/a/a_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ func BenchmarkX_x(b *testing.B) {}
func FuzzX(f *testing.F) {}
func Fuzz_x(f *testing.F) {}
func FuzzX_x(f *testing.F) {}

func xTestX(t *testing.T) {}
func xTest_x(t *testing.T) {} // want "xTest_x contains underscore. You should use mixedCap or MixedCap."
func xTestX_x(t *testing.T) {} // want "xTestX_x contains underscore. You should use mixedCap or MixedCap."

func xBenchmarkX(b *testing.B) {}
func xBenchmark_x(b *testing.B) {} // want "xBenchmark_x contains underscore. You should use mixedCap or MixedCap."
func xBenchmarkX_x(b *testing.B) {} // want "xBenchmarkX_x contains underscore. You should use mixedCap or MixedCap."

func xFuzzX(f *testing.F) {}
func xFuzz_x(f *testing.F) {} // want "xFuzz_x contains underscore. You should use mixedCap or MixedCap."
func xFuzzX_x(f *testing.F) {} // want "xFuzzX_x contains underscore. You should use mixedCap or MixedCap."

0 comments on commit 941c1cf

Please sign in to comment.