From bcb21134727693f326330ad53a8f2fc5172b60a4 Mon Sep 17 00:00:00 2001 From: Oleg Butuzov Date: Tue, 11 Jan 2022 14:00:31 +0200 Subject: [PATCH] fix: wasted regexp --- config/config.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/config/config.go b/config/config.go index a4681e3..e186028 100644 --- a/config/config.go +++ b/config/config.go @@ -44,11 +44,10 @@ func WithOptions(options ...Option) *Config { func WithIgnoredFunctions(excludes string) Option { return func(config *Config) { - if excludes == "" { - return - } - for _, exclude := range strings.Split(excludes, ",") { + if exclude == "" { + continue + } config.IgnoredFunctions = append(config.IgnoredFunctions, regexp.MustCompile(exclude)) } } @@ -56,11 +55,10 @@ func WithIgnoredFunctions(excludes string) Option { func WithIgnoredFiles(excludes string) Option { return func(config *Config) { - if excludes == "" { - return - } - for _, exclude := range strings.Split(excludes, ",") { + if exclude == "" { + continue + } config.IgnoredFiles = append(config.IgnoredFiles, regexp.MustCompile(exclude)) } } @@ -68,11 +66,10 @@ func WithIgnoredFiles(excludes string) Option { func WithIgnoredNumbers(numbers string) Option { return func(config *Config) { - if numbers == "" { - return - } - for _, number := range strings.Split(numbers, ",") { + if number == "" { + continue + } config.IgnoredNumbers[config.removeDigitSeparator(number)] = struct{}{} } } @@ -89,6 +86,9 @@ func WithCustomChecks(checks string) Option { } for _, name := range strings.Split(checks, ",") { + if name == "" { + continue + } config.Checks[name] = true } }