diff --git a/go.mod b/go.mod index b63bff53..12e8ebb6 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( github.com/firefart/nonamedreturns v1.0.4 github.com/fzipp/gocyclo v0.6.0 github.com/ghostiam/protogetter v0.3.5 - github.com/go-critic/go-critic v0.11.2 + github.com/go-critic/go-critic v0.11.3 github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 github.com/go-xmlfmt/xmlfmt v1.1.2 github.com/gofrs/flock v0.8.1 diff --git a/go.sum b/go.sum index 223527a8..979c064e 100644 --- a/go.sum +++ b/go.sum @@ -151,8 +151,8 @@ github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/ghostiam/protogetter v0.3.5 h1:+f7UiF8XNd4w3a//4DnusQ2SZjPkUjxkMEfjbxOK4Ug= github.com/ghostiam/protogetter v0.3.5/go.mod h1:7lpeDnEJ1ZjL/YtyoN99ljO4z0pd3H0d18/t2dPBxHw= -github.com/go-critic/go-critic v0.11.2 h1:81xH/2muBphEgPtcwH1p6QD+KzXl2tMSi3hXjBSxDnM= -github.com/go-critic/go-critic v0.11.2/go.mod h1:OePaicfjsf+KPy33yq4gzv6CO7TEQ9Rom6ns1KsJnl8= +github.com/go-critic/go-critic v0.11.3 h1:SJbYD/egY1noYjTMNTlhGaYlfQ77rQmrNH7h+gtn0N0= +github.com/go-critic/go-critic v0.11.3/go.mod h1:Je0h5Obm1rR5hAGA9mP2PDiOOk53W+n7pyvXErFKIgI= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= diff --git a/pkg/printers/teamcity.go b/pkg/printers/teamcity.go index ae088691..1d1c9f7d 100644 --- a/pkg/printers/teamcity.go +++ b/pkg/printers/teamcity.go @@ -89,7 +89,7 @@ type InspectionType struct { func (i InspectionType) Print(w io.Writer, escaper *strings.Replacer) (int, error) { return fmt.Fprintf(w, "##teamcity[inspectionType id='%s' name='%s' description='%s' category='%s']\n", - limit(i.id, smallLimit), limit(i.name, smallLimit), limit(escaper.Replace(i.description), largeLimit), limit(i.category, smallLimit)) + cutVal(i.id, smallLimit), cutVal(i.name, smallLimit), cutVal(escaper.Replace(i.description), largeLimit), cutVal(i.category, smallLimit)) } // InspectionInstance reports a specific defect, warning, error message. @@ -105,15 +105,15 @@ type InspectionInstance struct { func (i InspectionInstance) Print(w io.Writer, replacer *strings.Replacer) (int, error) { return fmt.Fprintf(w, "##teamcity[inspection typeId='%s' message='%s' file='%s' line='%d' SEVERITY='%s']\n", - limit(i.typeID, smallLimit), - limit(replacer.Replace(i.message), largeLimit), - limit(i.file, largeLimit), + cutVal(i.typeID, smallLimit), + cutVal(replacer.Replace(i.message), largeLimit), + cutVal(i.file, largeLimit), i.line, strings.ToUpper(i.severity)) } -func limit(s string, max int) string { +func cutVal(s string, limit int) string { var size, count int - for i := 0; i < max && count < len(s); i++ { + for i := 0; i < limit && count < len(s); i++ { _, size = utf8.DecodeRuneInString(s[count:]) count += size } diff --git a/pkg/printers/teamcity_test.go b/pkg/printers/teamcity_test.go index 31e31875..f333a3b6 100644 --- a/pkg/printers/teamcity_test.go +++ b/pkg/printers/teamcity_test.go @@ -66,7 +66,7 @@ func TestTeamCity_Print(t *testing.T) { assert.Equal(t, expected, buf.String()) } -func TestTeamCity_limit(t *testing.T) { +func TestTeamCity_cutVal(t *testing.T) { tests := []struct { input string max int @@ -100,6 +100,6 @@ func TestTeamCity_limit(t *testing.T) { } for _, tc := range tests { - require.Equal(t, tc.expected, limit(tc.input, tc.max)) + require.Equal(t, tc.expected, cutVal(tc.input, tc.max)) } }