setup typecheck error file if it's empty

This commit is contained in:
Denis Isaev 2018-11-18 15:50:15 +03:00
parent 27752e81a7
commit 7278b7ae8a
No known key found for this signature in database
GPG Key ID: A36A0EC8E27A1A01
3 changed files with 18 additions and 0 deletions

View File

@ -31,6 +31,16 @@ func ExtractErrors(pkg *packages.Package) []packages.Error {
}
}
// some errors like "code in directory expects import" don't have Pos, set it here
if len(pkg.GoFiles) != 0 {
for i := range uniqErrors {
err := &uniqErrors[i]
if err.Pos == "" {
err.Pos = fmt.Sprintf("%s:1", pkg.GoFiles[0])
}
}
}
return uniqErrors
}

View File

@ -83,6 +83,10 @@ func (p *AutogeneratedExclude) getOrCreateFileSummary(i *result.Issue) (*ageFile
fs = &ageFileSummary{}
p.fileSummaryCache[i.FilePath()] = fs
if i.FilePath() == "" {
return nil, fmt.Errorf("no file path for issue")
}
f := p.astCache.GetOrParse(i.FilePath(), nil)
if f.Err != nil {
return nil, fmt.Errorf("can't parse file %s: %s", i.FilePath(), f.Err)

View File

@ -83,6 +83,10 @@ func (p *Nolint) getOrCreateFileData(i *result.Issue) (*fileData, error) {
fd = &fileData{}
p.cache[i.FilePath()] = fd
if i.FilePath() == "" {
return nil, fmt.Errorf("no file path for issue")
}
file := p.astCache.GetOrParse(i.FilePath(), nil)
if file.Err != nil {
return nil, fmt.Errorf("can't parse file %s: %s", i.FilePath(), file.Err)