-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ioctl] add did service command #3848
Conversation
|
🚨 Fail code review process for file ioctl/cmd/did/common.go.
|
ChatGPT's review about
Here's an improved version of the code: // Copyright (c) 2022 IoTeX Foundation
// This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
// or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
// This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
package did
import (
"github.com/spf13/cobra"
"github.com/iotexproject/iotex-core/ioctl/config"
)
type didFlags struct {
endpoint string
insecure bool
}
// Multi-language support
type didCmdShorts map[config.Language]string
var (
didFlagsEn = didFlags{
endpoint: config.ReadConfig.Endpoint,
insecure: config.Insecure,
}
didCmdShorts = map[config.Language]didCmdShorts{
config.English: {
"generate": "Generate DID",
"register": "Register DID",
"get": "Get DID",
"dereg": "Deregister DID",
"add": "Add service to DID",
"remove": "Remove service from DID",
},
config.Chinese: {
"generate": "\xe7\x94\x9f\xe6\x88\x90DID",
"register": "\xe6\xb3\xa8\xe5\x86\x8CDID",
"get": "\xe8\x8e\xb7\xe5\x8f\x96DID",
"dereg": "\xe5\x8f\x96\xe6\xb6\x88DID",
"add": "\xe5\xb0\x86\xe6\x9c\x8d\xe5\x8a\xa1\xe6\xb7\xbb\xe5\x8a\xa0\xe5\x88\xb0DID",
"remove": "\xe4\xbb\x8eDID\xe4\xb8\x8a\xe5\x88\xa0\xe9\x99\xa4\xe6\x9c\x8d\xe5\x8a\xa1",
},
}
didCmd = &cobra.Command{
Use: "did",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["generate"],
}
didGenerateCmd = &cobra.Command{
Use: "generate",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["generate"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement generate DID
return nil
},
}
didRegisterCmd = &cobra.Command{
Use: "register",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["register"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement register DID
return nil
},
}
didGetCmd = &cobra.Command{
Use: "get",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["get"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement get DID
return nil
},
}
didDeregisterCmd = &cobra.Command{
Use: "deregister",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["dereg"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement deregister DID
return nil
},
}
didServiceAddCmd = &cobra.Command{
Use: "add",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["add"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement add service to DID
return nil
},
}
didServiceRemoveCmd = &cobra.Command{
Use: "remove",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["remove"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement remove service from DID
return nil
},
}
)
func init() {
didCmd.AddCommand(didGenerateCmd)
didCmd.AddCommand(didRegisterCmd)
didCmd.AddCommand(didGetCmd)
didCmd.AddCommand(didDeregisterCmd)
didCmd.AddCommand(didServiceAddCmd)
didCmd.AddCommand(didServiceRemoveCmd)
didFlagsEn.endpoint = config.TranslateInLang(map[config.Language]string{
config.English: "set endpoint for once",
config.Chinese: "\xe4\xb8\x80\xe6\xac\xa1\xe8\xae\xbe\xe7\xbd\xae\xe7\xab\xaf\xe7\x82\xb9",
}, config.UILanguage)
didFlagsEn.insecure = config.TranslateInLang(map[config.Language]string{
config.English: "insecure connection for once",
config.Chinese: "\xe4\xb8\x80\xe6\xac\xa1\xe4\xb8\x8d\xe5\xae\x89\xe5\x85\xa8\xe8\xbf\x9e\xe6\x8e\xa5",
}, config.UILanguage)
didCmd.PersistentFlags().StringVar(&didFlagsEn.endpoint, "endpoint", didFlagsEn.endpoint, didFlagsEn.endpoint)
didCmd.PersistentFlags().BoolVar(&didFlagsEn.insecure, "insecure", didFlagsEn.insecure, didFlagsEn.insecure)
} In this version of the code, we've:
|
ChatGPT's review about Potential Bugs or Code Smells
Suggestions for Improvements
|
ChatGPT's review about Potential Bugs or Code Smells
Suggestions for Improvement
|
Codecov Report
@@ Coverage Diff @@
## master #3848 +/- ##
==========================================
+ Coverage 75.38% 75.44% +0.06%
==========================================
Files 303 303
Lines 25923 26038 +115
==========================================
+ Hits 19541 19645 +104
- Misses 5360 5371 +11
Partials 1022 1022
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
🚨 Fail code review process for file ioctl/cmd/did/common.go.
|
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
ChatGPT's review about
Here's an improved version of the code: // Copyright (c) 2022 IoTeX Foundation
// This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
// or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
// This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
package did
import (
"github.com/spf13/cobra"
"github.com/iotexproject/iotex-core/ioctl/config"
)
type didFlags struct {
endpoint string
insecure bool
}
// Multi-language support
type didCmdShorts map[config.Language]string
var (
didFlagsEn = didFlags{
endpoint: config.ReadConfig.Endpoint,
insecure: config.Insecure,
}
didCmdShorts = map[config.Language]didCmdShorts{
config.English: {
"generate": "Generate DID",
"register": "Register DID",
"get": "Get DID",
"dereg": "Deregister DID",
"add": "Add service to DID",
"remove": "Remove service from DID",
},
config.Chinese: {
"generate": "\xe7\x94\x9f\xe6\x88\x90DID",
"register": "\xe6\xb3\xa8\xe5\x86\x8CDID",
"get": "\xe8\x8e\xb7\xe5\x8f\x96DID",
"dereg": "\xe5\x8f\x96\xe6\xb6\x88DID",
"add": "\xe5\xb0\x86\xe6\x9c\x8d\xe5\x8a\xa1\xe6\xb7\xbb\xe5\x8a\xa0\xe5\x88\xb0DID",
"remove": "\xe4\xbb\x8eDID\xe4\xb8\x8a\xe5\x88\xa0\xe9\x99\xa4\xe6\x9c\x8d\xe5\x8a\xa1",
},
}
didCmd = &cobra.Command{
Use: "did",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["generate"],
}
didGenerateCmd = &cobra.Command{
Use: "generate",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["generate"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement generate DID
return nil
},
}
didRegisterCmd = &cobra.Command{
Use: "register",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["register"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement register DID
return nil
},
}
didGetCmd = &cobra.Command{
Use: "get",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["get"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement get DID
return nil
},
}
didDeregisterCmd = &cobra.Command{
Use: "deregister",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["dereg"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement deregister DID
return nil
},
}
didServiceAddCmd = &cobra.Command{
Use: "add",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["add"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement add service to DID
return nil
},
}
didServiceRemoveCmd = &cobra.Command{
Use: "remove",
Short: config.TranslateInLang(didCmdShorts, config.UILanguage)["remove"],
RunE: func(cmd *cobra.Command, args []string) error {
// TODO: implement remove service from DID
return nil
},
}
)
func init() {
didCmd.AddCommand(didGenerateCmd)
didCmd.AddCommand(didRegisterCmd)
didCmd.AddCommand(didGetCmd)
didCmd.AddCommand(didDeregisterCmd)
didCmd.AddCommand(didServiceAddCmd)
didCmd.AddCommand(didServiceRemoveCmd)
didFlagsEn.endpoint = config.TranslateInLang(map[config.Language]string{
config.English: "set endpoint for once",
config.Chinese: "\xe4\xb8\x80\xe6\xac\xa1\xe8\xae\xbe\xe7\xbd\xae\xe7\xab\xaf\xe7\x82\xb9",
}, config.UILanguage)
didFlagsEn.insecure = config.TranslateInLang(map[config.Language]string{
config.English: "insecure connection for once",
config.Chinese: "\xe4\xb8\x80\xe6\xac\xa1\xe4\xb8\x8d\xe5\xae\x89\xe5\x85\xa8\xe8\xbf\x9e\xe6\x8e\xa5",
}, config.UILanguage)
didCmd.PersistentFlags().StringVar(&didFlagsEn.endpoint, "endpoint", didFlagsEn.endpoint, didFlagsEn.endpoint)
didCmd.PersistentFlags().BoolVar(&didFlagsEn.insecure, "insecure", didFlagsEn.insecure, didFlagsEn.insecure)
} In this version of the code, we've:
|
ChatGPT's review about Potential Bugs or Code Smells
Suggestions for Improvements
|
ChatGPT's review about Potential Bugs/Code Smells
Suggestions for Improvement
|
ChatGPT's review about Potential Bugs or Code Smells
Suggestions for Improvements
|
ChatGPT's review about Potential Bugs or Code Smells
Suggestions for Improvement
|
Description
Add ioctl command for DID service
Fixes #(issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: