StaticPaths collects static paths from all enabled analyzers It returns the collected paths and a boolean indicating if all enabled analyzers implement StaticPathAnalyzer
(disabled []Type)
| 602 | // StaticPaths collects static paths from all enabled analyzers |
| 603 | // It returns the collected paths and a boolean indicating if all enabled analyzers implement StaticPathAnalyzer |
| 604 | func (ag AnalyzerGroup) StaticPaths(disabled []Type) ([]string, bool) { |
| 605 | var paths []string |
| 606 | |
| 607 | type analyzerType interface{ Type() Type } |
| 608 | allAnalyzers := append( |
| 609 | xslices.Map(ag.analyzers, func(a analyzer) analyzerType { return a }), |
| 610 | xslices.Map(ag.postAnalyzers, func(a PostAnalyzer) analyzerType { return a })..., |
| 611 | ) |
| 612 | |
| 613 | for _, a := range allAnalyzers { |
| 614 | // Skip disabled analyzers |
| 615 | if slices.Contains(disabled, a.Type()) { |
| 616 | continue |
| 617 | } |
| 618 | |
| 619 | // We can't be sure that the file pattern uses a static path. |
| 620 | // So we don't need to use `StaticPath` logic if any enabled analyzer has a file pattern. |
| 621 | if _, ok := ag.filePatterns[a.Type()]; ok { |
| 622 | return nil, false |
| 623 | } |
| 624 | |
| 625 | // If any analyzer doesn't implement StaticPathAnalyzer, return false |
| 626 | staticPathAnalyzer, ok := a.(StaticPathAnalyzer) |
| 627 | if !ok { |
| 628 | return nil, false |
| 629 | } |
| 630 | |
| 631 | // Collect paths from StaticPathAnalyzer |
| 632 | paths = append(paths, staticPathAnalyzer.StaticPaths()...) |
| 633 | } |
| 634 | |
| 635 | // Remove duplicates |
| 636 | return lo.Uniq(paths), true |
| 637 | } |