Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit98c486b

Browse files
committed
fix: add local imported packages to the packages to analyze when using cache
1 parentc0f89fb commit98c486b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎pkg/golinters/goanalysis/runners.go‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package goanalysis
33
import (
44
"fmt"
55
"runtime"
6+
"slices"
67
"sort"
78
"strings"
89
"sync"
@@ -42,14 +43,32 @@ func runAnalyzers(cfg runAnalyzersConfig, lintCtx *linter.Context) ([]result.Iss
4243
pkgs=lintCtx.OriginalPackages
4344
}
4445

46+
pkgByPath:=make(map[string]*packages.Package,len(pkgs))
47+
for_,pkg:=rangepkgs {
48+
pkgByPath[pkg.PkgPath]=pkg
49+
}
50+
4551
issues,pkgsFromCache:=loadIssuesFromCache(pkgs,lintCtx,cfg.getAnalyzers())
52+
4653
varpkgsToAnalyze []*packages.Package
4754
for_,pkg:=rangepkgs {
4855
if!pkgsFromCache[pkg] {
4956
pkgsToAnalyze=append(pkgsToAnalyze,pkg)
57+
58+
// Also add the local packages imported by a package to analyze.
59+
// Some linters produce reports on a package reported by another one.
60+
// This is only needed for local imports.
61+
for_,v:=rangepkg.Imports {
62+
ifp,found:=pkgByPath[v.PkgPath];found {
63+
pkgsToAnalyze=append(pkgsToAnalyze,p)
64+
}
65+
}
5066
}
5167
}
5268

69+
// keep only unique packages
70+
pkgsToAnalyze=slices.Compact(pkgsToAnalyze)
71+
5372
diags,errs,passToPkg:=runner.run(cfg.getAnalyzers(),pkgsToAnalyze)
5473

5574
deferfunc() {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp