Skip to content

Commit 29eedbf

Browse files
authored
pkg/result/processors: compile nolint regexp only once (#2463)
1 parent eaed228 commit 29eedbf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/result/processors/nolint.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
)
1818

1919
var nolintDebugf = logutils.Debug("nolint")
20+
var nolintRe = regexp.MustCompile(`^nolint( |:|$)`)
2021

2122
type ignoredRange struct {
2223
linters []string
@@ -234,7 +235,7 @@ func (p *Nolint) extractFileCommentsInlineRanges(fset *token.FileSet, comments .
234235

235236
func (p *Nolint) extractInlineRangeFromComment(text string, g ast.Node, fset *token.FileSet) *ignoredRange {
236237
text = strings.TrimLeft(text, "/ ")
237-
if ok, _ := regexp.MatchString(`^nolint( |:|$)`, text); !ok {
238+
if !nolintRe.MatchString(text) {
238239
return nil
239240
}
240241

0 commit comments

Comments
 (0)