Skip to content

Commit

Permalink
[chore][checkapi] Add support for fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi committed Feb 5, 2025
1 parent 3cc420c commit a6c468a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/checkapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ func run(folder string, allowlistFilePath string) error {
return nil
}

func isTestFunction(fnName string) bool {
return strings.HasPrefix(fnName, "Test") ||
strings.HasPrefix(fnName, "Benchmark") ||
strings.HasPrefix(fnName, "Fuzz")
}

func handleFile(f *ast.File, result *api) {
for _, d := range f.Decls {
if str, isStr := d.(*ast.GenDecl); isStr {
Expand All @@ -107,7 +113,7 @@ func handleFile(f *ast.File, result *api) {
}
exported := false
receiver := ""
if fn.Recv.NumFields() == 0 && !strings.HasPrefix(fn.Name.String(), "Test") && !strings.HasPrefix(fn.Name.String(), "Benchmark") {
if fn.Recv.NumFields() == 0 && !isTestFunction(fn.Name.String()) {
exported = true
}
if fn.Recv.NumFields() > 0 {
Expand Down

0 comments on commit a6c468a

Please sign in to comment.