fix(cmd/linters): truncate multiline descriptions (#1663)

This commit is contained in:
James Lucktaylor 2021-02-07 03:35:31 +00:00 committed by GitHub
parent 6c1c9ccb97
commit 000a815656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,8 +45,16 @@ func printLinterConfigs(lcs []*linter.Config) {
if len(lc.AlternativeNames) != 0 {
altNamesStr = fmt.Sprintf(" (%s)", strings.Join(lc.AlternativeNames, ", "))
}
// If the linter description spans multiple lines, truncate everything following the first newline
linterDescription := lc.Linter.Desc()
firstNewline := strings.IndexRune(linterDescription, '\n')
if firstNewline > 0 {
linterDescription = linterDescription[:firstNewline]
}
fmt.Fprintf(logutils.StdOut, "%s%s: %s [fast: %t, auto-fix: %t]\n", color.YellowString(lc.Name()),
altNamesStr, lc.Linter.Desc(), !lc.IsSlowLinter(), lc.CanAutoFix)
altNamesStr, linterDescription, !lc.IsSlowLinter(), lc.CanAutoFix)
}
}