#40: fix panic in fast mode
This commit is contained in:
parent
0eb6aa7c59
commit
5646c61c73
6
Makefile
6
Makefile
@ -1,4 +1,8 @@
|
||||
test:
|
||||
go install ./cmd/...
|
||||
golangci-lint run
|
||||
golangci-lint run -v
|
||||
golangci-lint run --fast --no-config -v
|
||||
golangci-lint run --fast --no-config -v
|
||||
golangci-lint run --no-config -v
|
||||
golangci-lint run --fast --no-config -v ./pkg/testdata/with_issues/typecheck.go
|
||||
go test -v -race ./...
|
||||
|
@ -196,6 +196,7 @@ func discoverGoRoot() (string, error) {
|
||||
func separateNotCompilingPackages(lintCtx *golinters.Context) {
|
||||
prog := lintCtx.Program
|
||||
|
||||
if prog.Created != nil {
|
||||
compilingCreated := make([]*loader.PackageInfo, 0, len(prog.Created))
|
||||
for _, info := range prog.Created {
|
||||
if len(info.Errors) != 0 {
|
||||
@ -205,13 +206,16 @@ func separateNotCompilingPackages(lintCtx *golinters.Context) {
|
||||
}
|
||||
}
|
||||
prog.Created = compilingCreated
|
||||
}
|
||||
|
||||
if prog.Imported != nil {
|
||||
for k, info := range prog.Imported {
|
||||
if len(info.Errors) != 0 {
|
||||
lintCtx.NotCompilingPackages = append(lintCtx.NotCompilingPackages, info)
|
||||
delete(prog.Imported, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func buildLintCtx(ctx context.Context, linters []pkg.Linter, cfg *config.Config) (*golinters.Context, error) {
|
||||
@ -261,7 +265,9 @@ func buildLintCtx(ctx context.Context, linters []pkg.Linter, cfg *config.Config)
|
||||
ASTCache: astCache,
|
||||
}
|
||||
|
||||
if prog != nil {
|
||||
separateNotCompilingPackages(ret)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
@ -62,6 +62,10 @@ func (lint TypeCheck) parseError(err error) *result.Issue {
|
||||
}
|
||||
|
||||
func (lint TypeCheck) Run(ctx context.Context, lintCtx *Context) ([]result.Issue, error) {
|
||||
if lintCtx.NotCompilingPackages == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var res []result.Issue
|
||||
for _, pkg := range lintCtx.NotCompilingPackages {
|
||||
for _, err := range pkg.Errors {
|
||||
|
Loading…
x
Reference in New Issue
Block a user