(name string, f *core.File, chk check.Rule, blk nlp.Block)
| 291 | } |
| 292 | |
| 293 | func (l *Linter) shouldRun(name string, f *core.File, chk check.Rule, blk nlp.Block) bool { |
| 294 | minLevel := l.Manager.Config.MinAlertLevel |
| 295 | run := false |
| 296 | |
| 297 | details := chk.Fields() |
| 298 | if strings.Count(name, ".") > 1 { |
| 299 | // NOTE: This fixes the loading issue with consistency checks. |
| 300 | // |
| 301 | // See #129. |
| 302 | list := strings.Split(name, ".") |
| 303 | name = strings.Join([]string{list[0], list[1]}, ".") |
| 304 | } |
| 305 | |
| 306 | chkScope := check.NewScope(details.Scope) |
| 307 | if f.QueryComments(name) { //nolint:gocritic |
| 308 | // It has been disabled via an in-text comment. |
| 309 | return false |
| 310 | } else if core.LevelToInt[details.Level] < minLevel { |
| 311 | return false |
| 312 | } else if !chkScope.Matches(blk) { |
| 313 | return false |
| 314 | } |
| 315 | |
| 316 | // Has the check been disabled for this extension? |
| 317 | if val, ok := f.Checks[name]; ok && !run { |
| 318 | if !val { |
| 319 | return false |
| 320 | } |
| 321 | run = true |
| 322 | } |
| 323 | |
| 324 | // Has the check been disabled for all extensions? |
| 325 | if val, ok := l.Manager.Config.GChecks[name]; ok && !run { |
| 326 | if !val { |
| 327 | return false |
| 328 | } |
| 329 | run = true |
| 330 | } |
| 331 | |
| 332 | style := strings.Split(name, ".")[0] |
| 333 | if !run && !core.StringInSlice(style, f.BaseStyles) { |
| 334 | return false |
| 335 | } |
| 336 | |
| 337 | return true |
| 338 | } |
| 339 | |
| 340 | func (l *Linter) match(s string) bool { |
| 341 | if l.glob == nil { |
no test coverage detected