Showing 35 of 43 total issues
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 validate_process!
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def validate_process!(process)
# validate uniqueness of group:process
process_key = [process.attributes[:group], process.name].join(':')
if @@process_keys.key?(process_key)
$stderr.print "Config Error: You have two entries for the process name '#{process.name}'"
- 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 execute_blocking
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def execute_blocking(cmd, options = {})
rd, wr = IO.pipe
child = Daemonize.safefork
if child
- 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 kill_previous_bluepill
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def kill_previous_bluepill
return unless File.exist?(pid_file)
previous_pid = File.read(pid_file).to_i
return unless System.pid_alive?(previous_pid)
::Process.kill(0, previous_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
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 status
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def status(process_name = nil)
lines = []
if process_name.nil?
prefix = name ? ' ' : ''
lines << "#{name}:" if name
- 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 validate_process!
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_process!(process)
# validate uniqueness of group:process
process_key = [process.attributes[:group], process.name].join(':')
if @@process_keys.key?(process_key)
$stderr.print "Config Error: You have two entries for the process name '#{process.name}'"
Method execute_blocking
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute_blocking(cmd, options = {})
rd, wr = IO.pipe
child = Daemonize.safefork
if child
Method kill_all_pids_from_journal
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def kill_all_pids_from_journal(journal_name)
filename = pid_journal_filename(journal_name)
j = pid_journal(filename)
if !j.empty?
acquire_atomic_fs_lock(filename) do
- 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 kill_all_pgids_from_journal
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def kill_all_pgids_from_journal(journal_name)
filename = pgid_journal_filename(journal_name)
j = pgid_journal(filename)
if !j.empty?
acquire_atomic_fs_lock(filename) do
- 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 daemonize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def daemonize(cmd, options = {})
rd, wr = IO.pipe
child = Daemonize.safefork
if child
- 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 start_listener
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def start_listener
@listener_thread.kill if @listener_thread
@listener_thread = Thread.new do
loop do
begin
- 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 drop_privileges
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def drop_privileges(uid, gid, supplementary_groups)
return unless ::Process::Sys.geteuid.zero?
uid_num = Etc.getpwnam(uid).uid if uid
gid_num = Etc.getgrnam(gid).gid if gid
supplementary_groups ||= []
- 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 handle_command
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_command(application, command, *args)
case command.to_sym
when :status
puts send_to_daemon(application, :status, *args)
when :quit
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 kill_all_pgids_from_journal
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def kill_all_pgids_from_journal(journal_name)
filename = pgid_journal_filename(journal_name)
j = pgid_journal(filename)
if !j.empty?
acquire_atomic_fs_lock(filename) do
Method kill_all_pids_from_journal
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def kill_all_pids_from_journal(journal_name)
filename = pid_journal_filename(journal_name)
j = pid_journal(filename)
if !j.empty?
acquire_atomic_fs_lock(filename) do
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"