zold-io/zold

View on GitHub

Showing 107 of 117 total issues

Method add has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def add(content, host, port, score, time: Time.now, master: false)
      raise "Content can't be empty" if content.empty?
      raise 'TCP port must be of type Integer' unless port.is_a?(Integer)
      raise "TCP port can't be negative: #{port}" if port.negative?
      raise 'Time must be of type Time' unless time.is_a?(Time)
Severity: Minor
Found in lib/zold/copies.rb - About 1 hr to fix

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

        def start(host, port, threads: Concurrent.processor_count)
          raise 'Block is required for the farm to start' unless block_given?
          @log.info('Zero-threads farm won\'t score anything!') if threads.zero?
          if best.empty?
            @log.info("No scores found in the cache at #{@cache}")
    Severity: Minor
    Found in lib/zold/node/farm.rb - About 1 hr to fix

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

        Method metronome has 37 lines of code (exceeds 25 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

          Method clean has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def clean(max: 24 * 60 * 60)
                Futex.new(file, log: @log).open do
                  list = load
                  list.reject! do |s|
                    if s[:time] >= Time.now - max
          Severity: Minor
          Found in lib/zold/copies.rb - About 1 hr to fix

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

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

                    def acq(id, exclusive: false)
                      @wallets.acq(id, exclusive: exclusive) do |wallet|
                        return yield wallet unless exclusive
                        before = wallet.exists? ? IO.read(wallet.path) : ''
                        res = yield wallet
              Severity: Minor
              Found in lib/zold/node/journaled_pipeline.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 exec has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                def exec(_ = 0)
                  sleep(20 * 60) unless @opts['routine-immediately']
                  @remotes.iterate(@log) do |r|
                    next unless r.master?
                    next if r.to_mnemo == @address
              Severity: Minor
              Found in lib/zold/commands/routines/reconcile.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 elect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def elect(opts)
                    scores = []
                    @remotes.iterate(@log, farm: @farm, threads: opts['threads']) do |r|
                      uri = '/'
                      res = r.http(uri).get
              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 nohup has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def nohup(opts)
                    pid = fork do
                      nohup_log = NohupLog.new(opts['nohup-log'], opts['nohup-log-truncate'])
                      Signal.trap('HUP') do
                        nohup_log.print("Received HUP, ignoring...\n")
              Severity: Minor
              Found in lib/zold/commands/node.rb - About 1 hr to fix

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

                  Method fetch has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def fetch(id, cps, opts)
                        if @remotes.all.empty?
                          return if opts['quiet-if-absent']
                          raise "There are no remote nodes, run 'zold remote reset'"
                        end
                  Severity: Minor
                  Found in lib/zold/commands/fetch.rb - About 1 hr to fix

                    Method push has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def push(id, opts)
                          raise "There are no remote nodes, run 'zold remote reset'" if @remotes.all.empty?
                          @wallets.acq(id) do |wallet|
                            raise "The wallet #{id} is absent at #{wallet.path}" unless wallet.exists?
                          end
                    Severity: Minor
                    Found in lib/zold/commands/push.rb - About 1 hr to fix

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

                          def initialize(zents: nil, zld: nil)
                            if !zents.nil?
                              raise "Integer is required, while #{zents.class} provided: #{zents}" unless zents.is_a?(Integer)
                              @zents = zents
                            elsif !zld.nil?
                      Severity: Minor
                      Found in lib/zold/amount.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 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def run(args = [])
                            opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
                              o.banner = "Usage: zold taxes command [options]
                      Available commands:
                          #{Rainbow('taxes pay').green} wallet
                      Severity: Minor
                      Found in lib/zold/commands/taxes.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 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def run(args = [])
                            opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
                              o.banner = "Usage: zold pay wallet target amount [details] [options]
                      Where:
                          'wallet' is the sender's wallet ID
                      Severity: Minor
                      Found in lib/zold/commands/pay.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 exec has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def exec(step = 0)
                          sleep(60) unless @opts['routine-immediately']
                          cmd = Zold::Remote.new(remotes: @remotes, log: @log, farm: @farm)
                          args = ['remote', "--network=#{Shellwords.escape(@opts['network'])}", '--ignore-ping']
                          score = @farm.best[0]
                      Severity: Minor
                      Found in lib/zold/commands/routines/reconnect.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 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)
                              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
                            Severity
                            Category
                            Status
                            Source
                            Language