acuppy/daemons

View on GitHub
lib/daemons/application.rb

Summary

Maintainability
F
3 days
Test Coverage

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

            Method exception_log has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def exception_log
                  return unless logfile
            
                  require 'logger'
            
            
            Severity: Minor
            Found in lib/daemons/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

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

                  at_exit do
                    begin; @pid.cleanup; rescue ::Exception; end
            
                    # If the option <tt>:backtrace</tt> is used and the application did exit by itself
                    # create a exception log.
            Severity: Minor
            Found in lib/daemons/application.rb and 2 other locations - About 15 mins to fix
            lib/daemons/application.rb on lines 174..181
            lib/daemons/application.rb on lines 231..238

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 26.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    trap(SIGNAL) do
                      begin
                        if $daemons_stop_proc
                          $daemons_stop_proc.call
                        end
            Severity: Minor
            Found in lib/daemons/application.rb and 1 other location - About 15 mins to fix
            lib/daemons/application.rb on lines 191..205

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 26.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

                  at_exit do
                    begin; @pid.cleanup; rescue ::Exception; end
            
                    # If the option <tt>:backtrace</tt> is used and the application did exit by itself
                    # create a exception log.
            Severity: Minor
            Found in lib/daemons/application.rb and 2 other locations - About 15 mins to fix
            lib/daemons/application.rb on lines 112..119
            lib/daemons/application.rb on lines 231..238

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 26.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                  trap(SIGNAL) do
                    begin
                      if $daemons_stop_proc
                        $daemons_stop_proc.call
                      end
            Severity: Minor
            Found in lib/daemons/application.rb and 1 other location - About 15 mins to fix
            lib/daemons/application.rb on lines 248..262

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 26.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

                    at_exit do
                      begin; @pid.cleanup; rescue ::Exception; end
            
                      # If the option <tt>:backtrace</tt> is used and the application did exit by itself
                      # create a exception log.
            Severity: Minor
            Found in lib/daemons/application.rb and 2 other locations - About 15 mins to fix
            lib/daemons/application.rb on lines 112..119
            lib/daemons/application.rb on lines 174..181

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 26.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status