ioquatix/process-daemon

View on GitHub

Showing 7 of 7 total issues

Class Daemon has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Daemon
        # Initialize the daemon in the given working root.
        def initialize(working_directory = ".")
            @working_directory = working_directory
            
Severity: Minor
Found in lib/process/daemon.rb - About 2 hrs to fix

    Method spawn has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                def spawn
                    @daemon.prefork
                    @daemon.mark_log
    
                    fork do
    Severity: Minor
    Found in lib/process/daemon/controller.rb - About 1 hr to fix

      Method stop has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

                  def stop
                      @output.puts Rainbow("Stopping #{@daemon.name} daemon...").blue
      
                      # Check if the pid file exists...
                      unless File.file?(@daemon.process_file_path)
      Severity: Minor
      Found in lib/process/daemon/controller.rb - About 45 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 stop_by_terminate_or_kill has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                  def stop_by_terminate_or_kill(pgid)
                      # TERM/KILL loop - if the daemon didn't die easily, shoot it a few more times.
                      (STOP_ATTEMPTS+1).times do |attempt|
                          break unless ProcessFile.running(@daemon)
      
      
      Severity: Minor
      Found in lib/process/daemon/controller.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 reverse_gets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                  def reverse_gets(sep_string=$/)
                      end_pos = tell
      
                      offset = nil
                      buf = ""
      Severity: Minor
      Found in lib/process/daemon/log_file.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 start has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                  def start
                      @output.puts Rainbow("Starting #{@daemon.name} daemon...").blue
      
                      case self.status
                      when :running
      Severity: Minor
      Found in lib/process/daemon/controller.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 wait has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                  def wait(timeout: nil)
                      if timeout
                          read_ready, _, _ = IO.select([@output], [], [], timeout)
                          
                          return false unless read_ready and read_ready.any?
      Severity: Minor
      Found in lib/process/daemon/notification.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

      Severity
      Category
      Status
      Source
      Language