@cryptotaxi247 / kubo / commits / 640be715d

key cmd: fix codeclimate warnings

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Aug 7, 2018 at 15:10 UTC 640be715dc54cb8daa2d3d0b26d4aa6f8058c725
3 files changed +13 -13
core/commands/keystore.go
+6 -6
@@ -100,7 +100,7 @@ var keyGenCmd = &cmds.Command{
100
101 cmds.EmitOnce(res, &KeyOutput{
102 Name: name,
103 - Id: key.Id().Pretty(),
103 + Id: key.ID().Pretty(),
104 })
105 },
106 Encoders: cmds.EncoderMap{
@@ -140,7 +140,7 @@ var keyListCmd = &cmds.Command{
140 list := make([]KeyOutput, 0, len(keys))
141
142 for _, key := range keys {
143 - list = append(list, KeyOutput{Name: key.Name(), Id: key.Id().Pretty()})
143 + list = append(list, KeyOutput{Name: key.Name(), Id: key.ID().Pretty()})
144 }
145
146 cmds.EmitOnce(res, &KeyOutputList{list})
@@ -182,7 +182,7 @@ var keyRenameCmd = &cmds.Command{
182 cmds.EmitOnce(res, &KeyRenameOutput{
183 Was: name,
184 Now: newName,
185 - Id: key.Id().Pretty(),
185 + Id: key.ID().Pretty(),
186 Overwrite: overwritten,
187 })
188 },
@@ -231,7 +231,7 @@ var keyRmCmd = &cmds.Command{
231 return
232 }
233
234 - list = append(list, KeyOutput{Name: name, Id: key.Id().Pretty()})
234 + list = append(list, KeyOutput{Name: name, Id: key.ID().Pretty()})
235 }
236
237 cmds.EmitOnce(res, &KeyOutputList{list})
@@ -244,7 +244,7 @@ var keyRmCmd = &cmds.Command{
244
245 func keyOutputListMarshaler() cmds.EncoderFunc {
246 return cmds.MakeEncoder(func(req *cmds.Request, w io.Writer, v interface{}) error {
247 - withId, _ := req.Options["l"].(bool)
247 + withID, _ := req.Options["l"].(bool)
248
249 list, ok := v.(*KeyOutputList)
250 if !ok {
@@ -253,7 +253,7 @@ func keyOutputListMarshaler() cmds.EncoderFunc {
253
254 tw := tabwriter.NewWriter(w, 1, 2, 1, ' ', 0)
255 for _, s := range list.Keys {
256 - if withId {
256 + if withID {
257 fmt.Fprintf(tw, "%s\t%s\t\n", s.Id, s.Name)
258 } else {
259 fmt.Fprintf(tw, "%s\n", s.Name)
core/coreapi/interface/key.go
+2 -2
@@ -16,8 +16,8 @@ type Key interface {
16 // Path returns key path
17 Path() Path
18
19 - // Id returns key PeerID
20 - Id() peer.ID
19 + // ID returns key PeerID
20 + ID() peer.ID
21 }
22
23 // KeyAPI specifies the interface to Keystore
core/coreapi/key.go
+5 -5
@@ -18,7 +18,7 @@ type KeyAPI CoreAPI
18
19 type key struct {
20 name string
21 - peerId peer.ID
21 + peerID peer.ID
22 }
23
24 // Name returns the key name
@@ -28,7 +28,7 @@ func (k *key) Name() string {
28
29 // Path returns the path of the key.
30 func (k *key) Path() coreiface.Path {
31 - path, err := coreiface.ParsePath(ipfspath.Join([]string{"/ipns", k.peerId.Pretty()}))
31 + path, err := coreiface.ParsePath(ipfspath.Join([]string{"/ipns", k.peerID.Pretty()}))
32 if err != nil {
33 panic("error parsing path: " + err.Error())
34 }
@@ -36,9 +36,9 @@ func (k *key) Path() coreiface.Path {
36 return path
37 }
38
39 -// Id returns key PeerID
40 -func (k *key) Id() peer.ID {
41 - return k.peerId
39 +// ID returns key PeerID
40 +func (k *key) ID() peer.ID {
41 + return k.peerID
42 }
43
44 // Generate generates new key, stores it in the keystore under the specified