don't run megacheck if there are not compiling packages and warn about it

This commit is contained in:
Denis Isaev 2018-06-10 09:22:21 +03:00
parent 9ed7dad894
commit f5a9bbb140
No known key found for this signature in database
GPG Key ID: A36A0EC8E27A1A01

View File

@ -8,6 +8,7 @@ import (
megacheckAPI "github.com/golangci/go-tools/cmd/megacheck"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/result"
"github.com/sirupsen/logrus"
)
type Megacheck struct {
@ -51,6 +52,17 @@ func (m Megacheck) Desc() string {
}
func (m Megacheck) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issue, error) {
if len(lintCtx.NotCompilingPackages) != 0 {
var packages []string
for _, p := range lintCtx.NotCompilingPackages {
packages = append(packages, p.String())
}
logrus.Warnf("Can't run megacheck because of compilation errors in packages "+
"%s: run `typecheck` linter to see errors", packages)
// megacheck crashes if there are not compiling packages
return nil, nil
}
issues := megacheckAPI.Run(lintCtx.Program, lintCtx.LoaderConfig, lintCtx.SSAProgram,
m.StaticcheckEnabled, m.GosimpleEnabled, m.UnusedEnabled)
if len(issues) == 0 {