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