zold-io/zold

View on GitHub

Showing 108 of 118 total issues

Method run has 31 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 push [ID...] [options]
Available options:"
        o.bool '--ignore-score-weakness',
Severity: Minor
Found in lib/zold/commands/push.rb - About 1 hr to fix

    Method exec has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.exec(threads, set = (0..threads - 1).to_a, &block)
          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 1 hr to fix

      Method merge_one has 31 lines of code (exceeds 25 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 1 hr to fix

        Method fetch_one has 30 lines of code (exceeds 25 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 1 hr to fix

          Method iterate has 30 lines of code (exceeds 25 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 1 hr to fix

            Method run has 30 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 score [options]
            Available options:"
                    o.string '--time',
            Severity: Minor
            Found in lib/zold/commands/calculate.rb - About 1 hr to fix

              Method start has 29 lines of code (exceeds 25 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 1 hr to fix

                Method acq has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def acq(id, exclusive: false)
                      @wallets.acq(id, exclusive: exclusive) do |wallet|
                        unless wallet.exists?
                          if @queue.size > 256
                            @log.error("Hungry queue is full with #{@queue.size} wallets, can't add #{id}")
                Severity: Minor
                Found in lib/zold/hungry_wallets.rb - 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

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

                    def run(args = [])
                      opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
                        o.banner = "Usage: zold merge [ID...] [options]
                Available options:"
                        o.bool '--skip-propagate',
                Severity: Minor
                Found in lib/zold/commands/merge.rb - 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

                Method run has a Cognitive Complexity of 10 (exceeds 5 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: Minor
                Found in lib/zold/commands/remote.rb - 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

                Method metronome has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def metronome(farm, opts, host, port)
                      metronome = Metronome.new(@log)
                      if opts['no-metronome']
                        @log.info("Metronome hasn't been started because of --no-metronome")
                        return metronome
                Severity: Minor
                Found in lib/zold/commands/node.rb - 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

                Method to_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def to_hash
                      raise CantParse, "JSON is empty, can't parse#{@uri.empty? ? '' : " at #{@uri}"}" if @text.empty?
                      JSON.parse(@text)
                    rescue JSON::ParserError => e
                      raise CantParse, "Failed to parse JSON #{@uri.empty? ? '' : "at #{@uri}"} (#{short(e.message)}): #{short(@text)}"
                Severity: Minor
                Found in lib/zold/json_page.rb - 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

                Method start has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def start
                      raise 'Block must be given to start()' unless block_given?
                      FileUtils.mkdir_p(@dir)
                      DirItems.new(@dir).fetch.each do |f|
                        file = File.join(@dir, f)
                Severity: Minor
                Found in lib/zold/node/async_entrance.rb - About 1 hr to fix

                  Method save has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def save(file, overwrite: false, allow_negative_balance: false)
                        raise 'You have to join at least one wallet in' if empty?
                        before = ''
                        wallet = Wallet.new(file)
                        before = wallet.digest if wallet.exists?
                  Severity: Minor
                  Found in lib/zold/patch.rb - About 1 hr to fix

                    Method all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def all(masters_first: true)
                          Futex.new(file, log: @log).open(false) do
                            list = load.group_by { |s| s[:name] }.map do |name, scores|
                              {
                                name: name,
                    Severity: Minor
                    Found in lib/zold/copies.rb - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def exec(_ = 0)
                        sleep(60) unless @opts['routine-immediately']
                        cmd = Zold::Remove.new(wallets: @wallets, log: @log)
                        args = ['remove']
                        seen = 0
                    Severity: Minor
                    Found in lib/zold/commands/routines/gc.rb - About 55 mins 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 show has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def show
                          @remotes.all.each do |r|
                            score = Rainbow("/#{r[:score]}").color(r[:score].positive? ? :green : :red)
                            @log.info(
                              [
                    Severity: Minor
                    Found in lib/zold/commands/remote.rb - About 55 mins 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 assert_host_info has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def assert_host_info(host, port)
                          raise 'Host can\'t be nil' if host.nil?
                          raise 'Host can\'t be empty' if host.empty?
                          raise 'Host IP is wrong, can\'t be all zeros' if host == '0.0.0.0'
                          raise 'Port can\'t be nil' if port.nil?
                    Severity: Minor
                    Found in lib/zold/remotes.rb - About 55 mins 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 sub has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def sub(amount, invoice, pvt, details = '-', time: Time.now)
                          raise 'The amount has to be of type Amount' unless amount.is_a?(Amount)
                          raise "The amount can't be negative: #{amount}" if amount.negative?
                          raise 'The pvt has to be of type Key' unless pvt.is_a?(Key)
                          prefix, target = invoice.split('@')
                    Severity: Minor
                    Found in lib/zold/wallet.rb - About 45 mins 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 add has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def add(txn)
                          raise 'The txn has to be of type Txn' unless txn.is_a?(Txn)
                          raise "Wallet #{id} can't pay itself: #{txn}" if txn.bnf == id
                          raise "The amount can't be zero in #{id}: #{txn}" if txn.amount.zero?
                          if txn.amount.negative? && includes_negative?(txn.id)
                    Severity: Minor
                    Found in lib/zold/wallet.rb - About 45 mins 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