File process.rb
has 396 lines of code (exceeds 250 allowed). Consider refactoring. Open
gem 'state_machine'
require 'state_machine'
require 'daemons'
require 'bluepill/system'
Class Process
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class Process
CONFIGURABLE_ATTRIBUTES = [
:pre_start_command,
:start_command,
:stop_command,
Method stop_process
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def stop_process
if monitor_children
System.get_children(actual_pid).each do |child_pid|
ProcessJournal.append_pid_to_journal(name, child_pid)
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 stop_process
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def stop_process
if monitor_children
System.get_children(actual_pid).each do |child_pid|
ProcessJournal.append_pid_to_journal(name, child_pid)
end
Method start_process
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def start_process
ProcessJournal.kill_all_from_journal(name) # be sure nothing else is running from previous runs
pre_start_process
logger.warning "Executing start command: #{start_command}"
if daemonize?
- 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 pid_from_file
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def pid_from_file
return @actual_pid if cache_actual_pid? && @actual_pid
@actual_pid = begin
if pid_file
if File.exist?(pid_file)
- 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 initialize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(process_name, checks, options = {})
@name = process_name
@event_mutex = Monitor.new
@watches = []
@triggers = []
Method run_watches
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def run_watches
now = Time.now.to_i
threads = watches.collect do |watch|
[watch, Thread.new { Thread.current[:events] = watch.run(actual_pid, now) }]
- 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 restart_process
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def restart_process
if restart_command
cmd = prepare_command(restart_command)
logger.warning "Executing restart command: #{cmd}"
- 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 tick
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def tick
return if skipping_ticks?
self.skip_ticks_until = nil
# clear the memoization per tick
- 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"