Skip to content

Commit

Permalink
dev: simplify cutVal implementation (#5206)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear authored Dec 8, 2024
1 parent e955af1 commit 127edc0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/printers/teamcity.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"io"
"strings"
"unicode/utf8"

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

func cutVal(s string, limit int) string {
var size, count int
for i := 0; i < limit && count < len(s); i++ {
_, size = utf8.DecodeRuneInString(s[count:])
count += size
runes := []rune(s)
if len(runes) > limit {
return string(runes[:limit])
}

return s[:count]
return s
}

0 comments on commit 127edc0

Please sign in to comment.