Skip to content

Commit

Permalink
fix(lint): Update staticcheck and fix identified problems. (#1346)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpfleming authored Nov 12, 2024
1 parent 6155e7b commit eae9ee8
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ github.com/goreleaser/goreleaser/v2@latest
github.com/mgechev/revive@latest
github.com/securego/gosec/v2/cmd/gosec@latest
golang.org/x/tools/cmd/goimports@latest
honnef.co/go/tools/cmd/staticcheck@2023.1.7
honnef.co/go/tools/cmd/staticcheck@latest
4 changes: 2 additions & 2 deletions pkg/commands/compute/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,12 @@ func validateTemplateOptionOrURL(templates []config.StarterKit) func(string) err
}
if option, err := strconv.Atoi(input); err == nil {
if option > len(templates) {
return fmt.Errorf(msg)
return errors.New(msg)
}
return nil
}
if !gitRepositoryRegEx.MatchString(input) {
return fmt.Errorf(msg)
return errors.New(msg)
}
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/commands/logtail/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,11 @@ func findIdxBySeq(logs []Log, seq int) int {
// highSequence returns the highest SequenceNum
// in a slice of logs.
func highSequence(logs []Log) int {
var max int
var maximum int
for _, l := range logs {
if l.SequenceNum > max {
max = l.SequenceNum
if l.SequenceNum > maximum {
maximum = l.SequenceNum
}
}
return max
return maximum
}
4 changes: 2 additions & 2 deletions pkg/commands/profile/list.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package profile

import (
"fmt"
"errors"
"io"

"github.com/fastly/cli/pkg/argparser"
Expand Down Expand Up @@ -41,7 +41,7 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error {
if c.Globals.Config.Profiles == nil {
msg := "no profiles available"
return fsterr.RemediationError{
Inner: fmt.Errorf(msg),
Inner: errors.New(msg),
Remediation: fsterr.ProfileRemediation,
}
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/commands/profile/token.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package profile

import (
"errors"
"fmt"
"io"
"time"
Expand Down Expand Up @@ -57,7 +58,7 @@ func (c *TokenCommand) Exec(_ io.Reader, out io.Writer) (err error) {
}
msg := fmt.Sprintf(profile.DoesNotExist, name)
return fsterr.RemediationError{
Inner: fmt.Errorf(msg),
Inner: errors.New(msg),
Remediation: fsterr.ProfileRemediation,
}
}
Expand All @@ -71,7 +72,7 @@ func (c *TokenCommand) Exec(_ io.Reader, out io.Writer) (err error) {
return nil
}
return fsterr.RemediationError{
Inner: fmt.Errorf("no profiles available"),
Inner: errors.New("no profiles available"),
Remediation: fsterr.ProfileRemediation,
}
}
Expand All @@ -95,7 +96,7 @@ func checkTokenValidity(profileName string, p *config.Profile, ttl time.Duration
}

return fsterr.RemediationError{
Inner: fmt.Errorf(msg),
Inner: errors.New(msg),
Remediation: fsterr.TokenExpirationRemediation,
}
}
4 changes: 2 additions & 2 deletions pkg/commands/profile/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (c *UpdateCommand) identifyProfile() (string, *config.Profile, error) {
if p == nil {
msg := fmt.Sprintf(profile.DoesNotExist, c.profile)
return "", nil, fsterr.RemediationError{
Inner: fmt.Errorf(msg),
Inner: errors.New(msg),
Remediation: fsterr.ProfileRemediation,
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ func (c *UpdateCommand) staticTokenFlow(profileName string, p *config.Profile, i
if !ok {
msg := fmt.Sprintf(profile.DoesNotExist, profileName)
return fsterr.RemediationError{
Inner: fmt.Errorf(msg),
Inner: errors.New(msg),
Remediation: fsterr.ProfileRemediation,
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/errors/deduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func SimplifyFastlyError(httpError fastly.HTTPError) error {
if detail := httpError.Errors[0].Detail; detail != "" {
s += fmt.Sprintf(" (%s)", detail)
}
return fmt.Errorf(s)
return errors.New(s)

default:
return fmt.Errorf(
Expand Down

0 comments on commit eae9ee8

Please sign in to comment.