diff --git a/.codeclimate.yml b/.codeclimate.yml index 55c44f27f..de5270338 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -6,6 +6,7 @@ exclude_paths: - test/ - Godeps/ - thirdparty/ +- "**/*.pb.go" engines: fixme: diff --git a/blocks/blockstore/blockstore.go b/blocks/blockstore/blockstore.go index e34c3a8ee..3d66c5ae3 100644 --- a/blocks/blockstore/blockstore.go +++ b/blocks/blockstore/blockstore.go @@ -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 } diff --git a/blocks/blockstore/bloom_cache_test.go b/blocks/blockstore/bloom_cache_test.go index 7941a647c..8682267ea 100644 --- a/blocks/blockstore/bloom_cache_test.go +++ b/blocks/blockstore/bloom_cache_test.go @@ -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 { @@ -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) diff --git a/blockservice/blockservice_test.go b/blockservice/blockservice_test.go index a97c315ba..bd3b0c665 100644 --- a/blockservice/blockservice_test.go +++ b/blockservice/blockservice_test.go @@ -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) } } diff --git a/cmd/ipfswatch/main.go b/cmd/ipfswatch/main.go index ff9e74c4f..6f37d588d 100644 --- a/cmd/ipfswatch/main.go +++ b/cmd/ipfswatch/main.go @@ -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" ) @@ -141,7 +144,6 @@ func run(ipfsPath, watchPath string) error { log.Println(err) } } - return nil } func addTree(w *fsnotify.Watcher, root string) error { diff --git a/commands/http/handler.go b/commands/http/handler.go index dd138b985..7138d4ddb 100644 --- a/commands/http/handler.go +++ b/commands/http/handler.go @@ -1,6 +1,7 @@ package http import ( + "context" "errors" "fmt" "io" @@ -11,11 +12,10 @@ import ( "strings" "sync" - context "context" - "github.com/ipfs/go-ipfs/repo/config" - cors "gx/ipfs/QmPG2kW5t27LuHgHnvhUwbHCNHAt2eUcb4gPHqofrESUdB/cors" - cmds "github.com/ipfs/go-ipfs/commands" + "github.com/ipfs/go-ipfs/repo/config" + + cors "gx/ipfs/QmPG2kW5t27LuHgHnvhUwbHCNHAt2eUcb4gPHqofrESUdB/cors" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" ) @@ -323,7 +323,6 @@ func flushCopy(w io.Writer, r io.Reader) error { f.Flush() } - return nil } func sanitizedErrStr(err error) string { diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index 7c2a64967..fc98d1c88 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -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) } } @@ -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) diff --git a/filestore/filestore.go b/filestore/filestore.go index da3dc17c6..29725cd57 100644 --- a/filestore/filestore.go +++ b/filestore/filestore.go @@ -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 } diff --git a/fuse/ipns/ipns_unix.go b/fuse/ipns/ipns_unix.go index 40fb63afc..bec34413a 100644 --- a/fuse/ipns/ipns_unix.go +++ b/fuse/ipns/ipns_unix.go @@ -125,8 +125,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 { diff --git a/path/path_test.go b/path/path_test.go index a718bd81f..c3bdcd59e 100644 --- a/path/path_test.go +++ b/path/path_test.go @@ -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) } } } diff --git a/pin/pin_test.go b/pin/pin_test.go index 009373dfe..656f8f63d 100644 --- a/pin/pin_test.go +++ b/pin/pin_test.go @@ -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") @@ -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) diff --git a/pin/set_test.go b/pin/set_test.go index 57826a998..7dbc61a85 100644 --- a/pin/set_test.go +++ b/pin/set_test.go @@ -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) } } } diff --git a/unixfs/mod/dagmodifier.go b/unixfs/mod/dagmodifier.go index 52e821de9..73852e2fa 100644 --- a/unixfs/mod/dagmodifier.go +++ b/unixfs/mod/dagmodifier.go @@ -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 }