Skip to content

Commit

Permalink
dependabot-1 Linting fixes, removed varnamelen from lint checks
Browse files Browse the repository at this point in the history
  • Loading branch information
bdebyl committed Jul 15, 2022
1 parent 75153b2 commit d41d69e
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 33 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ linters:
enable-all: true
disable:
- goerr113
- varnamelen

linters-settings:
errcheck:
Expand Down
2 changes: 1 addition & 1 deletion archive/tar/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"path/filepath"
"strings"

"github.com/go-kit/kit/log"
"github.com/go-kit/log"

"github.com/meltwater/drone-cache/internal"
)
Expand Down
2 changes: 1 addition & 1 deletion cache/rebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (r rebuilder) Rebuild(srcs []string) error {
}

// rebuild pushes the archived file to the cache.
func (r rebuilder) rebuild(src, dst string) (err error) {
func (r rebuilder) rebuild(src, dst string) error {
src, err = filepath.Abs(filepath.Clean(src))
if err != nil {
return fmt.Errorf("clean source path, %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cache/restorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (r restorer) Restore(dsts []string) error {
}

// restore fetches the archived file from the cache and restores to the host machine's file system.
func (r restorer) restore(src, dst string) (err error) {
func (r restorer) restore(src, dst string) error {
pr, pw := io.Pipe()
defer internal.CloseWithErrCapturef(&err, pr, "rebuild, pr close <%s>", dst)

Expand Down
2 changes: 1 addition & 1 deletion cache/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type statWriter struct {
written int64
}

func (s *statWriter) Write(p []byte) (n int, err error) {
func (s *statWriter) Write(p []byte) (int, error) {
size := len(p)
s.written += int64(size)

Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/aws/aws-sdk-go v1.44.55
github.com/dustin/go-humanize v1.0.0
github.com/go-kit/kit v0.12.0
github.com/go-kit/log v0.2.1
github.com/google/go-cmp v0.5.8
github.com/klauspost/compress v1.15.8
github.com/pkg/sftp v1.13.5
Expand All @@ -24,11 +25,9 @@ require (
github.com/Azure/azure-pipeline-go v0.2.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golangci/golangci-lint v1.46.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
Expand All @@ -45,7 +44,7 @@ require (
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220714152414-ccd2914cffd4 // indirect
google.golang.org/genproto v0.0.0-20220714211235-042d03aeabc9 // indirect
google.golang.org/grpc v1.48.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golangci/golangci-lint v1.46.2 h1:o90t/Xa6dhJbvy8Bz2RpzUXqrkigp19DLStMolTZbyo=
github.com/golangci/golangci-lint v1.46.2/go.mod h1:3DkdHnxn9eoTTrpT2gB0TEv8KSziuoqe9FitgQLHvAY=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
Expand Down Expand Up @@ -688,8 +686,8 @@ google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljW
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA=
google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA=
google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA=
google.golang.org/genproto v0.0.0-20220714152414-ccd2914cffd4 h1:y2IEhgO0Rmt0axD3Se6N7D5e8yhTG9dUiFCyMbaaN7U=
google.golang.org/genproto v0.0.0-20220714152414-ccd2914cffd4/go.mod h1:GkXuJDJ6aQ7lnJcRF+SJVgFdQhypqgl3LB1C9vabdRE=
google.golang.org/genproto v0.0.0-20220714211235-042d03aeabc9 h1:zfXhTgBfGlIh3jMXN06W8qbhFGsh6MJNJiYEuhTddOI=
google.golang.org/genproto v0.0.0-20220714211235-042d03aeabc9/go.mod h1:GkXuJDJ6aQ7lnJcRF+SJVgFdQhypqgl3LB1C9vabdRE=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand Down
12 changes: 6 additions & 6 deletions internal/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"io"
"os"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
)

// CloseWithErrLogf is making sure we log every error, even those from best effort tiny closers.
func CloseWithErrLogf(logger log.Logger, closer io.Closer, format string, a ...interface{}) {
err := close(closer)
err := closeIo(closer)
if err == nil {
return
}
Expand All @@ -27,7 +27,7 @@ func CloseWithErrLogf(logger log.Logger, closer io.Closer, format string, a ...i
// CloseWithErrCapturef runs function and on error return error by argument including the given error..
func CloseWithErrCapturef(err *error, closer io.Closer, format string, a ...interface{}) {
if err != nil {
cErr := close(closer)
cErr := closeIo(closer)
if cErr == nil {
return
}
Expand All @@ -40,15 +40,15 @@ func CloseWithErrCapturef(err *error, closer io.Closer, format string, a ...inte
return
}

cErr := close(closer)
cErr := closeIo(closer)
if cErr == nil {
return
}

*err = cErr
}

func close(closer io.Closer) error {
func closeIo(closer io.Closer) error {
err := closer.Close()
if err == nil {
return nil
Expand Down
4 changes: 2 additions & 2 deletions internal/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package internal
import (
"os"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
)

const (
Expand Down
28 changes: 14 additions & 14 deletions test/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

// CreateTempFile is a test helper to create a temporary file with given name and content, in given directory.
func CreateTempFile(t testing.TB, name string, content []byte, in ...string) (string, func()) {
t.Helper()
func CreateTempFile(tb testing.TB, name string, content []byte, in ...string) (string, func()) {
tb.Helper()

parent := ""
if len(in) > 0 {
Expand All @@ -17,23 +17,23 @@ func CreateTempFile(t testing.TB, name string, content []byte, in ...string) (st

tmpfile, err := ioutil.TempFile(parent, name+"_*.testfile")
if err != nil {
t.Fatalf("unexpectedly failed creating the temp file: %v", err)
tb.Fatalf("unexpectedly failed creating the temp file: %v", err)
}

if _, err := tmpfile.Write(content); err != nil {
t.Fatalf("unexpectedly failed writing to the temp file: %v", err)
tb.Fatalf("unexpectedly failed writing to the temp file: %v", err)
}

if err := tmpfile.Close(); err != nil {
t.Fatalf("unexpectedly failed closing the temp file: %v", err)
tb.Fatalf("unexpectedly failed closing the temp file: %v", err)
}

return tmpfile.Name(), func() { os.Remove(tmpfile.Name()) }
}

// CreateTempFilesInDir is a test helper to create temporary files using name as prefix and content, in given directory.
func CreateTempFilesInDir(t testing.TB, name string, content []byte, in ...string) (string, func()) {
t.Helper()
func CreateTempFilesInDir(tb testing.TB, name string, content []byte, in ...string) (string, func()) {
tb.Helper()

parent := ""
if len(in) > 0 {
Expand All @@ -42,30 +42,30 @@ func CreateTempFilesInDir(t testing.TB, name string, content []byte, in ...strin

tmpDir, err := ioutil.TempDir(parent, name+"-testdir-*")
if err != nil {
t.Fatalf("unexpectedly failed creating the temp dir: %v", err)
tb.Fatalf("unexpectedly failed creating the temp dir: %v", err)
}

for i := 0; i < 3; i++ {
tmpfile, err := ioutil.TempFile(tmpDir, name+"_*.testfile")
if err != nil {
t.Fatalf("unexpectedly failed creating the temp file: %v", err)
tb.Fatalf("unexpectedly failed creating the temp file: %v", err)
}

if _, err := tmpfile.Write(content); err != nil {
t.Fatalf("unexpectedly failed writing to the temp file: %v", err)
tb.Fatalf("unexpectedly failed writing to the temp file: %v", err)
}

if err := tmpfile.Close(); err != nil {
t.Fatalf("unexpectedly failed closing the temp file: %v", err)
tb.Fatalf("unexpectedly failed closing the temp file: %v", err)
}
}

return tmpDir, func() { os.RemoveAll(tmpDir) }
}

// CreateTempDir is a test helper to create a temporary directory, in given directory.
func CreateTempDir(t testing.TB, name string, in ...string) (string, func()) {
t.Helper()
func CreateTempDir(tb testing.TB, name string, in ...string) (string, func()) {
tb.Helper()

parent := ""
if len(in) > 0 {
Expand All @@ -74,7 +74,7 @@ func CreateTempDir(t testing.TB, name string, in ...string) (string, func()) {

tmpDir, err := ioutil.TempDir(parent, name+"-testdir-*")
if err != nil {
t.Fatalf("unexpectedly failed creating the temp dir: %v", err)
tb.Fatalf("unexpectedly failed creating the temp dir: %v", err)
}

return tmpDir, func() { os.RemoveAll(tmpDir) }
Expand Down

0 comments on commit d41d69e

Please sign in to comment.