Whiteblock/cli

View on GitHub

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")
Severity: Minor
Found in whiteblock/cmd/build.go - About 6 hrs to fix

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")
Severity: Major
Found in whiteblock/cmd/build.go - About 6 hrs to fix

    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)
    
    
    Severity: Major
    Found in whiteblock/cmd/webhandler.go - About 2 hrs to fix

      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 {
      Severity: Minor
      Found in whiteblock/cmd/build/flags.go - About 2 hrs to fix

      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
          }
      Severity: Minor
      Found in whiteblock/cmd/auto.go - About 1 hr to fix

        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)
        
        
        Severity: Minor
        Found in whiteblock/cmd/webhandler.go - About 1 hr to fix

        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 {
        Severity: Minor
        Found in whiteblock/cmd/build/flags.go - About 1 hr to fix

          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 {
          Severity: Major
          Found in whiteblock/cmd/build/helpers.go - About 55 mins to fix

            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)
            Severity: Major
            Found in whiteblock/util/jsonrpc.go - About 45 mins to fix

              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)
              Severity: Major
              Found in whiteblock/util/util.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                if err != nil {
                                    util.InvalidInteger(key, text, false)
                                    i--
                                    continue
                                }
                Severity: Major
                Found in whiteblock/cmd/build.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                  if err != nil {
                                      util.PrintErrorFatal(err)
                                      i--
                                      continue
                                  }
                  Severity: Major
                  Found in whiteblock/cmd/build.go - About 45 mins to fix

                    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
                    Severity: Major
                    Found in whiteblock/cmd/profile.go - About 40 mins to fix

                      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
                          }
                      Severity: Major
                      Found in whiteblock/cmd/sql.go - About 40 mins to fix

                        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
                        Severity: Major
                        Found in whiteblock/cmd/gethCMD.go - About 40 mins to fix

                          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) {
                          Severity: Minor
                          Found in whiteblock/cmd/iperf.go - About 35 mins to fix

                            Function fetchBlockDataLocally has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            func fetchBlockDataLocally(sem *semaphore.Weighted, node Node, blockHeight int, startBlock int, dir string) {
                            Severity: Minor
                            Found in whiteblock/cmd/export.go - About 35 mins to fix

                              Function CheckIntegerBounds has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              func CheckIntegerBounds(cmd *cobra.Command, name string, val int, min int, max int) {
                              Severity: Minor
                              Found in whiteblock/util/error.go - About 35 mins to fix

                                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 {
                                Severity: Minor
                                Found in whiteblock/cmd/export.go - About 35 mins to fix

                                  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) {
                                  Severity: Minor
                                  Found in whiteblock/cmd/export.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language