From e876a76a77e8c5e7be93aec91a3b095775908422 Mon Sep 17 00:00:00 2001 From: Ian Chechin Date: Thu, 14 May 2026 23:44:57 +0800 Subject: [PATCH] all: replace strings.Replace(_, -1) with strings.ReplaceAll staticcheck QF1004 prefers strings.ReplaceAll over strings.Replace with a -1 count: the intent of replace-everywhere is clearer in the name and matches the form added to the standard library in Go 1.12. Three call sites: - internal/pushrules/util.go: glob-to-regex translation - syncapi/storage/postgres/filtering.go: glob-to-LIKE translation No behavior change. Signed-off-by: Ian Chechin --- internal/pushrules/util.go | 4 ++-- syncapi/storage/postgres/filtering.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/pushrules/util.go b/internal/pushrules/util.go index e2821b57a..4979bbd2a 100644 --- a/internal/pushrules/util.go +++ b/internal/pushrules/util.go @@ -61,8 +61,8 @@ func globToRegexp(pattern string) (*regexp.Regexp, error) { // characters, which makes this a straight-forward // replace-after-quote. pattern = globNonMetaRegexp.ReplaceAllStringFunc(pattern, regexp.QuoteMeta) - pattern = strings.Replace(pattern, "*", ".*", -1) - pattern = strings.Replace(pattern, "?", ".", -1) + pattern = strings.ReplaceAll(pattern, "*", ".*") + pattern = strings.ReplaceAll(pattern, "?", ".") return regexp.Compile("^(" + pattern + ")$") } diff --git a/syncapi/storage/postgres/filtering.go b/syncapi/storage/postgres/filtering.go index 0d9271332..a4160d7e8 100644 --- a/syncapi/storage/postgres/filtering.go +++ b/syncapi/storage/postgres/filtering.go @@ -25,7 +25,7 @@ func filterConvertTypeWildcardToSQL(values *[]string) []string { v := *values ret := make([]string, len(v)) for i := range v { - ret[i] = strings.Replace(v[i], "*", "%", -1) + ret[i] = strings.ReplaceAll(v[i], "*", "%") } return ret }