bluepill-rb/bluepill

View on GitHub

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'
Severity: Minor
Found in lib/bluepill/process.rb - About 5 hrs to fix

    Class Process has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Process
        CONFIGURABLE_ATTRIBUTES = [
          :pre_start_command,
          :start_command,
          :stop_command,
    Severity: Minor
    Found in lib/bluepill/process.rb - About 4 hrs to fix

      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}'"
      Severity: Minor
      Found in lib/bluepill/dsl/process_factory.rb - About 3 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 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
      Severity: Minor
      Found in lib/bluepill/system.rb - About 3 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 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)
      Severity: Minor
      Found in lib/bluepill/application.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 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
      Severity: Minor
      Found in lib/bluepill/process.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 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
      Severity: Minor
      Found in lib/bluepill/group.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 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}'"
      Severity: Minor
      Found in lib/bluepill/dsl/process_factory.rb - About 2 hrs to fix

        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
        Severity: Minor
        Found in lib/bluepill/system.rb - About 1 hr to fix

          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
          Severity: Minor
          Found in lib/bluepill/process_journal.rb - About 1 hr 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 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
          Severity: Minor
          Found in lib/bluepill/process_journal.rb - About 1 hr 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 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
          Severity: Minor
          Found in lib/bluepill/process.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/bluepill/system.rb - About 1 hr 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 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
            Severity: Minor
            Found in lib/bluepill/application.rb - About 1 hr 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 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 ||= []
            Severity: Minor
            Found in lib/bluepill/system.rb - About 1 hr 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 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
            Severity: Minor
            Found in lib/bluepill/controller.rb - About 1 hr to fix

              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?
              Severity: Minor
              Found in lib/bluepill/process.rb - About 1 hr 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 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
              Severity: Minor
              Found in lib/bluepill/process_journal.rb - About 1 hr to fix

                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
                Severity: Minor
                Found in lib/bluepill/process_journal.rb - About 1 hr to fix

                  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)
                  Severity: Minor
                  Found in lib/bluepill/process.rb - About 1 hr 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

                  Severity
                  Category
                  Status
                  Source
                  Language