lint: skip work involving facts for analyses without facts
@@ -271,10 +271,14 @@ func (r *Runner) makeAnalysisAction(a *analysis.Analyzer, pkg *Package) *analysi
analyzer: a,
analyzerID: aid,
pkg: pkg,
- pkgFacts: map[*types.Package][]analysis.Fact{},
+ }
+
+ if len(a.FactTypes) == 0 {
+ return ac
}
// Merge all package facts of dependencies
+ ac.pkgFacts = map[*types.Package][]analysis.Fact{}
seen := map[*Package]struct{}{}
var dfs func(*Package)
dfs = func(pkg *Package) {
@@ -326,6 +330,7 @@ func (r *Runner) runAnalysisUser(pass *analysis.Pass, ac *analysisAction) (inter
return nil, err
}
+ if len(ac.analyzer.FactTypes) > 0 {
// Merge new facts into the package.
for _, fact := range ac.newFacts {
if fact.obj == nil {
@@ -337,7 +342,6 @@ func (r *Runner) runAnalysisUser(pass *analysis.Pass, ac *analysisAction) (inter
}
// Persist facts to cache
- if len(ac.analyzer.FactTypes) > 0 {
facts := make([]Fact, 0, len(ac.newFacts))
for _, fact := range ac.newFacts {
if fact.obj == nil {
