Showing 29 of 39 total issues
Function Build
has a Cognitive Complexity of 59 (exceeds 20 allowed). Consider refactoring. Open
func Build(cmd *cobra.Command, args []string, isAppend bool) {
var err error
util.CheckArguments(cmd, args, 0, 0)
blockchainFlag := util.GetStringFlagValue(cmd, "blockchain")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function Build
has 176 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Build(cmd *cobra.Command, args []string, isAppend bool) {
var err error
util.CheckArguments(cmd, args, 0, 0)
blockchainFlag := util.GetStringFlagValue(cmd, "blockchain")
Function buildListener
has 79 lines of code (exceeds 50 allowed). Consider refactoring. Open
func buildListener(testnetId string) {
sigChan := make(chan os.Signal, 1)
pauseChan := make(chan os.Signal, 1)
quitChan := make(chan os.Signal, 1)
Function HandleResources
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
func HandleResources(cmd *cobra.Command, args []string, bconf *Config) (givenCPU bool, givenMem bool) {
givenCPU = cmd.Flags().Changed("cpus")
givenMem = cmd.Flags().Changed("memory")
if len(bconf.Resources) < bconf.Nodes {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function createAutoGraph
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func createAutoGraph() ([]ui.Drawable, error) {
res, err := util.JsonRpcCall("state::sub_routines_stats", []string{})
if err != nil {
return nil, err
}
Function buildListener
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
func buildListener(testnetId string) {
sigChan := make(chan os.Signal, 1)
pauseChan := make(chan os.Signal, 1)
quitChan := make(chan os.Signal, 1)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function HandleResources
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func HandleResources(cmd *cobra.Command, args []string, bconf *Config) (givenCPU bool, givenMem bool) {
givenCPU = cmd.Flags().Changed("cpus")
givenMem = cmd.Flags().Changed("memory")
if len(bconf.Resources) < bconf.Nodes {
Function determineImage
has 9 return statements (exceeds 4 allowed). Open
func determineImage(blockchain string, requested string) string {
cont, err := getImageTable()
if err != nil {
if len(requested) > 0 {
Function jsonRpcCall
has 7 return statements (exceeds 4 allowed). Open
func jsonRpcCall(method string, params interface{}) (interface{}, error) {
//log.Println("URL IS "+url)
jrpc, err := json2.EncodeClientRequest(method, params)
if err != nil {
log.Warn(err)
Function jwtHTTPRequest
has 7 return statements (exceeds 4 allowed). Open
func jwtHTTPRequest(method string, url string, bodyData string) (string, error) {
if bodyData == "test" {
return "{}", nil
}
body := strings.NewReader(bodyData)
Avoid deeply nested control flow statements. Open
if err != nil {
util.InvalidInteger(key, text, false)
i--
continue
}
Avoid deeply nested control flow statements. Open
if err != nil {
util.PrintErrorFatal(err)
i--
continue
}
Function GetBiome
has 6 return statements (exceeds 4 allowed). Open
func GetBiome(org Organization) (map[string]interface{}, error) {
if len(org.Biomes) == 0 {
return nil, fmt.Errorf("No available biomes")
}
if len(org.Biomes) == 1 { // There is only one biome so just choose that one
Function apiRequest
has 6 return statements (exceeds 4 allowed). Open
func apiRequest(path string, method string, body []byte) ([]byte, error) {
request, err := http.NewRequest(method, fmt.Sprintf("%s%s", conf.APIURL, path), bytes.NewReader(body))
if err != nil {
return nil, err
}
Function checkContractFiles
has 6 return statements (exceeds 4 allowed). Open
func checkContractFiles(fileName string) bool {
cwd := os.Getenv("HOME")
if _, err := os.Stat(cwd + "/smart-contracts/node_modules"); err != nil {
util.Print("Smartcontracts have not been initialized. Please run 'geth solc init' to deploy a smart contract.")
return false
Function CaptureAndDisplayTogether
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func CaptureAndDisplayTogether(r1 io.Reader, r2 io.Reader, offset int, label1 string, label2 string) {
Function fetchBlockDataLocally
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func fetchBlockDataLocally(sem *semaphore.Weighted, node Node, blockHeight int, startBlock int, dir string) {
Function CheckIntegerBounds
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func CheckIntegerBounds(cmd *cobra.Command, name string, val int, min int, max int) {
Function handleChunks
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func handleChunks(testnetID string, node Node, logName string, rawChunks string, sem *semaphore.Weighted) []string {
Function handleExportBlocks
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func handleExportBlocks(testnetID string, node string, rawRes string, coveredBlockNumbers *map[int64]struct{}, sem *semaphore.Weighted) (interface{}, []string) {