acuppy/daemons

View on GitHub

Showing 22 of 27 total issues

Method start_proc has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def start_proc
      return unless p = options[:proc]

      myproc = proc do

Severity: Minor
Found in lib/daemons/application.rb - About 4 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 has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def stop(no_wait = false)
      unless running?
        zap
        return
      end
Severity: Minor
Found in lib/daemons/application.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

File application.rb has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'daemons/pidfile'
require 'daemons/pidmem'
require 'daemons/change_privilege'
require 'daemons/daemonize'
require 'daemons/exceptions'
Severity: Minor
Found in lib/daemons/application.rb - About 3 hrs to fix

    Method start_load has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def start_load
          unless options[:ontop]
            Daemonize.daemonize(output_logfile, @group.app_name)
          else
            Daemonize.simulate(output_logfile)
    Severity: Minor
    Found in lib/daemons/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

    Class Application has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Application
        attr_accessor :app_argv
        attr_accessor :controller_argv
    
        # the Pid instance belonging to this application
    Severity: Minor
    Found in lib/daemons/application.rb - About 2 hrs to fix

      Method start_none has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def start_none
            unless options[:ontop]
              Daemonize.daemonize(output_logfile, @group.app_name)
            else
              Daemonize.simulate(output_logfile)
      Severity: Minor
      Found in lib/daemons/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 stop has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def stop(no_wait = false)
            unless running?
              zap
              return
            end
      Severity: Minor
      Found in lib/daemons/application.rb - About 1 hr to fix

        Method run has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def run
              @options.update @optparse.parse(@controller_part).delete_if { |k, v| !v }
        
              setup_options
        
        
        Severity: Minor
        Found in lib/daemons/controller.rb - About 1 hr to fix

          Method initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(controller)
                @controller = controller
                @options = {}
          
                @opts = OptionParser.new do |opts|
          Severity: Minor
          Found in lib/daemons/cmdline.rb - About 1 hr to fix

            Method new_application has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def new_application(add_options = {})
                  if @applications.size > 0 && !@multiple
                    if options[:force]
                      @applications.delete_if do |a|
                        unless a.running?
            Severity: Minor
            Found in lib/daemons/application_group.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_load has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def start_load
                  unless options[:ontop]
                    Daemonize.daemonize(output_logfile, @group.app_name)
                  else
                    Daemonize.simulate(output_logfile)
            Severity: Minor
            Found in lib/daemons/application.rb - About 1 hr to fix

              Method start_proc has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def start_proc
                    return unless p = options[:proc]
              
                    myproc = proc do
              
              
              Severity: Minor
              Found in lib/daemons/application.rb - About 1 hr to fix

                Method run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def run
                      @options.update @optparse.parse(@controller_part).delete_if { |k, v| !v }
                
                      setup_options
                
                
                Severity: Minor
                Found in lib/daemons/controller.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 redirect_io has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def redirect_io(logfile_name)
                    begin; STDIN.reopen '/dev/null'; rescue ::Exception; end
                
                    if logfile_name
                      begin
                Severity: Minor
                Found in lib/daemons/daemonize.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 find_files has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.find_files(dir, progname, delete = false)
                      files = Dir[File.join(dir, "#{progname}_num*.pid")]
                      files = Dir[File.join(dir, "#{progname}.pid")] if files.size == 0
                
                      files.delete_if { |f| not (File.file?(f) and File.readable?(f)) }
                Severity: Minor
                Found in lib/daemons/pidfile.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 call_as_daemon has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def call_as_daemon(block, logfile_name = nil, app_name = nil)
                    # we use a pipe to return the PID of the daemon
                    rd, wr = IO.pipe
                
                    if tmppid = safefork
                Severity: Minor
                Found in lib/daemons/daemonize.rb - About 55 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 close_io has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def close_io
                    # Make sure all input/output streams are closed
                    # Part I: close all IO objects (except for STDIN/STDOUT/STDERR)
                    ObjectSpace.each_object(IO) do |io|
                      unless [STDIN, STDOUT, STDERR].include?(io)
                Severity: Minor
                Found in lib/daemons/daemonize.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def initialize(dir, progname, multiple = false)
                      @dir = File.expand_path(dir)
                      @progname = progname
                      @multiple = multiple
                      @number = nil
                Severity: Minor
                Found in lib/daemons/pidfile.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 find has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.find(dir, app_name)
                      pid = PidFile.find_files(dir, app_name, false)[0]
                
                      if pid
                        pid = PidFile.existing(pid)
                Severity: Minor
                Found in lib/daemons/monitor.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 default_show_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def default_show_status(daemon = self)
                      running = daemon.running?
                
                      puts "#{group.app_name}: #{running ? '' : 'not '}running#{(running and daemon.pid.exist?) ? ' [pid ' + daemon.pid.pid.to_s + ']' : ''}#{(daemon.pid.exist? and not running) ? ' (but pid-file exists: ' + daemon.pid.pid.to_s + ')' : ''}"
                    end
                Severity: Minor
                Found in lib/daemons/application.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

                Severity
                Category
                Status
                Source
                Language