Skip to content

Commit 95a942a

Browse files
jlucktayashanbrown
authored andcommitted
fix(cmd/linters): truncate multiline descriptions (golangci#1663)
1 parent 7d27e03 commit 95a942a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/commands/help.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,16 @@ func printLinterConfigs(lcs []*linter.Config) {
4545
if len(lc.AlternativeNames) != 0 {
4646
altNamesStr = fmt.Sprintf(" (%s)", strings.Join(lc.AlternativeNames, ", "))
4747
}
48+
49+
// If the linter description spans multiple lines, truncate everything following the first newline
50+
linterDescription := lc.Linter.Desc()
51+
firstNewline := strings.IndexRune(linterDescription, '\n')
52+
if firstNewline > 0 {
53+
linterDescription = linterDescription[:firstNewline]
54+
}
55+
4856
fmt.Fprintf(logutils.StdOut, "%s%s: %s [fast: %t, auto-fix: %t]\n", color.YellowString(lc.Name()),
49-
altNamesStr, lc.Linter.Desc(), !lc.IsSlowLinter(), lc.CanAutoFix)
57+
altNamesStr, linterDescription, !lc.IsSlowLinter(), lc.CanAutoFix)
5058
}
5159
}
5260

0 commit comments

Comments
 (0)