From 86c32e2805dea3fe281d381d2282c73225184e44 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 1 Mar 2022 12:10:29 +0100 Subject: [PATCH] logcheck: harmonize report messages If the message consists of full sentences, it should use valid spelling (upper capital at the beginning, full stop at the end). Shorter messages should be consistent with messages from other tools where lower case seems to be more common (https://grep.app/search?q=pass.Report). --- logcheck/pkg/logcheck.go | 6 +++--- logcheck/testdata/src/verbose/verbose.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/logcheck/pkg/logcheck.go b/logcheck/pkg/logcheck.go index 139d471f..38122de0 100644 --- a/logcheck/pkg/logcheck.go +++ b/logcheck/pkg/logcheck.go @@ -340,14 +340,14 @@ func isKeysValid(keyValues []ast.Expr, fun ast.Expr, pass *analysis.Pass, funNam if !ok { pass.Report(analysis.Diagnostic{ Pos: fun.Pos(), - Message: fmt.Sprintf("Key positional arguments are expected to be inlined constant strings. Please replace %v provided with string value", arg), + Message: fmt.Sprintf("Key positional arguments are expected to be inlined constant strings. Please replace %v provided with string value.", arg), }) continue } if lit.Kind != token.STRING { pass.Report(analysis.Diagnostic{ Pos: fun.Pos(), - Message: fmt.Sprintf("Key positional arguments are expected to be inlined constant strings. Please replace %v provided with string value", lit.Value), + Message: fmt.Sprintf("Key positional arguments are expected to be inlined constant strings. Please replace %v provided with string value.", lit.Value), }) continue } @@ -492,7 +492,7 @@ func checkForIfEnabled(i *ast.IfStmt, pass *analysis.Pass, c *config) { pass.Report(analysis.Diagnostic{ Pos: i.Pos(), End: i.End(), - Message: fmt.Sprintf("The result of %s should be stored in a variable and then be used multiple times: if %s := %s(); %s.Enabled() { ... %s.Info ... }", + Message: fmt.Sprintf("the result of %s should be stored in a variable and then be used multiple times: if %s := %s(); %s.Enabled() { ... %s.Info ... }", funcCall, varName, funcCall, varName, varName), }) } diff --git a/logcheck/testdata/src/verbose/verbose.go b/logcheck/testdata/src/verbose/verbose.go index b49de0c9..fa8758c0 100644 --- a/logcheck/testdata/src/verbose/verbose.go +++ b/logcheck/testdata/src/verbose/verbose.go @@ -37,11 +37,11 @@ func verboseLogging() { // \(\) is actually () in the diagnostic output. We have to escape here // because `want` expects a regular expression. - if klog.V(1).Enabled() { // want `The result of klog.V should be stored in a variable and then be used multiple times: if klogV := klog.V\(\); klogV.Enabled\(\) { ... klogV.Info ... }` + if klog.V(1).Enabled() { // want `the result of klog.V should be stored in a variable and then be used multiple times: if klogV := klog.V\(\); klogV.Enabled\(\) { ... klogV.Info ... }` klog.V(1).InfoS("I'm logging at level 1.") } - if l.V(1).Enabled() { // want `The result of l.V should be stored in a variable and then be used multiple times: if l := l.V\(\); l.Enabled\(\) { ... l.Info ... }` + if l.V(1).Enabled() { // want `the result of l.V should be stored in a variable and then be used multiple times: if l := l.V\(\); l.Enabled\(\) { ... l.Info ... }` l.V(1).Info("I'm logging at level 1.") }