From a52e4389ec6a66535f40864c7f5aed8667bf2798 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 9 Dec 2024 13:14:56 +0200 Subject: [PATCH 1/3] dev: enhance help linters output on fast and auto-fix capabilities --- pkg/commands/help.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/commands/help.go b/pkg/commands/help.go index c86b2068d6f9..11d99ba3aa62 100644 --- a/pkg/commands/help.go +++ b/pkg/commands/help.go @@ -148,7 +148,18 @@ func printLinters(lcs []*linter.Config) { deprecatedMark = " [" + color.RedString("deprecated") + "]" } - _, _ = fmt.Fprintf(logutils.StdOut, "%s%s: %s [fast: %t, auto-fix: %t]\n", - color.YellowString(lc.Name()), deprecatedMark, string(rawDesc), !lc.IsSlowLinter(), lc.CanAutoFix) + var capability string + switch isFast := !lc.IsSlowLinter(); { + case isFast && lc.CanAutoFix: + capability = " [" + color.GreenString("fast, auto-fix") + "]" + case isFast: + capability = " [" + color.GreenString("fast") + "]" + case lc.CanAutoFix: + capability = " [" + color.GreenString("auto-fix") + "]" + default: + } + + _, _ = fmt.Fprintf(logutils.StdOut, "%s%s: %s%s\n", + color.YellowString(lc.Name()), deprecatedMark, string(rawDesc), capability) } } From e5653d2464bf73cbf3564030e8012f70ada5f667 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 9 Dec 2024 18:21:31 +0100 Subject: [PATCH 2/3] review: simplify --- pkg/commands/help.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/commands/help.go b/pkg/commands/help.go index 11d99ba3aa62..7613b59e26af 100644 --- a/pkg/commands/help.go +++ b/pkg/commands/help.go @@ -148,15 +148,17 @@ func printLinters(lcs []*linter.Config) { deprecatedMark = " [" + color.RedString("deprecated") + "]" } + var capabilities []string + if !lc.IsSlowLinter() { + capabilities = append(capabilities, color.GreenString("fast")) + } + if lc.CanAutoFix { + capabilities = append(capabilities, color.GreenString("auto-fix")) + } + var capability string - switch isFast := !lc.IsSlowLinter(); { - case isFast && lc.CanAutoFix: - capability = " [" + color.GreenString("fast, auto-fix") + "]" - case isFast: - capability = " [" + color.GreenString("fast") + "]" - case lc.CanAutoFix: - capability = " [" + color.GreenString("auto-fix") + "]" - default: + if capabilities != nil { + capability = " [" + strings.Join(capabilities, ", ") + "]" } _, _ = fmt.Fprintf(logutils.StdOut, "%s%s: %s%s\n", From c29a523ebbbe904633f8bc65a11d1ea80e91fea1 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 9 Dec 2024 18:23:09 +0100 Subject: [PATCH 3/3] review: use a more neutral color - fast: blue - auto-fix: green --- pkg/commands/help.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/commands/help.go b/pkg/commands/help.go index 7613b59e26af..a3c052840e1c 100644 --- a/pkg/commands/help.go +++ b/pkg/commands/help.go @@ -150,7 +150,7 @@ func printLinters(lcs []*linter.Config) { var capabilities []string if !lc.IsSlowLinter() { - capabilities = append(capabilities, color.GreenString("fast")) + capabilities = append(capabilities, color.BlueString("fast")) } if lc.CanAutoFix { capabilities = append(capabilities, color.GreenString("auto-fix"))