@@ -5,16 +5,15 @@ import (
5
5
"slices"
6
6
"sort"
7
7
"strings"
8
+ "unicode"
9
+ "unicode/utf8"
8
10
9
11
"github.com/fatih/color"
10
- "github.com/spf13/cobra"
11
- "golang.org/x/text/cases"
12
- "golang.org/x/text/language"
13
-
14
12
"github.com/golangci/golangci-lint/pkg/config"
15
13
"github.com/golangci/golangci-lint/pkg/lint/linter"
16
14
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
17
15
"github.com/golangci/golangci-lint/pkg/logutils"
16
+ "github.com/spf13/cobra"
18
17
)
19
18
20
19
type helpCommand struct {
@@ -126,16 +125,21 @@ func printLinters(lcs []*linter.Config) {
126
125
})
127
126
128
127
for _ , lc := range lcs {
128
+ desc := lc .Linter .Desc ()
129
+
129
130
// 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' )
132
132
if firstNewline > 0 {
133
- linterDescription = linterDescription [:firstNewline ]
133
+ desc = desc [:firstNewline ]
134
134
}
135
135
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 , '.' )
139
143
}
140
144
141
145
deprecatedMark := ""
@@ -144,6 +148,6 @@ func printLinters(lcs []*linter.Config) {
144
148
}
145
149
146
150
_ , _ = 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 )
148
152
}
149
153
}
0 commit comments