Skip to content

Commit 127edc0

Browse files
authored
dev: simplify cutVal implementation (#5206)
1 parent e955af1 commit 127edc0

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

pkg/printers/teamcity.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"io"
66
"strings"
7-
"unicode/utf8"
87

98
"github.com/golangci/golangci-lint/pkg/result"
109
)
@@ -112,11 +111,9 @@ func (i InspectionInstance) Print(w io.Writer, replacer *strings.Replacer) (int,
112111
}
113112

114113
func cutVal(s string, limit int) string {
115-
var size, count int
116-
for i := 0; i < limit && count < len(s); i++ {
117-
_, size = utf8.DecodeRuneInString(s[count:])
118-
count += size
114+
runes := []rune(s)
115+
if len(runes) > limit {
116+
return string(runes[:limit])
119117
}
120-
121-
return s[:count]
118+
return s
122119
}

0 commit comments

Comments
 (0)