Skip to content

Commit 746a16a

Browse files
committed
fix: log only if not root analyzer
1 parent f9e9726 commit 746a16a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/golinters/goanalysis/runner_action.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ func (act *action) waitUntilDependingAnalyzersWorked() {
9898
func (act *action) analyzeSafe() {
9999
defer func() {
100100
if p := recover(); p != nil {
101-
// This line allows to display "hidden" panic with analyzers like buildssa.
102-
// Some linters are dependent of sub-analyzers but when a sub-analyzer fails the linter is not aware of that,
103-
// this results to another panic (ex: "interface conversion: interface {} is nil, not *buildssa.SSA").
104-
// This line will create a duplication of the panic message on purpose.
105-
act.r.log.Errorf("%s: panic during analysis: %v, %s", act.a.Name, p, string(debug.Stack()))
101+
if !act.isroot {
102+
// This line allows to display "hidden" panic with analyzers like buildssa.
103+
// Some linters are dependent of sub-analyzers but when a sub-analyzer fails the linter is not aware of that,
104+
// this results to another panic (ex: "interface conversion: interface {} is nil, not *buildssa.SSA").
105+
// This line will create a duplication of the panic message on purpose.
106+
act.r.log.Errorf("%s: panic during analysis: %v, %s", act.a.Name, p, string(debug.Stack()))
107+
}
106108

107109
act.err = errorutil.NewPanicError(fmt.Sprintf("%s: package %q (isInitialPkg: %t, needAnalyzeSource: %t): %s",
108110
act.a.Name, act.pkg.Name, act.isInitialPkg, act.needAnalyzeSource, p), debug.Stack())

0 commit comments

Comments
 (0)