Fix: goheader linter can throw nil pointer exception in case of a source file has not issues ()

* fix potential nil pointer exception

Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com>

* add test to cover

Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com>
This commit is contained in:
Denis Tingaikin 2020-07-05 15:32:00 +07:00 committed by GitHub
parent afa9be632b
commit dfa0013583
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 0 deletions

View file

@ -193,6 +193,9 @@ func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext
skipMultilineComment(scanner)
continue
}
if strings.TrimSpace(line) == "" {
continue
}
if !strings.HasPrefix(line, "//") {
return rc
}