Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lint): Update staticcheck and fix identified problems. #1346

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading