zold-io/zold

View on GitHub

Showing 108 of 118 total issues

Avoid too many return statements within this method.
Open

      return "#{days}d" if days < 14
Severity: Major
Found in lib/zold/age.rb - About 30 mins to fix

    Method top_scores has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def top_scores(opts)
          best = []
          @remotes.iterate(@log) do |r|
            @log.debug("Testing #{r}...")
            uri = '/'
    Severity: Minor
    Found in lib/zold/commands/taxes.rb - About 25 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 sign has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def sign(pvt, id, txn)
          raise 'pvt must be of type Key' unless pvt.is_a?(Key)
          raise 'id must be of type Id' unless id.is_a?(Id)
          raise 'txn must be of type Txn' unless txn.is_a?(Txn)
          pvt.sign(body(id, txn))
    Severity: Minor
    Found in lib/zold/signature.rb - About 25 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 all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def all
          DirItems.new(path).fetch.select do |f|
            next unless f.end_with?(Wallet::EXT)
            basename = File.basename(f, Wallet::EXT)
            file = File.join(path, f)
    Severity: Minor
    Found in lib/zold/tree_wallets.rb - About 25 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 exists? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def exists?(id, body)
          DirItems.new(@dir).fetch.each do |f|
            next unless f.start_with?("#{id}-")
            return true if safe_read(File.join(@dir, f)) == body
          end
    Severity: Minor
    Found in lib/zold/node/async_entrance.rb - About 25 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 trim has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def trim(opts)
          all = @remotes.all
          all.each do |r|
            next if r[:errors] <= opts['tolerate']
            @remotes.remove(r[:host], r[:port]) if !opts['masters-too'] || !r[:master]
    Severity: Minor
    Found in lib/zold/commands/remote.rb - About 25 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 all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def all
          list = Futex.new(@file).open(false) { load }
          max_score = list.empty? ? 0 : list.max_by { |r| r[:score] }[:score]
          max_score = 1 if max_score.zero?
          max_errors = list.empty? ? 0 : list.max_by { |r| r[:errors] }[:errors]
    Severity: Minor
    Found in lib/zold/remotes.rb - About 25 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 fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def fetch
          raise "Wallet file '#{@file}' is absent" unless File.exist?(@file)
          lines = []
          File.open(@file) do |f|
            lines << f.readline.strip while lines.count < 4 && !f.eof?
    Severity: Minor
    Found in lib/zold/head.rb - About 25 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