Skip to content

Commit

Permalink
fix: many linting issues
Browse files Browse the repository at this point in the history
refs #3874

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Mar 20, 2023
1 parent c849cfc commit a459911
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 38 deletions.
6 changes: 3 additions & 3 deletions internal/client/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ func NewGitea(ctx *context.Context, token string) (Client, error) {
return &giteaClient{client: client}, nil
}

func (c *giteaClient) Changelog(ctx *context.Context, repo Repo, prev, current string) (string, error) {
func (c *giteaClient) Changelog(_ *context.Context, _ Repo, _, _ string) (string, error) {
return "", ErrNotImplemented
}

// CloseMilestone closes a given milestone.
func (c *giteaClient) CloseMilestone(ctx *context.Context, repo Repo, title string) error {
func (c *giteaClient) CloseMilestone(_ *context.Context, repo Repo, title string) error {
closedState := gitea.StateClosed
opts := gitea.EditMilestoneOption{
State: &closedState,
Expand All @@ -87,7 +87,7 @@ func (c *giteaClient) CloseMilestone(ctx *context.Context, repo Repo, title stri
return err
}

func (c *giteaClient) GetDefaultBranch(ctx *context.Context, repo Repo) (string, error) {
func (c *giteaClient) GetDefaultBranch(_ *context.Context, repo Repo) (string, error) {
projectID := repo.String()
p, res, err := c.client.GetRepo(repo.Owner, repo.Name)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/client/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewGitLab(ctx *context.Context, token string) (Client, error) {
return &gitlabClient{client: client}, nil
}

func (c *gitlabClient) Changelog(ctx *context.Context, repo Repo, prev, current string) (string, error) {
func (c *gitlabClient) Changelog(_ *context.Context, repo Repo, prev, current string) (string, error) {
cmpOpts := &gitlab.CompareOptions{
From: &prev,
To: &current,
Expand All @@ -82,7 +82,7 @@ func (c *gitlabClient) Changelog(ctx *context.Context, repo Repo, prev, current
}

// GetDefaultBranch get the default branch
func (c *gitlabClient) GetDefaultBranch(ctx *context.Context, repo Repo) (string, error) {
func (c *gitlabClient) GetDefaultBranch(_ *context.Context, repo Repo) (string, error) {
projectID := repo.String()
p, res, err := c.client.Projects.GetProject(projectID, nil)
if err != nil {
Expand All @@ -97,7 +97,7 @@ func (c *gitlabClient) GetDefaultBranch(ctx *context.Context, repo Repo) (string
}

// CloseMilestone closes a given milestone.
func (c *gitlabClient) CloseMilestone(ctx *context.Context, repo Repo, title string) error {
func (c *gitlabClient) CloseMilestone(_ *context.Context, repo Repo, title string) error {
milestone, err := c.getMilestoneByTitle(repo, title)
if err != nil {
return err
Expand Down
16 changes: 8 additions & 8 deletions internal/client/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ type Mock struct {
ReleaseNotesParams []string
}

func (c *Mock) Changelog(ctx *context.Context, repo Repo, prev, current string) (string, error) {
func (c *Mock) Changelog(_ *context.Context, _ Repo, _, _ string) (string, error) {
if c.Changes != "" {
return c.Changes, nil
}
return "", ErrNotImplemented
}

func (c *Mock) GenerateReleaseNotes(ctx *context.Context, repo Repo, prev, current string) (string, error) {
func (c *Mock) GenerateReleaseNotes(_ *context.Context, _ Repo, prev, current string) (string, error) {
if c.ReleaseNotes != "" {
c.ReleaseNotesParams = []string{prev, current}
return c.ReleaseNotes, nil
}
return "", ErrNotImplemented
}

func (c *Mock) CloseMilestone(ctx *context.Context, repo Repo, title string) error {
func (c *Mock) CloseMilestone(_ *context.Context, _ Repo, title string) error {
if c.FailToCloseMilestone {
return errors.New("milestone failed")
}
Expand All @@ -65,30 +65,30 @@ func (c *Mock) CloseMilestone(ctx *context.Context, repo Repo, title string) err
return nil
}

func (c *Mock) GetDefaultBranch(ctx *context.Context, repo Repo) (string, error) {
func (c *Mock) GetDefaultBranch(_ *context.Context, _ Repo) (string, error) {
return "", ErrNotImplemented
}

func (c *Mock) CreateRelease(ctx *context.Context, body string) (string, error) {
func (c *Mock) CreateRelease(_ *context.Context, _ string) (string, error) {
if c.FailToCreateRelease {
return "", errors.New("release failed")
}
c.CreatedRelease = true
return "", nil
}

func (c *Mock) ReleaseURLTemplate(ctx *context.Context) (string, error) {
func (c *Mock) ReleaseURLTemplate(_ *context.Context) (string, error) {
return "https://dummyhost/download/{{ .Tag }}/{{ .ArtifactName }}", nil
}

func (c *Mock) CreateFile(ctx *context.Context, commitAuthor config.CommitAuthor, repo Repo, content []byte, path, msg string) error {
func (c *Mock) CreateFile(_ *context.Context, _ config.CommitAuthor, _ Repo, content []byte, path, _ string) error {
c.CreatedFile = true
c.Content = string(content)
c.Path = path
return nil
}

func (c *Mock) Upload(ctx *context.Context, releaseID string, artifact *artifact.Artifact, file *os.File) error {
func (c *Mock) Upload(_ *context.Context, _ string, artifact *artifact.Artifact, file *os.File) error {
c.Lock.Lock()
defer c.Lock.Unlock()
if c.UploadedFilePaths == nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/gio/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ func copyFile(src, dst string, mode os.FileMode) error {
}
defer original.Close()

new, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, mode)
f, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, mode)
if err != nil {
return fmt.Errorf("failed to open '%s': %w", dst, err)
}
defer new.Close()
defer f.Close()

if _, err := io.Copy(new, original); err != nil {
if _, err := io.Copy(f, original); err != nil {
return fmt.Errorf("failed to copy: %w", err)
}
return nil
Expand Down
5 changes: 1 addition & 4 deletions internal/pipe/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ func (Pipe) Run(ctx *context.Context) error {
continue
}
g.Go(func() error {
if err := create(ctx, archive, artifacts); err != nil {
return err
}
return nil
return create(ctx, archive, artifacts)
})
}
}
Expand Down
5 changes: 2 additions & 3 deletions internal/pipe/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (f *fakeBuilder) WithDefaults(build config.Build) (config.Build, error) {
return build, nil
}

func (f *fakeBuilder) Build(ctx *context.Context, build config.Build, options api.Options) error {
func (f *fakeBuilder) Build(ctx *context.Context, _ config.Build, options api.Options) error {
if f.fail {
return errFailedBuild
}
Expand Down Expand Up @@ -90,8 +90,7 @@ func TestBuild(t *testing.T) {
)
opts, err := buildOptionsForTarget(ctx, ctx.Config.Builds[0], "darwin_amd64")
require.NoError(t, err)
error := doBuild(ctx, ctx.Config.Builds[0], *opts)
require.NoError(t, error)
require.NoError(t, doBuild(ctx, ctx.Config.Builds[0], *opts))
}

func TestRunPipe(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions internal/pipe/chocolatey/chocolatey.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ var cmd cmder = stdCmd{}
// Pipe for chocolatey packaging.
type Pipe struct{}

func (Pipe) String() string { return "chocolatey packages" }
func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.Chocolateys) == 0 }
func (Pipe) Dependencies(ctx *context.Context) []string { return []string{"choco"} }
func (Pipe) String() string { return "chocolatey packages" }
func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.Chocolateys) == 0 }
func (Pipe) Dependencies(_ *context.Context) []string { return []string{"choco"} }

// Default sets the pipe defaults.
func (Pipe) Default(ctx *context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/pipe/chocolatey/chocolatey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,6 @@ type fakeCmd struct {

var _ cmder = fakeCmd{}

func (f fakeCmd) Exec(ctx *context.Context, name string, args ...string) ([]byte, error) {
func (f fakeCmd) Exec(_ *context.Context, _ string, _ ...string) ([]byte, error) {
return f.execFn()
}
2 changes: 1 addition & 1 deletion internal/pipe/docker/api_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type dockerImager struct {

var dockerDigestPattern = regexp.MustCompile("sha256:[a-z0-9]{64}")

func (i dockerImager) Push(ctx *context.Context, image string, flags []string) (string, error) {
func (i dockerImager) Push(ctx *context.Context, image string, _ []string) (string, error) {
bts, err := runCommandWithOutput(ctx, ".", "docker", "push", image)
if err != nil {
return "", fmt.Errorf("failed to push %s: %w", image, err)
Expand Down
4 changes: 2 additions & 2 deletions internal/pipe/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
// Pipe implementation.
type Pipe struct{}

func (Pipe) String() string { return "storing release metadata" }
func (Pipe) Skip(ctx *context.Context) bool { return false }
func (Pipe) String() string { return "storing release metadata" }
func (Pipe) Skip(_ *context.Context) bool { return false }

// Run the pipe.
func (Pipe) Run(ctx *context.Context) error {
Expand Down
6 changes: 3 additions & 3 deletions internal/pipe/snapcraft/snapcraft.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ const defaultNameTemplate = `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arc
// Pipe for snapcraft packaging.
type Pipe struct{}

func (Pipe) String() string { return "snapcraft packages" }
func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.Snapcrafts) == 0 }
func (Pipe) Dependencies(ctx *context.Context) []string { return []string{"snapcraft"} }
func (Pipe) String() string { return "snapcraft packages" }
func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.Snapcrafts) == 0 }
func (Pipe) Dependencies(_ *context.Context) []string { return []string{"snapcraft"} }

// Default sets the pipe defaults.
func (Pipe) Default(ctx *context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (*dummy) WithDefaults(build config.Build) (config.Build, error) {
return build, nil
}

func (*dummy) Build(ctx *context.Context, build config.Build, options Options) error {
func (*dummy) Build(_ *context.Context, _ config.Build, _ Options) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ nfpms:

type errorReader struct{}

func (errorReader) Read(p []byte) (n int, err error) {
func (errorReader) Read(_ []byte) (n int, err error) {
return 1, fmt.Errorf("error")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ var Healthcheckers = []Healthchecker{

type system struct{}

func (system) String() string { return "system" }
func (system) Dependencies(ctx *context.Context) []string { return []string{"git", "go"} }
func (system) String() string { return "system" }
func (system) Dependencies(_ *context.Context) []string { return []string{"git", "go"} }

0 comments on commit a459911

Please sign in to comment.