Skip to content
This repository was archived by the owner on May 9, 2021. It is now read-only.

Prevent panic in case there are no files to check. #299

Closed
wants to merge 2 commits into from
Closed
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: 3 additions & 3 deletions lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ func (l *Linter) Lint(filename string, src []byte) ([]Problem, error) {
// LintFiles lints a set of files of a single package.
// The argument is a map of filename to source.
func (l *Linter) LintFiles(files map[string][]byte) ([]Problem, error) {
if len(files) == 0 {
return nil, nil
}
pkg := &pkg{
fset: token.NewFileSet(),
files: make(map[string]*file),
Expand All @@ -111,6 +108,9 @@ func (l *Linter) LintFiles(files map[string][]byte) ([]Problem, error) {
filename: filename,
}
}
if len(pkg.files) == 0 {
return nil, nil
}
return pkg.lint(), nil
}

Expand Down