From d4510172d3a400a6d52bee5eb9b1bba668a4ca4a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Wed, 18 Jul 2018 14:02:56 -0500 Subject: [PATCH] Fix linter issues: ineffassign --- Makefile | 1 + ctl/import_test.go | 6 ++++++ ctl/inspect_test.go | 3 +++ fragment.go | 5 +++-- roaring/roaring_internal_test.go | 2 +- test/pilosa.go | 3 +++ test/pilosa_test.go | 3 +++ 7 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 65df8f894..e7dcb5e77 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,7 @@ gometalinter: require-gometalinter --enable=goimports \ --enable=gotype \ --enable=gotypex \ + --enable=ineffassign \ --enable=interfacer \ --enable=misspell \ --enable=unparam \ diff --git a/ctl/import_test.go b/ctl/import_test.go index 56970e9be..a41f6d525 100644 --- a/ctl/import_test.go +++ b/ctl/import_test.go @@ -203,6 +203,9 @@ func TestImportCommand_BugOverwriteValue(t *testing.T) { file.Close() file, err = ioutil.TempFile("", "import-value2.csv") + if err != nil { + t.Fatalf("Error creating tempfile: %s", err) + } file.Write([]byte("0,16\n")) cm.Paths = []string{file.Name()} err = cm.Run(ctx) @@ -212,6 +215,9 @@ func TestImportCommand_BugOverwriteValue(t *testing.T) { file.Close() file, err = ioutil.TempFile("", "import-value3.csv") + if err != nil { + t.Fatalf("Error creating tempfile: %s", err) + } file.Write([]byte("0,19\n")) cm.Paths = []string{file.Name()} err = cm.Run(ctx) diff --git a/ctl/inspect_test.go b/ctl/inspect_test.go index 5cf34481d..c7a48d400 100644 --- a/ctl/inspect_test.go +++ b/ctl/inspect_test.go @@ -31,6 +31,9 @@ func TestInspectCommand_Run(t *testing.T) { cm := NewInspectCommand(stdin, w, w) file, err := ioutil.TempFile("", "inspectTest") + if err != nil { + t.Fatalf("Error creating tempfile: %s", err) + } file.Write([]byte("12358267538963")) file.Close() cm.Path = file.Name() diff --git a/fragment.go b/fragment.go index 371b4ef46..b20478e54 100644 --- a/fragment.go +++ b/fragment.go @@ -584,9 +584,9 @@ func (f *fragment) sum(filter *Row, bitDepth uint) (sum, count uint64, err error // // 10*(2^0) + 4*(2^1) + 3*(2^2) = 30 // + var cnt uint64 for i := uint(0); i < bitDepth; i++ { row := f.row(uint64(i)) - cnt := uint64(0) if filter != nil { cnt = row.intersectionCount(filter) } else { @@ -1713,10 +1713,11 @@ func (f *fragment) rows() []uint64 { } func (f *fragment) rowsForColumn(columnID uint64) []uint64 { + var colKey uint64 + colID := columnID % ShardWidth i, _ := f.storage.Containers.Iterator(0) - colKey := uint64(0) colVal := uint16(colID & 0xFFFF) rows := make([]uint64, 0) diff --git a/roaring/roaring_internal_test.go b/roaring/roaring_internal_test.go index 5836782b8..3a56e30f3 100644 --- a/roaring/roaring_internal_test.go +++ b/roaring/roaring_internal_test.go @@ -2276,7 +2276,7 @@ func TestIteratorRuns(t *testing.T) { t.Fatalf("iterator did not seek correctly in multiple containers: %v\n", itr) } - val, eof = itr.Next() + itr.Next() val, eof = itr.Next() if !(val == 0 && eof) { t.Fatalf("iterator did not eof correctly: %d, %v\n", val, eof) diff --git a/test/pilosa.go b/test/pilosa.go index 001949906..507dd0af3 100644 --- a/test/pilosa.go +++ b/test/pilosa.go @@ -243,6 +243,9 @@ func MustDo(method, urlStr string, body string) *httpResponse { urlStr, strings.NewReader(body), ) + if err != nil { + panic(err) + } req.Header.Set("Content-Type", "application/json") req.Header.Set("Accept", "application/json") diff --git a/test/pilosa_test.go b/test/pilosa_test.go index 25bb808df..1f00ff68b 100644 --- a/test/pilosa_test.go +++ b/test/pilosa_test.go @@ -40,6 +40,9 @@ func TestNewCluster(t *testing.T) { cluster[0].URL()+"/status", strings.NewReader(""), ) + if err != nil { + t.Fatalf("creating http request: %v", err) + } req.Header.Set("Accept", "application/json")