Method run
has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring. Open
def run
@status = :run
output_header "cluster"
- 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 cluster.rb
has 446 lines of code (exceeds 250 allowed). Consider refactoring. Open
require_relative 'runner'
require_relative 'util'
require_relative 'plugin'
require_relative 'cluster/worker_handle'
require_relative 'cluster/worker'
Method run
has 128 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
@status = :run
output_header "cluster"
Class Cluster
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class Cluster < Runner
def initialize(launcher)
super(launcher)
@phase = 0
Method wait_workers
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def wait_workers
# Reap all children, known workers or otherwise.
# If puma has PID 1, as it's common in containerized environments,
# then it's responsible for reaping orphaned processes, so we must reap
# all our dead children, regardless of whether they are workers we spawned
- 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 setup_signals
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def setup_signals
if @options[:fork_worker]
Signal.trap "SIGURG" do
fork_worker!
end
- 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 setup_signals
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_signals
if @options[:fork_worker]
Signal.trap "SIGURG" do
fork_worker!
end
Method wait_workers
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def wait_workers
# Reap all children, known workers or otherwise.
# If puma has PID 1, as it's common in containerized environments,
# then it's responsible for reaping orphaned processes, so we must reap
# all our dead children, regardless of whether they are workers we spawned
Avoid deeply nested control flow statements. Open
if idle_workers[pid]
idle_workers.delete pid
else
idle_workers[pid] = true
end
Method check_workers
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_workers
return if @next_check >= Time.now
@next_check = Time.now + @options[:worker_check_interval]
- 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
Avoid deeply nested control flow statements. Open
w.term unless w.term?
Avoid deeply nested control flow statements. Open
if !booted && @workers.none? {|worker| worker.last_status.empty?}
@events.fire_on_booted!
debug_loaded_extensions("Loaded Extensions - master:") if @log_writer.debug?
booted = true
end
Method spawn_workers
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def spawn_workers
diff = @options[:workers] - @workers.size
return if diff < 1
master = Process.pid
- 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
Avoid deeply nested control flow statements. Open
if in_phased_restart && workers_not_booted.positive? && w0 = worker_at(0)
w0.ping!(status)
@events.fire(:ping!, w0)
end
Method timeout_workers
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def timeout_workers
@workers.each do |w|
if !w.term? && w.ping_timeout <= Time.now
details = if w.booted?
"(Worker #{w.index} failed to check in within #{@options[:worker_timeout]} seconds)"
- 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"