zold-io/zold

View on GitHub

Showing 117 of 117 total issues

Method join has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
Open

    def join(wallet, ledger: '/dev/null', baseline: false, master: false)
      if @id.nil?
        @id = wallet.id
        @key = wallet.key
        @network = wallet.network
Severity: Minor
Found in lib/zold/patch.rb - About 1 day 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

Method run has 255 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run(args = [])
      opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
        o.banner = 'Usage: zold node [options]'
        o.string '--invoice',
          'The invoice you want to collect money to or the wallet ID',
Severity: Major
Found in lib/zold/commands/node.rb - About 1 day to fix

    File front.rb has 528 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    STDOUT.sync = true
    
    require 'get_process_mem'
    require 'thin'
    require 'haml'
    Severity: Major
    Found in lib/zold/node/front.rb - About 1 day to fix

      File node.rb has 478 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'open3'
      require 'slop'
      require 'shellwords'
      require 'backtrace'
      require 'fileutils'
      Severity: Minor
      Found in lib/zold/commands/node.rb - About 7 hrs to fix

        Method join has 111 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def join(wallet, ledger: '/dev/null', baseline: false, master: false)
              if @id.nil?
                @id = wallet.id
                @key = wallet.key
                @network = wallet.network
        Severity: Major
        Found in lib/zold/patch.rb - About 4 hrs to fix

          Method paid has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              def paid
                txns = @wallet.txns
                scored = txns.map do |t|
                  next if t.amount.positive?
                  pfx, body = t.details.split(' ', 2)
          Severity: Minor
          Found in lib/zold/tax.rb - About 4 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

          Method run has 95 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def run(args = [])
                opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
                  o.banner = "Usage: zold remote <command> [options]
          Available commands:
              #{Rainbow('remote show').green}
          Severity: Major
          Found in lib/zold/commands/remote.rb - About 3 hrs to fix

            Method merge_one has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                def merge_one(opts, patch, wallet, name, baseline: false, master: false)
                  start = Time.now
                  @log.debug("Adding copy ##{name}#{master ? ' (master)' : ''} to the patch #{wallet.mnemo}...")
                  if opts['depth'].positive?
                    patch.join(wallet, ledger: opts['ledger'], baseline: baseline, master: master) do |txn|
            Severity: Minor
            Found in lib/zold/commands/merge.rb - About 3 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

            File remote.rb has 313 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'slop'
            require 'semantic'
            require 'rainbow'
            require 'net/http'
            require 'json'
            Severity: Minor
            Found in lib/zold/commands/remote.rb - About 3 hrs to fix

              Method initialize has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize(id, date, amount, prefix, bnf, details)
                    raise 'The ID can\'t be NIL' if id.nil?
                    raise "ID of transaction can't be negative: #{id}" if id < 1
                    @id = id
                    raise 'The time can\'t be NIL' if date.nil?
              Severity: Minor
              Found in lib/zold/txn.rb - About 3 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

              Class Wallet has 27 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Wallet
                  # The name of the main production network. All other networks
                  # must have different names.
                  MAINET = 'zold'
              
              
              Severity: Minor
              Found in lib/zold/wallet.rb - About 3 hrs to fix

                Method propagate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                    def propagate(id, _)
                      start = Time.now
                      modified = []
                      total = 0
                      network = @wallets.acq(id, &:network)
                Severity: Minor
                Found in lib/zold/commands/propagate.rb - About 3 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

                Method run has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                    def run(args = [])
                      opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
                        o.banner = 'Usage: zold node [options]'
                        o.string '--invoice',
                          'The invoice you want to collect money to or the wallet ID',
                Severity: Minor
                Found in lib/zold/commands/node.rb - 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

                Method pay has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def pay(wallet, opts)
                      raise 'The wallet is absent' unless wallet.exists?
                      tax = Tax.new(wallet)
                      debt = total = tax.debt
                      @log.info("The current debt of #{wallet.mnemo} is #{debt} (#{debt.to_i} zents), \
                Severity: Minor
                Found in lib/zold/commands/taxes.rb - 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

                Method update has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def update(opts)
                      st = Time.now
                      seen = Set.new
                      capacity = []
                      opts['depth'].times do
                Severity: Minor
                Found in lib/zold/commands/remote.rb - 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

                Method merge has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def merge(id, cps, opts)
                      start = Time.now
                      cps = cps.all(masters_first: !opts['edge-baseline'])
                      patch = Patch.new(@wallets, log: @log)
                      score = 0
                Severity: Minor
                Found in lib/zold/commands/merge.rb - 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

                Method start has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def start
                      raise 'Block must be given to start()' unless block_given?
                      @entrance.start do
                        @seen = Set.new
                        @modified = Queue.new
                Severity: Minor
                Found in lib/zold/node/spread_entrance.rb - 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

                Method fetch_one has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def fetch_one(id, r, cps, opts)
                      if opts['ignore-node'].include?(r.to_s)
                        @log.debug("#{r} ignored because of --ignore-node")
                        return 0
                      end
                Severity: Minor
                Found in lib/zold/commands/fetch.rb - 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

                Method iterate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def iterate(log, farm: Farm::Empty.new, threads: 1)
                      raise 'Log can\'t be nil' if log.nil?
                      raise 'Farm can\'t be nil' if farm.nil?
                      Hands.exec(threads, all) do |r, idx|
                        Thread.current.name = "remotes-#{idx}@#{r[:host]}:#{r[:port]}"
                Severity: Minor
                Found in lib/zold/remotes.rb - 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

                Method exec has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.exec(threads, set = (0..threads - 1).to_a)
                      raise 'The thread pool is empty' if POOL.empty?
                      raise "Number of threads #{threads} has to be positive" unless threads.positive?
                      list = set.dup
                      total = [threads, set.count].min
                Severity: Minor
                Found in lib/zold/hands.rb - 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

                Severity
                Category
                Status
                Source
                Language