From 2c66ea6995cee698e16c95dc6fb2db6c4b3f8aa8 Mon Sep 17 00:00:00 2001 From: Kay Date: Tue, 5 Sep 2023 17:05:51 +0330 Subject: [PATCH] refactor: if statement (#10105) --- core/commands/dag/dag.go | 4 ++-- core/corehttp/option_test.go | 7 +++---- core/corehttp/routing.go | 5 ++--- core/node/libp2p/smux.go | 19 +++++++++---------- fuse/node/mount_darwin.go | 3 +-- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 649142fd0..07851eb31 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -234,10 +234,10 @@ Specification of CAR formats: https://ipld.io/specs/transport/car/ if event.Root.PinErrorMsg != "" { return fmt.Errorf("pinning root %q FAILED: %s", enc.Encode(event.Root.Cid), event.Root.PinErrorMsg) - } else { - event.Root.PinErrorMsg = "success" } + event.Root.PinErrorMsg = "success" + _, err = fmt.Fprintf( w, "Pinned root\t%s\t%s\n", diff --git a/core/corehttp/option_test.go b/core/corehttp/option_test.go index b401be9d5..be4f3afaa 100644 --- a/core/corehttp/option_test.go +++ b/core/corehttp/option_test.go @@ -51,10 +51,9 @@ func TestCheckVersionOption(t *testing.T) { called = true if !tc.shouldHandle { t.Error("handler was called even though version didn't match") - } else { - if _, err := io.WriteString(w, "check!"); err != nil { - t.Error(err) - } + } + if _, err := io.WriteString(w, "check!"); err != nil { + t.Error(err) } }) diff --git a/core/corehttp/routing.go b/core/corehttp/routing.go index 357122a45..e648afb4e 100644 --- a/core/corehttp/routing.go +++ b/core/corehttp/routing.go @@ -100,10 +100,9 @@ func (it *peerChanIter) Next() bool { if ok { it.next = &addr return true - } else { - it.next = nil - return false } + it.next = nil + return false } func (it *peerChanIter) Val() types.Record { diff --git a/core/node/libp2p/smux.go b/core/node/libp2p/smux.go index d96dacf0a..0966dfaf2 100644 --- a/core/node/libp2p/smux.go +++ b/core/node/libp2p/smux.go @@ -38,17 +38,16 @@ func makeSmuxTransportOption(tptConfig config.Transports) (libp2p.Option, error) } } return libp2p.ChainOptions(opts...), nil - } else { - return prioritizeOptions([]priorityOption{{ - priority: tptConfig.Multiplexers.Yamux, - defaultPriority: 100, - opt: libp2p.Muxer(yamux.ID, yamux.DefaultTransport), - }, { - priority: tptConfig.Multiplexers.Mplex, - defaultPriority: config.Disabled, - opt: libp2p.Muxer(mplex.ID, mplex.DefaultTransport), - }}), nil } + return prioritizeOptions([]priorityOption{{ + priority: tptConfig.Multiplexers.Yamux, + defaultPriority: 100, + opt: libp2p.Muxer(yamux.ID, yamux.DefaultTransport), + }, { + priority: tptConfig.Multiplexers.Mplex, + defaultPriority: config.Disabled, + opt: libp2p.Muxer(mplex.ID, mplex.DefaultTransport), + }}), nil } func SmuxTransport(tptConfig config.Transports) func() (opts Libp2pOpts, err error) { diff --git a/fuse/node/mount_darwin.go b/fuse/node/mount_darwin.go index bd0bbb3ae..4d2446ecd 100644 --- a/fuse/node/mount_darwin.go +++ b/fuse/node/mount_darwin.go @@ -141,9 +141,8 @@ func darwinFuseCheckVersion(node *core.IpfsNode) error { return err } else if skip { return nil // user told us not to check version... ok.... - } else { - return errGFV } + return errGFV } log.Debug("mount: osxfuse version:", ov)