From b598dd3c5d01771624739f2419af68854027ff41 Mon Sep 17 00:00:00 2001 From: russmack Date: Fri, 7 Aug 2015 17:46:47 +0100 Subject: [PATCH] Fixed splitting lines on colons when line includes eg i := range. --- check/utils.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/check/utils.go b/check/utils.go index a5c6dbd..cf2cfd9 100644 --- a/check/utils.go +++ b/check/utils.go @@ -91,20 +91,25 @@ func getFileSummary(filename, dir, cmd, out string) (FileSummary, error) { } split := strings.Split(string(out), "\n") for _, sp := range split[0 : len(split)-1] { - parts := strings.Split(sp, ":") msg := sp - if cmd != "gocyclo" { - msg = parts[len(parts)-1] + var loc string + if cmd == "gocyclo" { + s := strings.SplitN(sp, " ", 2) + loc = s[1] + } else { + s := strings.SplitN(sp, ": ", 2) + loc = s[0] + if len(s) > 1 { + msg = s[1] + } } + e := Error{ErrorString: msg} switch cmd { case "golint", "gocyclo", "vet": - ls := strings.Split(sp, ":") - if len(ls) >= 2 && strings.Contains(sp, filename) { + ls := strings.Split(loc, ":") + if len(ls) >= 1 && strings.Contains(loc, filename) { idx := len(ls) - 2 - if cmd == "golint" { - idx = len(ls) - 3 - } if cmd == "vet" { idx = 1 }