cloudfoundry-community/bosh-cloudstack-cpi

View on GitHub
bosh_agent/lib/bosh_agent/monit.rb

Summary

Maintainability
D
1 day
Test Coverage

Class Monit has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Monit
    BUFSIZE = (32 * 1024)
    NUM_RETRY_MONIT_INCARNATION = 60
    NUM_RETRY_MONIT_WAIT_INCARNATION = 15

Severity: Minor
Found in bosh_agent/lib/bosh_agent/monit.rb - About 4 hrs to fix

    Method exec_monit has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def exec_monit
          status = nil
    
          stdout_rd, stdout_wr = IO.pipe()
          stderr_rd, stderr_wr = IO.pipe()
    Severity: Minor
    Found in bosh_agent/lib/bosh_agent/monit.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 monit.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'bosh_agent/monit_client'
    
    module Bosh::Agent
      # A good chunk of this code is lifted from the implementation of POSIX::Spawn::Child
      class Monit
    Severity: Minor
    Found in bosh_agent/lib/bosh_agent/monit.rb - About 2 hrs to fix

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

            def retry_monit_request(attempts=10)
              # HACK: Monit becomes unresponsive after reload
              begin
                yield monit_api_client if block_given?
              rescue Errno::ECONNREFUSED, TimeoutError
      Severity: Minor
      Found in bosh_agent/lib/bosh_agent/monit.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 service_group_state has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def service_group_state(num_retries=10)
              # FIXME: state should be unknown if monit is disabled
              # However right now that would break director interaction
              # (at least in integration tests)
              return "running" unless @enabled
      Severity: Minor
      Found in bosh_agent/lib/bosh_agent/monit.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 log_monit_output has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def log_monit_output(stdout, stderr)
            timeout = nil
            out, err = '', ''
            readers = [stdout, stderr]
            writers = []
      Severity: Minor
      Found in bosh_agent/lib/bosh_agent/monit.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

      There are no issues that match your filters.

      Category
      Status