kennethkalmer/daemon-kit

View on GitHub
lib/daemon_kit/initializer.rb

Summary

Maintainability
B
7 hrs
Test Coverage

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 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 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 set_root_path! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_root_path!
          raise "DAEMON_ROOT is not set" unless defined?(::DAEMON_ROOT)
          raise "DAEMON_ROOT is not a directory" unless File.directory?(::DAEMON_ROOT)
    
          @root_path = ::DAEMON_ROOT.to_absolute_path
    Severity: Minor
    Found in lib/daemon_kit/initializer.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