Gurpartap/cognizant

View on GitHub
lib/cognizant/daemon.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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

    def stop_previous_daemon
      if self.pidfile and File.exists?(self.pidfile)
        if previous_daemon_pid = File.read(self.pidfile).to_i
          # Only attempt to stop automatically if the daemon will run in background.
          if self.daemonize and Cognizant::System.pid_running?(previous_daemon_pid)
Severity: Minor
Found in lib/cognizant/daemon.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 start has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def start(options = {})
      self.reset!

      load_files = []
      rb_files   = []
Severity: Major
Found in lib/cognizant/daemon.rb - About 2 hrs to fix

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

        def start(options = {})
          self.reset!
    
          load_files = []
          rb_files   = []
    Severity: Minor
    Found in lib/cognizant/daemon.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 load_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def load_file(file)
          if file.end_with?(".yml")
            yml_config = YAML.load_file(file)
            if yml_config
              yml_config.deep_symbolize_keys!
    Severity: Minor
    Found in lib/cognizant/daemon.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

    There are no issues that match your filters.

    Category
    Status