Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
chore(deps): bump github.com/golangci/golangci-lint from 1.31.0 to 1.…
…32.2 (#1882)

* chore(deps): bump github.com/golangci/golangci-lint

Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.31.0 to 1.32.2.
- [Release notes](https://github.com/golangci/golangci-lint/releases)
- [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md)
- [Commits](golangci/golangci-lint@v1.31.0...v1.32.2)

Signed-off-by: dependabot[bot] <support@github.com>

* fix: lint issues

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* refactor: lint issues

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
dependabot[bot] and caarlos0 committed Nov 10, 2020
1 parent c125fe3 commit 27aa687
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Expand Up @@ -18,3 +18,5 @@ linters:
- gofumpt
- gci
- nlreturn
- exhaustivestruct
- wrapcheck
4 changes: 3 additions & 1 deletion cmd/root.go
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"
"os"

Expand Down Expand Up @@ -33,7 +34,8 @@ func (cmd *rootCmd) Execute(args []string) {
if err := cmd.cmd.Execute(); err != nil {
var code = 1
var msg = "command failed"
if eerr, ok := err.(*exitError); ok {
var eerr = &exitError{}
if errors.As(err, &eerr) {
code = eerr.code
if eerr.details != "" {
msg = eerr.details
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -10,7 +10,7 @@ require (
github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e
github.com/client9/misspell v0.3.4
github.com/fatih/color v1.10.0
github.com/golangci/golangci-lint v1.31.0
github.com/golangci/golangci-lint v1.32.2
github.com/google/go-github/v28 v28.1.1
github.com/goreleaser/nfpm v1.9.0
github.com/hashicorp/go-version v1.2.1 // indirect
Expand Down
61 changes: 61 additions & 0 deletions go.sum

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions internal/client/client.go
Expand Up @@ -2,6 +2,7 @@
package client

import (
"errors"
"fmt"
"os"

Expand Down Expand Up @@ -85,6 +86,8 @@ func (e RetriableError) Error() string {
return e.Err.Error()
}

// NotImplementedError happens when trying to use something a client does not
// implement.
type NotImplementedError struct {
TokenType context.TokenType
}
Expand All @@ -93,7 +96,7 @@ func (e NotImplementedError) Error() string {
return fmt.Sprintf("not implemented for %s", e.TokenType)
}

// IsNotImplementedErr returns true if given error is a NotImplementedError.
func IsNotImplementedErr(err error) bool {
_, ok := err.(NotImplementedError)
return ok
return errors.As(err, &NotImplementedError{})
}
8 changes: 4 additions & 4 deletions internal/pipe/archive/archive.go
Expand Up @@ -146,7 +146,7 @@ func create(ctx *context.Context, arch config.Archive, binaries []*artifact.Arti
archiveFile, err := os.Create(archivePath)
if err != nil {
lock.Unlock()
return fmt.Errorf("failed to create directory %s: %s", archivePath, err.Error())
return fmt.Errorf("failed to create directory %s: %w", archivePath, err)
}
lock.Unlock()
defer archiveFile.Close()
Expand All @@ -166,16 +166,16 @@ func create(ctx *context.Context, arch config.Archive, binaries []*artifact.Arti

files, err := findFiles(template, arch)
if err != nil {
return fmt.Errorf("failed to find files to archive: %s", err.Error())
return fmt.Errorf("failed to find files to archive: %w", err)
}
for _, f := range files {
if err = a.Add(f, f); err != nil {
return fmt.Errorf("failed to add %s to the archive: %s", f, err.Error())
return fmt.Errorf("failed to add %s to the archive: %w", f, err)
}
}
for _, binary := range binaries {
if err := a.Add(binary.Name, binary.Path); err != nil {
return fmt.Errorf("failed to add %s -> %s to the archive: %s", binary.Path, binary.Name, err.Error())
return fmt.Errorf("failed to add %s -> %s to the archive: %w", binary.Path, binary.Name, err)
}
}
ctx.Artifacts.Add(&artifact.Artifact{
Expand Down
2 changes: 1 addition & 1 deletion internal/pipe/before/before.go
Expand Up @@ -39,7 +39,7 @@ func (Pipe) Run(ctx *context.Context) error {
out, err := cmd.CombinedOutput()
log.WithField("cmd", step).Debug(string(out))
if err != nil {
return fmt.Errorf("hook failed: %s: %s; output: %s", step, err.Error(), string(out))
return fmt.Errorf("hook failed: %s: %w; output: %s", step, err, string(out))
}
}
return nil
Expand Down
1 change: 0 additions & 1 deletion internal/pipe/changelog/changelog.go
Expand Up @@ -214,7 +214,6 @@ func previous(tag string) (result string, err error) {
return
}

// nolint: gochecknoglobals
var validSHA1 = regexp.MustCompile(`^[a-fA-F0-9]{40}$`)

// isSHA1 te lets us know if the ref is a SHA1 or not.
Expand Down
8 changes: 5 additions & 3 deletions internal/pipe/pipe.go
@@ -1,7 +1,10 @@
// Package pipe provides generic erros for pipes to use.
package pipe

import "strings"
import (
"errors"
"strings"
)

// ErrSnapshotEnabled happens when goreleaser is running in snapshot mode.
// It usually means that publishing and maybe some validations were skipped.
Expand All @@ -21,8 +24,7 @@ var ErrSkipValidateEnabled = Skip("validation is disabled")

// IsSkip returns true if the error is an ErrSkip.
func IsSkip(err error) bool {
_, ok := err.(ErrSkip)
return ok
return errors.As(err, &ErrSkip{})
}

// ErrSkip occurs when a pipe is skipped for some reason.
Expand Down
7 changes: 2 additions & 5 deletions internal/pipe/release/release.go
Expand Up @@ -189,19 +189,16 @@ func upload(ctx *context.Context, cli client.Client, releaseID string, artifact
}

var err error
loop:
for try < 10 {
err = tryUpload()
if err == nil {
return nil
}
switch err.(type) {
case client.RetriableError:
if errors.As(err, &client.RetriableError{}) {
time.Sleep(time.Duration(try*50) * time.Millisecond)
continue
default:
break loop
}
break
}

return fmt.Errorf("failed to upload %s after %d tries: %w", artifact.Name, try, err)
Expand Down
4 changes: 2 additions & 2 deletions internal/testlib/skip.go
@@ -1,6 +1,7 @@
package testlib

import (
"errors"
"testing"

"github.com/goreleaser/goreleaser/internal/pipe"
Expand All @@ -9,6 +10,5 @@ import (

// AssertSkipped asserts that a pipe was skipped.
func AssertSkipped(t *testing.T, err error) {
_, ok := err.(pipe.ErrSkip)
require.True(t, ok, "expected a pipe.ErrSkip but got %v", err)
require.True(t, errors.As(err, &pipe.ErrSkip{}), "expected a pipe.ErrSkip but got %v", err)
}

1 comment on commit 27aa687

@vercel
Copy link

@vercel vercel bot commented on 27aa687 Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.