check len s before assigning loc for gocyclo

This commit is contained in:
Shawn Smith
2015-09-10 15:07:14 +09:00
parent 6cb91be295
commit 00eafa6527

View File

@@ -95,7 +95,9 @@ func getFileSummary(filename, dir, cmd, out string) (FileSummary, error) {
var loc string
if cmd == "gocyclo" {
s := strings.SplitN(sp, " ", 2)
loc = s[1]
if len(s) > 1 {
loc = s[1]
}
} else {
s := strings.SplitN(sp, ": ", 2)
loc = s[0]