Skip to content

Commit cb55604

Browse files
committed
review
1 parent 4b090e1 commit cb55604

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ require (
131131
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
132132
golang.org/x/mod v0.22.0
133133
golang.org/x/sys v0.28.0
134-
golang.org/x/text v0.20.0
135134
golang.org/x/tools v0.28.0
136135
gopkg.in/yaml.v3 v3.0.1
137136
honnef.co/go/tools v0.5.1
@@ -200,6 +199,7 @@ require (
200199
go.uber.org/zap v1.24.0 // indirect
201200
golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect
202201
golang.org/x/sync v0.10.0 // indirect
202+
golang.org/x/text v0.20.0 // indirect
203203
google.golang.org/protobuf v1.34.2 // indirect
204204
gopkg.in/ini.v1 v1.67.0 // indirect
205205
gopkg.in/yaml.v2 v2.4.0 // indirect

pkg/commands/help.go

+15-11
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ import (
55
"slices"
66
"sort"
77
"strings"
8+
"unicode"
9+
"unicode/utf8"
810

911
"github.com/fatih/color"
10-
"github.com/spf13/cobra"
11-
"golang.org/x/text/cases"
12-
"golang.org/x/text/language"
13-
1412
"github.com/golangci/golangci-lint/pkg/config"
1513
"github.com/golangci/golangci-lint/pkg/lint/linter"
1614
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
1715
"github.com/golangci/golangci-lint/pkg/logutils"
16+
"github.com/spf13/cobra"
1817
)
1918

2019
type helpCommand struct {
@@ -126,16 +125,21 @@ func printLinters(lcs []*linter.Config) {
126125
})
127126

128127
for _, lc := range lcs {
128+
desc := lc.Linter.Desc()
129+
129130
// If the linter description spans multiple lines, truncate everything following the first newline
130-
linterDescription := lc.Linter.Desc()
131-
firstNewline := strings.IndexRune(linterDescription, '\n')
131+
firstNewline := strings.IndexRune(desc, '\n')
132132
if firstNewline > 0 {
133-
linterDescription = linterDescription[:firstNewline]
133+
desc = desc[:firstNewline]
134134
}
135135

136-
// Capitalize the first word of the linter description
137-
if firstWord, remaining, ok := strings.Cut(linterDescription, " "); ok {
138-
linterDescription = cases.Title(language.Und, cases.NoLower).String(firstWord) + " " + remaining
136+
rawDesc := []rune(desc)
137+
138+
r, _ := utf8.DecodeRuneInString(desc)
139+
rawDesc[0] = unicode.ToUpper(r)
140+
141+
if rawDesc[len(rawDesc)-1] != '.' {
142+
rawDesc = append(rawDesc, '.')
139143
}
140144

141145
deprecatedMark := ""
@@ -144,6 +148,6 @@ func printLinters(lcs []*linter.Config) {
144148
}
145149

146150
_, _ = fmt.Fprintf(logutils.StdOut, "%s%s: %s [fast: %t, auto-fix: %t]\n",
147-
color.YellowString(lc.Name()), deprecatedMark, linterDescription, !lc.IsSlowLinter(), lc.CanAutoFix)
151+
color.YellowString(lc.Name()), deprecatedMark, string(rawDesc), !lc.IsSlowLinter(), lc.CanAutoFix)
148152
}
149153
}

0 commit comments

Comments
 (0)