From 827e15afce44647beda6bc6c82ce2ccf0e4c5f57 Mon Sep 17 00:00:00 2001 From: Michael Brooks Date: Mon, 28 Apr 2025 13:21:43 -0700 Subject: [PATCH] refactor: enable linter ST1005 'Incorrectly formatted error string' --- .golangci.yml | 1 - internal/api/client.go | 2 +- internal/auth/auth.go | 2 +- internal/pkg/create/create.go | 2 +- internal/pkg/platform/localserver.go | 2 +- internal/style/template.go | 2 +- internal/update/cli_metadata.go | 2 +- 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 4b17c618..f2c3bcaf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -34,7 +34,6 @@ linters: checks: - all - '-ST1003' # disable rule 'Poorly chosen identifier' - - '-ST1005' # disable rule 'Incorrectly formatted error string' - '-ST1006' # disable rule 'Poorly chosen receiver name' - '-ST1008' # disable rule 'Function’s error value should be its last return value' - '-ST1023' # disable rule 'Redundant type in variable declaration' diff --git a/internal/api/client.go b/internal/api/client.go index 3ff163e2..26cb695c 100644 --- a/internal/api/client.go +++ b/internal/api/client.go @@ -294,7 +294,7 @@ func (c *Client) DoWithRetry(ctx context.Context, request *http.Request, span op span.SetTag("status_code", r.StatusCode) if r.StatusCode != http.StatusOK { - return nil, errors.WithStack(fmt.Errorf("Slack API unexpected status code %d returned from url %s", r.StatusCode, sURL)) + return nil, errors.WithStack(fmt.Errorf("unexpected status code %d returned from url %s", r.StatusCode, sURL)) } var bytes []byte diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 61137c22..69653c6d 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -374,7 +374,7 @@ func (c *Client) SetAuth(ctx context.Context, auth types.SlackAuth) (types.Slack allAuths, err := c.auths(ctx) if err != nil { - return types.SlackAuth{}, "", fmt.Errorf("Failed to fetch user authorizations %s", err) + return types.SlackAuth{}, "", fmt.Errorf("failed to fetch user authorizations %s", err) } allAuths[auth.TeamID] = auth diff --git a/internal/pkg/create/create.go b/internal/pkg/create/create.go index b60c84c6..4b3fa07b 100644 --- a/internal/pkg/create/create.go +++ b/internal/pkg/create/create.go @@ -169,7 +169,7 @@ func getAppDirName(appName string) (string, error) { // name cannot be a reserved word if goutils.Contains(reserved, appName, false) { - return "", fmt.Errorf("The app name you entered is reserved. Please try a different name.") + return "", fmt.Errorf("the app name you entered is reserved") } return appName, nil } diff --git a/internal/pkg/platform/localserver.go b/internal/pkg/platform/localserver.go index 742c866a..498812ab 100644 --- a/internal/pkg/platform/localserver.go +++ b/internal/pkg/platform/localserver.go @@ -428,7 +428,7 @@ type SocketEvent struct { func sendWebSocketMessage(c WebSocketConnection, linkResponse *LinkResponse) error { // Validate the response if linkResponse == nil { - return slackerror.Wrap(fmt.Errorf("Websocket response message cannot be empty"), slackerror.ErrSocketConnection) + return slackerror.Wrap(fmt.Errorf("websocket response message cannot be empty"), slackerror.ErrSocketConnection) } // Prepare response for websocket diff --git a/internal/style/template.go b/internal/style/template.go index 42d1b5be..608bd8eb 100644 --- a/internal/style/template.go +++ b/internal/style/template.go @@ -111,7 +111,7 @@ func getTemplateFuncs() template.FuncMap { func PrintTemplate(w io.Writer, tmpl string, data any) (err error) { defer func() { if r := recover(); r != nil { - err = fmt.Errorf("Failed to create the template! %+v", r) + err = fmt.Errorf("failed to create the template: %+v", r) } }() t := template.New("template") diff --git a/internal/update/cli_metadata.go b/internal/update/cli_metadata.go index 26c834dc..8c4c7e0c 100644 --- a/internal/update/cli_metadata.go +++ b/internal/update/cli_metadata.go @@ -98,7 +98,7 @@ func (md *Metadata) httpClientRequest(method string, host string, data interface } if res.StatusCode != http.StatusOK { - return errors.WithStack(fmt.Errorf("Slack CLI metadata responded with an unexpected status code %d from url %s", res.StatusCode, host)) + return errors.WithStack(fmt.Errorf("CLI metadata responded with an unexpected status code %d from url %s", res.StatusCode, host)) } var bytes []byte