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]}"
- Read upRead up
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 remotes.rb
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'concurrent'
require 'csv'
require 'uri'
require 'net/http'
require 'time'
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]}"
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?
- Read upRead up
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]
- Read upRead up
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"