Skip to content

Commit

Permalink
pkg/result/processors: compile nolint regexp only once (#2463)
Browse files Browse the repository at this point in the history
  • Loading branch information
quasilyte committed Jan 6, 2022
1 parent eaed228 commit 29eedbf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/result/processors/nolint.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
)

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

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

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

Expand Down

0 comments on commit 29eedbf

Please sign in to comment.