Skip to content

Commit

Permalink
remove regexp var duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
mfederowicz committed Nov 30, 2023
1 parent d3269f0 commit aaa2398
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rule/imports-blocklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type ImportsBlocklistRule struct {
sync.Mutex
}

var replaceRegexp = regexp.MustCompile(`/?\*\*/?`)
var replaceImportRegexp = regexp.MustCompile(`/?\*\*/?`)

func (r *ImportsBlocklistRule) configure(arguments lint.Arguments) {
r.Lock()
Expand All @@ -28,7 +28,7 @@ func (r *ImportsBlocklistRule) configure(arguments lint.Arguments) {
if !ok {
panic(fmt.Sprintf("Invalid argument to the imports-blocklist rule. Expecting a string, got %T", arg))
}
regStr, err := regexp.Compile(fmt.Sprintf(`(?m)"%s"$`, replaceRegexp.ReplaceAllString(argStr, `(\W|\w)*`)))
regStr, err := regexp.Compile(fmt.Sprintf(`(?m)"%s"$`, replaceImportRegexp.ReplaceAllString(argStr, `(\W|\w)*`)))
if err != nil {
panic(fmt.Sprintf("Invalid argument to the imports-blocklist rule. Expecting %q to be a valid regular expression, got: %v", argStr, err))
}
Expand Down

0 comments on commit aaa2398

Please sign in to comment.