Skip to content

Commit 09531cf

Browse files
committed
fix: nolint false positive.
1 parent a68a88e commit 09531cf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/result/processors/nolint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"go/ast"
66
"go/parser"
77
"go/token"
8+
"regexp"
89
"sort"
910
"strings"
1011

@@ -146,7 +147,6 @@ func (p *Nolint) buildIgnoredRangesForFile(f *ast.File, fset *token.FileSet, fil
146147

147148
func (p *Nolint) shouldPassIssue(i *result.Issue) (bool, error) {
148149
nolintDebugf("got issue: %v", *i)
149-
150150
if i.FromLinter == golinters.NolintlintName && i.ExpectNoLint && i.ExpectedNoLintLinter != "" {
151151
// don't expect disabled linters to cover their nolint statements
152152
nolintDebugf("enabled linters: %v", p.enabledLinters)
@@ -234,7 +234,7 @@ func (p *Nolint) extractFileCommentsInlineRanges(fset *token.FileSet, comments .
234234

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

0 commit comments

Comments
 (0)