kennethkalmer/daemon-kit

View on GitHub

Showing 24 of 32 total issues

File capistrano.rb has 363 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'yaml'
require 'capistrano/recipes/deploy/scm'
require 'capistrano/recipes/deploy/strategy'

def _cset(name, *args, &block)
Severity: Minor
Found in lib/daemon_kit/deployment/capistrano.rb - About 4 hrs to fix

    Method reopen_logs has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

          def reopen_logs
            nr = 0
            append_flags = File::WRONLY | File::APPEND
            DaemonKit.logger.info "Rotating logs" if DaemonKit.logger
    
    
    Severity: Minor
    Found in lib/daemon_kit/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

    Class AbstractLogger has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class AbstractLogger
    
        attr_accessor :copy_to_stdout
    
        @severities = {
    Severity: Minor
    Found in lib/daemon_kit/abstract_logger.rb - About 3 hrs to fix

      File initializer.rb has 295 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'pathname'
      
      DAEMON_ENV = (ENV['DAEMON_ENV'] || 'development').dup unless defined?(DAEMON_ENV)
      
      # Absolute paths to the daemon_kit libraries added to $:
      Severity: Minor
      Found in lib/daemon_kit/initializer.rb - About 3 hrs to fix

        Method configuration has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

              def configuration( argv )
                configs = []
        
                i = 0
                while i < argv.size
        Severity: Minor
        Found in lib/daemon_kit/arguments.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 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def stop
                @pid_file = PidFile.new( DaemonKit.configuration.pid_file( DaemonKit.configuration.instance ) )
        
                unless @pid_file.running?
                  @pid_file.cleanup
        Severity: Minor
        Found in lib/daemon_kit/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 initialize has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize
              @options = {}
        
              @parser = OptionParser.new do |opts|
                opts.banner = "Usage: #{File.basename($0)} [command] [options]"
        Severity: Minor
        Found in lib/daemon_kit/arguments.rb - About 1 hr to fix

          Method configuration has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def configuration( argv )
                  configs = []
          
                  i = 0
                  while i < argv.size
          Severity: Minor
          Found in lib/daemon_kit/arguments.rb - About 1 hr to fix

            Method stop has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def stop
                    @pid_file = PidFile.new( DaemonKit.configuration.pid_file( DaemonKit.configuration.instance ) )
            
                    unless @pid_file.running?
                      @pid_file.cleanup
            Severity: Minor
            Found in lib/daemon_kit/application.rb - About 1 hr to fix

              Method parse_arguments! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_arguments!
                    return unless own_args?
              
                    configs = Arguments.configuration( ARGV ).first
                    @unused_arguments = {}
              Severity: Minor
              Found in lib/daemon_kit/initializer.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 shutdown has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.shutdown( clean = false, do_exit = false )
                    return unless $daemon_kit_shutdown_hooks_ran.nil?
                    $daemon_kit_shutdown_hooks_ran = true
              
                    DaemonKit.logger.info "Running shutdown hooks"
              Severity: Minor
              Found in lib/daemon_kit/initializer.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 initialize_logger has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize_logger
                    return if DaemonKit.logger
              
                    unless logger = configuration.logger
                      logger = AbstractLogger.new( configuration.log_path )
              Severity: Minor
              Found in lib/daemon_kit/initializer.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 process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def process( transport, from, workitem )
                      # keep it singleton
                      @instance ||= new
              
                      work = parse( workitem )
              Severity: Minor
              Found in lib/daemon_kit/ruote_workitem.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize
                    @config = DaemonKit::Config.load('xmpp')
              
                    if @config.enable_logging
                      Blather.logger = DaemonKit.logger
              Severity: Minor
              Found in lib/daemon_kit/xmpp.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 help has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def help
                      namespaces = constants.inject([]) do |list, sym|
                        unless sym == :Base || sym == :AppGenerator
                          klass = const_get( sym )
                          list << klass.namespace if klass.respond_to?( :namespace )
              Severity: Minor
              Found in lib/daemon_kit/generators.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 trap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def trap( signal, proc = nil, &block )
                    return if proc.nil? && !block_given?
              
                    # One step towards running on windows, not enough though
                    unless Signal.list.include?( signal )
              Severity: Minor
              Found in lib/daemon_kit/initializer.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def initialize( *args )
                      super
              
                      unless INSTALLERS.include?( options[:installer] )
                        raise Error, "Invalid value for --installer option. Supported installers are: #{INSTALLERS.join(', ')}"
              Severity: Minor
              Found in lib/generators/daemon_kit/app/app_generator.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 try_sudo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def try_sudo(*args)
                options = args.last.is_a?(Hash) ? args.pop : {}
                command = args.shift
                raise ArgumentError, "too many arguments" if args.any?
              
              
              Severity: Minor
              Found in lib/daemon_kit/deployment/capistrano.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 logger= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def logger=( logger )
                    if logger.is_a?( Symbol )
                      @backend = logger
                      @logger.close rescue nil
                      @logger = create_logger
              Severity: Minor
              Found in lib/daemon_kit/abstract_logger.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 drop_privileges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def drop_privileges
                      if DaemonKit.configuration.group
                        begin
                          group = Etc.getgrnam( DaemonKit.configuration.group )
                          Process::Sys.setgid( group.gid.to_i )
              Severity: Minor
              Found in lib/daemon_kit/application.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