lint: don't flag ignores for checks that were disabled
@@ -524,24 +524,26 @@ func (l *Linter) Lint(initial []*packages.Package, stats *PerfStats) []Problem {
if ig.matched {
continue
}
+
+ couldveMatched := false
+ for f, pkg := range prog.astFileMap {
+ if prog.Fset().Position(f.Pos()).Filename != ig.File {
+ continue
+ }
+ allowedChecks := FilterChecks(allChecks, pkg.Config.Checks)
for _, c := range ig.Checks {
- idx := strings.IndexFunc(c, func(r rune) bool {
- return unicode.IsNumber(r)
- })
- if idx == -1 {
- // malformed check name, backing out
+ if !allowedChecks[c] {
continue
}
-
- responsible := false
- for _, checker := range l.Checkers {
- if c[:idx] == checker.Prefix() {
- // for this checker
- responsible = true
+ couldveMatched = true
break
}
+ break
}
- if !responsible {
+
+ if !couldveMatched {
+ // The ignored checks were disabled for the containing package.
+ // Don't flag the ignore for not having matched.
continue
}
p := Problem{
@@ -553,7 +555,6 @@ func (l *Linter) Lint(initial []*packages.Package, stats *PerfStats) []Problem {
}
out = append(out, p)
}
- }
sort.Slice(out, func(i int, j int) bool {
pi, pj := out[i].Position, out[j].Position
