Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
soothe the linters
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ ONeal committed Sep 23, 2020
1 parent fd74bb2 commit bc267dd
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
9 changes: 5 additions & 4 deletions archiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package archiver
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -323,7 +322,7 @@ func testArchiveUnarchive(t *testing.T, au archiverUnarchiver) {

// Test extracting archive
dest := filepath.Join(tmp, "extraction_test_"+auStr)
os.Mkdir(dest, 0755)
_ = os.Mkdir(dest, 0755)
err = au.Unarchive(outfile, dest)
if err != nil {
t.Fatalf("[%s] extracting archive [%s -> %s]: didn't expect an error, but got: %v", auStr, outfile, dest, err)
Expand All @@ -333,6 +332,7 @@ func testArchiveUnarchive(t *testing.T, au archiverUnarchiver) {
symmetricTest(t, auStr, dest, true, true)
}

/*
// testMatching tests that au can match the format of archiveFile.
func testMatching(t *testing.T, au archiverUnarchiver, archiveFile string) {
m, ok := au.(Matcher)
Expand All @@ -358,12 +358,13 @@ func testMatching(t *testing.T, au archiverUnarchiver, archiveFile string) {
t.Fatalf("%s (%T): format should have matched, but didn't", m, m)
}
}
*/

// symmetricTest compares the contents of a destination directory to the contents
// of the test corpus and tests that they are equal.
func symmetricTest(t *testing.T, formatName, dest string, testSymlinks, testModes bool) {
var expectedFileCount int
filepath.Walk("testdata/corpus", func(fpath string, info os.FileInfo, err error) error {
_ = filepath.Walk("testdata/corpus", func(fpath string, info os.FileInfo, err error) error {
if testSymlinks || (info.Mode()&os.ModeSymlink) == 0 {
expectedFileCount++
}
Expand All @@ -373,7 +374,7 @@ func symmetricTest(t *testing.T, formatName, dest string, testSymlinks, testMode
// If outputs equals inputs, we're good; traverse output files
// and compare file names, file contents, and file count.
var actualFileCount int
filepath.Walk(dest, func(fpath string, info os.FileInfo, err error) error {
_ = filepath.Walk(dest, func(fpath string, info os.FileInfo, _ error) error {
if fpath == dest {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/arc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func getFormat(subcommand string) (interface{}, error) {
v.ContinueOnError = continueOnError
v.Password = os.Getenv("ARCHIVE_PASSWORD")
case *archiver.Tar:
v = mytar
f = mytar
case *archiver.TarBrotli:
v.Tar = mytar
v.Quality = compressionLevel
Expand Down
4 changes: 3 additions & 1 deletion rar.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ func (*Rar) Match(file io.ReadSeeker) (bool, error) {
if err != nil {
return false, err
}
defer file.Seek(currentPos, io.SeekStart)
defer func() {
_, _ = file.Seek(currentPos, io.SeekStart)
}()

buf := make([]byte, 8)
if n, err := file.Read(buf); err != nil || n < 8 {
Expand Down
2 changes: 1 addition & 1 deletion sz.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Snappy struct{}

// Compress reads in, compresses it, and writes it to out.
func (s *Snappy) Compress(in io.Reader, out io.Writer) error {
w := snappy.NewWriter(out)
w := snappy.NewBufferedWriter(out)
defer w.Close()
_, err := io.Copy(w, in)
return err
Expand Down
4 changes: 3 additions & 1 deletion tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,9 @@ func (*Tar) Match(file io.ReadSeeker) (bool, error) {
if err != nil {
return false, err
}
defer file.Seek(currentPos, io.SeekStart)
defer func() {
_, _ = file.Seek(currentPos, io.SeekStart)
}()

buf := make([]byte, tarBlockSize)
if _, err = io.ReadFull(file, buf); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tarsz.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (tsz *TarSz) Extract(source, target, destination string) error {
func (tsz *TarSz) wrapWriter() {
var sw *snappy.Writer
tsz.Tar.writerWrapFn = func(w io.Writer) (io.Writer, error) {
sw = snappy.NewWriter(w)
sw = snappy.NewBufferedWriter(w)
return sw, nil
}
tsz.Tar.cleanupWrapFn = func() {
Expand Down
14 changes: 8 additions & 6 deletions zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ type Zip struct {
ContinueOnError bool

// Compression algorithm
FileMethod ZipCompressionMethod
zw *zip.Writer
zr *zip.Reader
ridx int
decinitialized bool
FileMethod ZipCompressionMethod
zw *zip.Writer
zr *zip.Reader
ridx int
//decinitialized bool
}

// CheckExt ensures the file extension matches the format.
Expand Down Expand Up @@ -596,7 +596,9 @@ func (*Zip) Match(file io.ReadSeeker) (bool, error) {
if err != nil {
return false, err
}
defer file.Seek(currentPos, io.SeekStart)
defer func() {
_, _ = file.Seek(currentPos, io.SeekStart)
}()

buf := make([]byte, 4)
if n, err := file.Read(buf); err != nil || n < 4 {
Expand Down

0 comments on commit bc267dd

Please sign in to comment.