Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multiple govet warnings #3824

Merged
merged 2 commits into from
Mar 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exclude_paths:
- test/
- Godeps/
- thirdparty/
- "**/*.pb.go"

engines:
fixme:
Expand Down
4 changes: 2 additions & 2 deletions blocks/blockstore/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ func (bs *blockstore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error)
return
}
if e.Error != nil {
log.Errorf("blockstore.AllKeysChan got err:", e.Error)
log.Errorf("blockstore.AllKeysChan got err: %s", e.Error)
return
}

// need to convert to key.Key using key.KeyFromDsKey.
k, err := dshelp.DsKeyToCid(ds.RawKey(e.Key))
if err != nil {
log.Warningf("error parsing key from DsKey: ", err)
log.Warningf("error parsing key from DsKey: %s", err)
continue
}

Expand Down
8 changes: 6 additions & 2 deletions blocks/blockstore/bloom_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ func testBloomCached(bs Blockstore, ctx context.Context) (*bloomcache, error) {
func TestPutManyAddsToBloom(t *testing.T) {
bs := NewBlockstore(syncds.MutexWrap(ds.NewMapDatastore()))

ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

cachedbs, err := testBloomCached(bs, ctx)

select {
Expand Down Expand Up @@ -75,7 +77,9 @@ func TestHasIsBloomCached(t *testing.T) {
for i := 0; i < 1000; i++ {
bs.Put(blocks.NewBlock([]byte(fmt.Sprintf("data: %d", i))))
}
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

cachedbs, err := testBloomCached(bs, ctx)
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion blockservice/blockservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestWriteThroughWorks(t *testing.T) {

bserv.AddBlock(block)
if bstore.PutCounter != 2 {
t.Fatal("Put should have called again, should be 2 is: %d", bstore.PutCounter)
t.Fatalf("Put should have called again, should be 2 is: %d", bstore.PutCounter)
}
}

Expand Down
8 changes: 5 additions & 3 deletions cmd/ipfswatch/main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package main

import (
"context"
"flag"
"log"
"os"
"os/signal"
"path/filepath"

context "context"
homedir "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
commands "github.com/ipfs/go-ipfs/commands"
core "github.com/ipfs/go-ipfs/core"
corehttp "github.com/ipfs/go-ipfs/core/corehttp"
coreunix "github.com/ipfs/go-ipfs/core/coreunix"
config "github.com/ipfs/go-ipfs/repo/config"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"

homedir "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"

process "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"

fsnotify "gx/ipfs/QmczzCMvJ3HV57WBKDy8b4ucp7quT325JjDbixYRS5Pwvv/fsnotify.v1"
)

Expand Down Expand Up @@ -141,7 +144,6 @@ func run(ipfsPath, watchPath string) error {
log.Println(err)
}
}
return nil
}

func addTree(w *fsnotify.Watcher, root string) error {
Expand Down
7 changes: 3 additions & 4 deletions commands/http/handler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package http

import (
"context"
"errors"
"fmt"
"io"
Expand All @@ -11,11 +12,10 @@ import (
"strings"
"sync"

context "context"
cmds "github.com/ipfs/go-ipfs/commands"
"github.com/ipfs/go-ipfs/repo/config"
cors "gx/ipfs/QmPG2kW5t27LuHgHnvhUwbHCNHAt2eUcb4gPHqofrESUdB/cors"

cmds "github.com/ipfs/go-ipfs/commands"
cors "gx/ipfs/QmPG2kW5t27LuHgHnvhUwbHCNHAt2eUcb4gPHqofrESUdB/cors"
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
)

Expand Down Expand Up @@ -323,7 +323,6 @@ func flushCopy(w io.Writer, r io.Reader) error {

f.Flush()
}
return nil
}

func sanitizedErrStr(err error) string {
Expand Down
4 changes: 2 additions & 2 deletions core/coreapi/unixfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestCatOffline(t *testing.T) {

_, err = api.Cat(ctx, coreapi.ResolvedPath("/ipns/Qmfoobar", nil, nil))
if err != coreiface.ErrOffline {
t.Fatalf("expected ErrOffline, got: %", err)
t.Fatalf("expected ErrOffline, got: %s", err)
}
}

Expand All @@ -223,7 +223,7 @@ func TestLs(t *testing.T) {
}
parts := strings.Split(k, "/")
if len(parts) != 2 {
t.Errorf("unexpected path:", k)
t.Errorf("unexpected path: %s", k)
}
p := coreapi.ResolvedPath("/ipfs/"+parts[0], nil, nil)

Expand Down
1 change: 1 addition & 0 deletions filestore/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (f *Filestore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error) {

a, err := f.bs.AllKeysChan(ctx)
if err != nil {
cancel()
return nil, err
}

Expand Down
2 changes: 0 additions & 2 deletions fuse/ipns/ipns_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ func loadRoot(ctx context.Context, rt *keyRoot, ipfs *core.IpfsNode, name string
default:
return nil, errors.New("unrecognized type")
}

panic("not reached")
}

type keyRoot struct {
Expand Down
2 changes: 1 addition & 1 deletion path/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestPathParsing(t *testing.T) {
_, err := ParsePath(p)
valid := (err == nil)
if valid != expected {
t.Fatalf("expected %s to have valid == %s", p, expected)
t.Fatalf("expected %s to have valid == %t", p, expected)
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions pin/pin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ func TestPinRecursiveFail(t *testing.T) {
}

// NOTE: This isnt a time based test, we expect the pin to fail
mctx, _ := context.WithTimeout(ctx, time.Millisecond)
mctx, cancel := context.WithTimeout(ctx, time.Millisecond)
defer cancel()

err = p.Pin(mctx, a, true)
if err == nil {
t.Fatal("should have failed to pin here")
Expand All @@ -358,7 +360,8 @@ func TestPinRecursiveFail(t *testing.T) {
}

// this one is time based... but shouldnt cause any issues
mctx, _ = context.WithTimeout(ctx, time.Second)
mctx, cancel = context.WithTimeout(ctx, time.Second)
defer cancel()
err = p.Pin(mctx, a, true)
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion pin/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestSet(t *testing.T) {

for _, c := range inputs {
if !seen.Has(c) {
t.Fatalf("expected to have %s, didnt find it")
t.Fatalf("expected to have '%s', didnt find it", c)
}
}
}
3 changes: 3 additions & 0 deletions unixfs/mod/dagmodifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,18 @@ func (dm *DagModifier) readPrep() error {
ctx, cancel := context.WithCancel(dm.ctx)
dr, err := uio.NewDagReader(ctx, dm.curNode, dm.dagserv)
if err != nil {
cancel()
return err
}

i, err := dr.Seek(int64(dm.curWrOff), os.SEEK_SET)
if err != nil {
cancel()
return err
}

if i != int64(dm.curWrOff) {
cancel()
return ErrSeekFail
}

Expand Down