*: clean up if, bool comparison

release-3.0
Gyu-Ho Lee 2016-04-02 12:55:11 -07:00
parent dc0061e4db
commit b0cc0e443c
9 changed files with 14 additions and 21 deletions

View File

@ -124,7 +124,7 @@ func testWatchMultiWatcher(t *testing.T, wctx *watchctx) {
got = append(got, string(ev.Kv.Value))
}
sort.Strings(got)
if reflect.DeepEqual(expected, got) == false {
if !reflect.DeepEqual(expected, got) {
t.Errorf("got %v, expected %v", got, expected)
}

View File

@ -95,7 +95,7 @@ func OpDelete(key string, opts ...OpOption) Op {
panic("unexpected revision in delete")
case ret.sort != nil:
panic("unexpected sort in delete")
case ret.serializable != false:
case ret.serializable:
panic("unexpected serializable in delete")
}
return ret
@ -113,7 +113,7 @@ func OpPut(key, val string, opts ...OpOption) Op {
panic("unexpected revision in put")
case ret.sort != nil:
panic("unexpected sort in put")
case ret.serializable != false:
case ret.serializable:
panic("unexpected serializable in delete")
}
return ret
@ -129,7 +129,7 @@ func opWatch(key string, opts ...OpOption) Op {
panic("unexpected limit in watch")
case ret.sort != nil:
panic("unexpected sort in watch")
case ret.serializable != false:
case ret.serializable:
panic("unexpected serializable in watch")
}
return ret

View File

@ -521,7 +521,7 @@ func (w *watcher) resumeWatchers(wc pb.Watch_WatchClient) error {
resp, err := wc.Recv()
if err != nil {
return err
} else if len(resp.Events) != 0 || resp.Created != true {
} else if len(resp.Events) != 0 || !resp.Created {
return fmt.Errorf("watcher: unexpected response (%+v)", resp)
}

View File

@ -275,7 +275,7 @@ func newEtcdProcessCluster(cfg *etcdProcessClusterConfig) (*etcdProcessCluster,
}
func newEtcdProcess(cfg *etcdProcessConfig) (*etcdProcess, error) {
if fileutil.Exist("../bin/etcd") == false {
if !fileutil.Exist("../bin/etcd") {
return nil, fmt.Errorf("could not find etcd binary")
}
if err := os.RemoveAll(cfg.dataDirPath); err != nil {

View File

@ -563,7 +563,7 @@ func TestApplyConfChangeShouldStop(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error %v", err)
}
if shouldStop != false {
if shouldStop {
t.Errorf("shouldStop = %t, want %t", shouldStop, false)
}
@ -573,7 +573,7 @@ func TestApplyConfChangeShouldStop(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error %v", err)
}
if shouldStop != true {
if !shouldStop {
t.Errorf("shouldStop = %t, want %t", shouldStop, true)
}
}
@ -610,7 +610,7 @@ func TestApplyMultiConfChangeShouldStop(t *testing.T) {
}
_, shouldStop := srv.apply(ents, &raftpb.ConfState{})
if shouldStop == false {
if !shouldStop {
t.Errorf("shouldStop = %t, want %t", shouldStop, true)
}
}

View File

@ -362,7 +362,7 @@ func TestV3DeleteRange(t *testing.T) {
for j := range rresp.Kvs {
keys = append(keys, rresp.Kvs[j].Key)
}
if reflect.DeepEqual(tt.wantSet, keys) == false {
if !reflect.DeepEqual(tt.wantSet, keys) {
t.Errorf("expected %v on test %v, got %v", tt.wantSet, i, keys)
}

View File

@ -226,7 +226,7 @@ func TestV3WatchFromCurrentRevision(t *testing.T) {
t.Errorf("#%d: wStream.Recv error: %v", i, err)
continue
}
if cresp.Created != true {
if !cresp.Created {
t.Errorf("#%d: did not create watchid, got +%v", i, cresp)
continue
}

View File

@ -87,12 +87,12 @@ func TestExist(t *testing.T) {
}
f.Close()
if g := Exist(f.Name()); g != true {
if g := Exist(f.Name()); !g {
t.Errorf("exist = %v, want true", g)
}
os.Remove(f.Name())
if g := Exist(f.Name()); g != false {
if g := Exist(f.Name()); g {
t.Errorf("exist = %v, want false", g)
}
}

View File

@ -131,14 +131,7 @@ func (ki *keyIndex) get(atRev int64) (modified, created revision, ver int64, err
return revision{}, revision{}, 0, ErrRevisionNotFound
}
f := func(rev revision) bool {
if rev.main <= atRev {
return false
}
return true
}
n := g.walk(f)
n := g.walk(func(rev revision) bool { return rev.main > atRev })
if n != -1 {
return g.revs[n], g.created, g.ver - int64(len(g.revs)-n-1), nil
}