From 887eb4510d105dcc7f9a4485722ab838610802fc Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Fri, 19 Apr 2024 23:56:17 +0900 Subject: [PATCH] ignore test package --- urlstring/analyzer.go | 4 ++++ urlstring/testdata/a_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 urlstring/testdata/a_test.go diff --git a/urlstring/analyzer.go b/urlstring/analyzer.go index f377eb8..8abcdb4 100644 --- a/urlstring/analyzer.go +++ b/urlstring/analyzer.go @@ -3,6 +3,7 @@ package urlstring import ( "go/ast" "go/token" + "strings" "github.com/seiyab/gost/utils" "golang.org/x/tools/go/analysis" @@ -16,6 +17,9 @@ var Analyzer = &analysis.Analyzer{ func run(pass *analysis.Pass) (any, error) { for _, f := range pass.Files { + if f.Name != nil && strings.HasSuffix(f.Name.Name, "_test") { + continue + } ast.Inspect(f, func(n ast.Node) bool { switch n := n.(type) { case *ast.CallExpr: diff --git a/urlstring/testdata/a_test.go b/urlstring/testdata/a_test.go new file mode 100644 index 0000000..dab5541 --- /dev/null +++ b/urlstring/testdata/a_test.go @@ -0,0 +1,11 @@ +package testdata_test + +import "fmt" + +func _(host, userUUID, query string) { + _ = fmt.Sprintf("http://%s/api/v1/users/%s/comments?q=%s", host, userUUID, query) + + _ = "https://" + host + "/api" + + _ = "https://example.com" +}