pkg/result/processors: compile nolint regexp only once (#2463)
This commit is contained in:
parent
eaed228d2f
commit
29eedbf6e5
@ -17,6 +17,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var nolintDebugf = logutils.Debug("nolint")
|
var nolintDebugf = logutils.Debug("nolint")
|
||||||
|
var nolintRe = regexp.MustCompile(`^nolint( |:|$)`)
|
||||||
|
|
||||||
type ignoredRange struct {
|
type ignoredRange struct {
|
||||||
linters []string
|
linters []string
|
||||||
@ -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 {
|
func (p *Nolint) extractInlineRangeFromComment(text string, g ast.Node, fset *token.FileSet) *ignoredRange {
|
||||||
text = strings.TrimLeft(text, "/ ")
|
text = strings.TrimLeft(text, "/ ")
|
||||||
if ok, _ := regexp.MatchString(`^nolint( |:|$)`, text); !ok {
|
if !nolintRe.MatchString(text) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user