Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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 ./...
30 changes: 18 additions & 12 deletions pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,24 @@ func discoverGoRoot() (string, error) {
func separateNotCompilingPackages(lintCtx *golinters.Context) {
prog := lintCtx.Program

compilingCreated := make([]*loader.PackageInfo, 0, len(prog.Created))
for _, info := range prog.Created {
if len(info.Errors) != 0 {
lintCtx.NotCompilingPackages = append(lintCtx.NotCompilingPackages, info)
} else {
compilingCreated = append(compilingCreated, info)
if prog.Created != nil {
compilingCreated := make([]*loader.PackageInfo, 0, len(prog.Created))
for _, info := range prog.Created {
if len(info.Errors) != 0 {
lintCtx.NotCompilingPackages = append(lintCtx.NotCompilingPackages, info)
} else {
compilingCreated = append(compilingCreated, info)
}
}
prog.Created = compilingCreated
}
prog.Created = compilingCreated

for k, info := range prog.Imported {
if len(info.Errors) != 0 {
lintCtx.NotCompilingPackages = append(lintCtx.NotCompilingPackages, info)
delete(prog.Imported, k)
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)
}
}
}
}
Expand Down Expand Up @@ -261,7 +265,9 @@ func buildLintCtx(ctx context.Context, linters []pkg.Linter, cfg *config.Config)
ASTCache: astCache,
}

separateNotCompilingPackages(ret)
if prog != nil {
separateNotCompilingPackages(ret)
}

return ret, nil
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/golinters/typecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down