bluepill-rb/bluepill

View on GitHub
lib/bluepill/process.rb

Summary

Maintainability
D
2 days
Test Coverage

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 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 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 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 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

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

          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) }]
          Severity: Minor
          Found in lib/bluepill/process.rb - About 35 mins 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 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}"
          Severity: Minor
          Found in lib/bluepill/process.rb - About 25 mins 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 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
          Severity: Minor
          Found in lib/bluepill/process.rb - About 25 mins 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

          There are no issues that match your filters.

          Category
          Status