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

Enable and fix perfsprint linter #929

Merged
merged 1 commit into from
Apr 29, 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
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ linters:
- nilnil
- nonamedreturns
- nosprintfhostport
- perfsprint
- prealloc
- predeclared
- promlinter
Expand Down
4 changes: 1 addition & 3 deletions commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package commands

import (
"fmt"

"github.com/spf13/cobra"

"sigs.k8s.io/release-utils/log"
Expand Down Expand Up @@ -67,7 +65,7 @@ func New(opts Options) *cobra.Command {
&rootOpts.logLevel,
"log-level",
"info",
fmt.Sprintf("the logging verbosity, either %s", log.LevelNames()),
"the logging verbosity, either "+log.LevelNames(),
)

AddCommands(cmd)
Expand Down
3 changes: 2 additions & 1 deletion commands/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package commands

import (
"encoding/json"
"errors"
"fmt"
"os"

Expand Down Expand Up @@ -57,7 +58,7 @@ func (exo *exportOptions) setAndValidate() error {
case JSON:
case LOG:
default:
return fmt.Errorf("unsuported output format")
return errors.New("unsuported output format")
}

if exo.outputFile != "" && OutputFormat(exo.outputFormat) == LOG {
Expand Down
3 changes: 2 additions & 1 deletion commands/set_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package commands

import (
"errors"
"fmt"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -46,7 +47,7 @@ func addSetVersion(topLevel *cobra.Command) {
// upgrading/downgrading a single dependency to the specified version.
func runSetVersion(opts *options, args []string) error {
if len(args) != 2 {
return fmt.Errorf("expected exactly two arguments: <dependency> <version>")
return errors.New("expected exactly two arguments: <dependency> <version>")
}

client, err := dependency.NewLocalClient()
Expand Down
3 changes: 2 additions & 1 deletion pkg/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package gitlab

import (
"errors"
"fmt"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -179,7 +180,7 @@ func (g *GitLab) GetRepository(owner, repo string) (*gitlab.Project, error) {
}

if len(projects) == 0 {
return nil, fmt.Errorf("no project found")
return nil, errors.New("no project found")
}

return projects[0], nil
Expand Down