Skip to content

Commit efeeefc

Browse files
committed
Unknown linter breaks //nolint
1 parent 3fe444c commit efeeefc

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

pkg/result/processors/nolint.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,14 @@ func (p *Nolint) extractInlineRangeFromComment(text string, g ast.Node, fset *to
250250
var linters []string
251251
text = strings.Split(text, "//")[0] // allow another comment after this comment
252252
linterItems := strings.Split(strings.TrimPrefix(text, "nolint:"), ",")
253-
var gotUnknownLinters bool
254253
for _, linter := range linterItems {
255254
linterName := strings.ToLower(strings.TrimSpace(linter))
256255

257256
lcs := p.dbManager.GetLinterConfigs(linterName)
258257
if lcs == nil {
259258
p.unknownLintersSet[linterName] = true
260-
gotUnknownLinters = true
259+
linters = append(linters, linterName)
260+
nolintDebugf("unknown linter %s on line %d", linterName, fset.Position(g.Pos()).Line)
261261
continue
262262
}
263263

@@ -266,10 +266,6 @@ func (p *Nolint) extractInlineRangeFromComment(text string, g ast.Node, fset *to
266266
}
267267
}
268268

269-
if gotUnknownLinters {
270-
return buildRange(nil) // ignore all linters to not annoy user
271-
}
272-
273269
nolintDebugf("%d: linters are %s", fset.Position(g.Pos()).Line, linters)
274270
return buildRange(linters)
275271
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//args: -Enolintlint -Egofmt
2+
//config: linters-settings.nolintlint.allow-unused=true
3+
package testdata
4+
5+
func bar() {
6+
_ = 0 //nolint: foobar // ERROR "File is not `gofmt`-ed with `-s`"
7+
}

0 commit comments

Comments
 (0)