refactor: if statement (#10105)
Kay committed
Sep 5, 2023 at 17:05 UTC
2c66ea6995cee698e16c95dc6fb2db6c4b3f8aa8
5 files changed
+17
-21
core/commands/dag/dag.go
+2
-2
@@ -234,10 +234,10 @@ Specification of CAR formats: https://ipld.io/specs/transport/car/
234
235
if event.Root.PinErrorMsg != "" {
236
return fmt.Errorf("pinning root %q FAILED: %s", enc.Encode(event.Root.Cid), event.Root.PinErrorMsg)
237
- } else {
238
- event.Root.PinErrorMsg = "success"
237
}
238
239
+ event.Root.PinErrorMsg = "success"
240
+
241
_, err = fmt.Fprintf(
242
w,
243
"Pinned root\t%s\t%s\n",
core/corehttp/option_test.go
+3
-4
@@ -51,10 +51,9 @@ func TestCheckVersionOption(t *testing.T) {
51
called = true
52
if !tc.shouldHandle {
53
t.Error("handler was called even though version didn't match")
54
- } else {
55
- if _, err := io.WriteString(w, "check!"); err != nil {
56
- t.Error(err)
57
- }
54
+ }
55
+ if _, err := io.WriteString(w, "check!"); err != nil {
56
+ t.Error(err)
57
}
58
})
59
core/corehttp/routing.go
+2
-3
@@ -100,10 +100,9 @@ func (it *peerChanIter) Next() bool {
100
if ok {
101
it.next = &addr
102
return true
103
- } else {
104
- it.next = nil
105
- return false
103
}
104
+ it.next = nil
105
+ return false
106
}
107
108
func (it *peerChanIter) Val() types.Record {
core/node/libp2p/smux.go
+9
-10
@@ -38,17 +38,16 @@ func makeSmuxTransportOption(tptConfig config.Transports) (libp2p.Option, error)
38
}
39
}
40
return libp2p.ChainOptions(opts...), nil
41
- } else {
42
- return prioritizeOptions([]priorityOption{{
43
- priority: tptConfig.Multiplexers.Yamux,
44
- defaultPriority: 100,
45
- opt: libp2p.Muxer(yamux.ID, yamux.DefaultTransport),
46
- }, {
47
- priority: tptConfig.Multiplexers.Mplex,
48
- defaultPriority: config.Disabled,
49
- opt: libp2p.Muxer(mplex.ID, mplex.DefaultTransport),
50
- }}), nil
41
}
42
+ return prioritizeOptions([]priorityOption{{
43
+ priority: tptConfig.Multiplexers.Yamux,
44
+ defaultPriority: 100,
45
+ opt: libp2p.Muxer(yamux.ID, yamux.DefaultTransport),
46
+ }, {
47
+ priority: tptConfig.Multiplexers.Mplex,
48
+ defaultPriority: config.Disabled,
49
+ opt: libp2p.Muxer(mplex.ID, mplex.DefaultTransport),
50
+ }}), nil
51
}
52
53
func SmuxTransport(tptConfig config.Transports) func() (opts Libp2pOpts, err error) {
fuse/node/mount_darwin.go
+1
-2
@@ -141,9 +141,8 @@ func darwinFuseCheckVersion(node *core.IpfsNode) error {
141
return err
142
} else if skip {
143
return nil // user told us not to check version... ok....
144
- } else {
145
- return errGFV
144
}
145
+ return errGFV
146
}
147
148
log.Debug("mount: osxfuse version:", ov)