cloudfoundry/dea_ng

View on GitHub
lib/dea/starting/instance.rb

Summary

Maintainability
F
3 days
Test Coverage

File instance.rb has 731 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'membrane'
require 'steno'
require 'steno/core_ext'
require 'yaml'

Severity: Major
Found in lib/dea/starting/instance.rb - About 1 day to fix

    Class Instance has 65 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Instance < Task
        include EventEmitter
    
        STAT_COLLECTION_INTERVAL_SECS = 10
    
    
    Severity: Major
    Found in lib/dea/starting/instance.rb - About 1 day to fix

      Method start has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def start(&callback)
            p = Promise.new do
              logger.info('droplet.starting')
      
              promise_state(State::BORN, State::STARTING).resolve
      Severity: Minor
      Found in lib/dea/starting/instance.rb - About 1 hr to fix

        Method snapshot_attributes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def snapshot_attributes
              {
                'cc_partition' => attributes['cc_partition'],
        
                'instance_id' => attributes['instance_id'],
        Severity: Minor
        Found in lib/dea/starting/instance.rb - About 1 hr to fix

          Method promise_start has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def promise_start
                Promise.new do |p|
                  env = Env.new(StartMessage.new(@raw_attributes), self)
          
                  if staged_info
          Severity: Minor
          Found in lib/dea/starting/instance.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 promise_health_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def promise_health_check
                Promise.new do |p|
                  begin
                    logger.debug('droplet.health-check.get-container-info')
                    container.update_path_and_ip
          Severity: Minor
          Found in lib/dea/starting/instance.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

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

              def start(&callback)
                p = Promise.new do
                  logger.info('droplet.starting')
          
                  promise_state(State::BORN, State::STARTING).resolve
          Severity: Minor
          Found in lib/dea/starting/instance.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

          Method link has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def link(&callback)
                Promise.resolve(promise_link) do |error, link_response|
                  if error
                    logger.warn('droplet.warden.link.failed', error: error, backtrace: error.backtrace)
          
          
          Severity: Minor
          Found in lib/dea/starting/instance.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

          Method promise_exec_hook_script has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def promise_exec_hook_script(key)
                Promise.new do |p|
                  if bootstrap.config['hooks'] && bootstrap.config['hooks'][key]
                    script_path = bootstrap.config['hooks'][key]
                    if File.exist?(script_path)
          Severity: Minor
          Found in lib/dea/starting/instance.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 promise_read_instance_manifest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def promise_read_instance_manifest(container_path)
                Promise.new do |p|
                  if container_path.nil?
                    p.deliver({})
                    next
          Severity: Minor
          Found in lib/dea/starting/instance.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 promise_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def promise_state(from, to = nil)
                Promise.new do |p|
                  if !Array(from).include?(state)
                    p.fail(TransitionError.new(state, to))
                  else
          Severity: Minor
          Found in lib/dea/starting/instance.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 translate_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.translate_attributes(attributes)
                attributes = attributes.dup
          
                transfer_attr_with_existance_check(attributes, 'instance_index', 'index')
                transfer_attr_with_existance_check(attributes, 'application_version', 'version')
          Severity: Minor
          Found in lib/dea/starting/instance.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