From 4fda076e5d8dabc819b30b73f34a50f5ffe19a0f Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 16 Dec 2024 16:18:11 +0200 Subject: [PATCH] Refactor AppendError to use strings.Contains (#1270) --- analyzer.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/analyzer.go b/analyzer.go index 21886cd..ba2cb6f 100644 --- a/analyzer.go +++ b/analyzer.go @@ -543,8 +543,7 @@ func (gosec *Analyzer) ParseErrors(pkg *packages.Package) error { // AppendError appends an error to the file errors func (gosec *Analyzer) AppendError(file string, err error) { // Do not report the error for empty packages (e.g. files excluded from build with a tag) - r := regexp.MustCompile(`no buildable Go source files in`) - if r.MatchString(err.Error()) { + if strings.Contains(err.Error(), "no buildable Go source files in") { return } errors := make([]Error, 0)