zold-io/zold

View on GitHub
lib/zold/remotes.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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 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 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 masters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def masters
          MASTERS.each do |r|
            if block_given?
              next unless yield(r[:host], r[:port])
            end
    Severity: Minor
    Found in lib/zold/remotes.rb - About 35 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

    There are no issues that match your filters.

    Category
    Status