Skip to content

Commit f5a9bbb

Browse files
committed
don't run megacheck if there are not compiling packages and warn about it
1 parent 9ed7dad commit f5a9bbb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/golinters/megacheck.go

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
megacheckAPI "github.com/golangci/go-tools/cmd/megacheck"
99
"github.com/golangci/golangci-lint/pkg/lint/linter"
1010
"github.com/golangci/golangci-lint/pkg/result"
11+
"github.com/sirupsen/logrus"
1112
)
1213

1314
type Megacheck struct {
@@ -51,6 +52,17 @@ func (m Megacheck) Desc() string {
5152
}
5253

5354
func (m Megacheck) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issue, error) {
55+
if len(lintCtx.NotCompilingPackages) != 0 {
56+
var packages []string
57+
for _, p := range lintCtx.NotCompilingPackages {
58+
packages = append(packages, p.String())
59+
}
60+
logrus.Warnf("Can't run megacheck because of compilation errors in packages "+
61+
"%s: run `typecheck` linter to see errors", packages)
62+
// megacheck crashes if there are not compiling packages
63+
return nil, nil
64+
}
65+
5466
issues := megacheckAPI.Run(lintCtx.Program, lintCtx.LoaderConfig, lintCtx.SSAProgram,
5567
m.StaticcheckEnabled, m.GosimpleEnabled, m.UnusedEnabled)
5668
if len(issues) == 0 {

0 commit comments

Comments
 (0)