Skip to content

Commit e56b966

Browse files
committed
review: be consistent with the code of the documentation
1 parent 4b090e1 commit e56b966

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"slices"
66
"sort"
77
"strings"
8+
"unicode"
9+
"unicode/utf8"
810

911
"github.com/fatih/color"
1012
"github.com/spf13/cobra"
11-
"golang.org/x/text/cases"
12-
"golang.org/x/text/language"
1313

1414
"github.com/golangci/golangci-lint/pkg/config"
1515
"github.com/golangci/golangci-lint/pkg/lint/linter"
@@ -126,16 +126,21 @@ func printLinters(lcs []*linter.Config) {
126126
})
127127

128128
for _, lc := range lcs {
129+
desc := lc.Linter.Desc()
130+
129131
// If the linter description spans multiple lines, truncate everything following the first newline
130-
linterDescription := lc.Linter.Desc()
131-
firstNewline := strings.IndexRune(linterDescription, '\n')
132-
if firstNewline > 0 {
133-
linterDescription = linterDescription[:firstNewline]
132+
endFirstLine := strings.IndexRune(desc, '\n')
133+
if endFirstLine > 0 {
134+
desc = desc[:endFirstLine]
134135
}
135136

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
137+
rawDesc := []rune(desc)
138+
139+
r, _ := utf8.DecodeRuneInString(desc)
140+
rawDesc[0] = unicode.ToUpper(r)
141+
142+
if rawDesc[len(rawDesc)-1] != '.' {
143+
rawDesc = append(rawDesc, '.')
139144
}
140145

141146
deprecatedMark := ""
@@ -144,6 +149,6 @@ func printLinters(lcs []*linter.Config) {
144149
}
145150

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

0 commit comments

Comments
 (0)