cloudfoundry/health_manager

View on GitHub

Showing 11 of 11 total issues

Class Droplet has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Droplet
    include HealthManager::Common

    attr_reader :id, :state, :live_version, :num_instances, :package_state, :last_updated, :crashes, :extra_instances
    attr_accessor :desired_state_update_required
Severity: Minor
Found in lib/health_manager/droplet.rb - About 3 hrs to fix

    Method process_next_batch has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_next_batch(bulk_token, start_time, &block)
          with_credentials do |user, password|
            options = {
              :head => { 'authorization' => [user, password] },
              :query => {
    Severity: Minor
    Found in lib/health_manager/desired_state.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 update_extra_instances has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_extra_instances
          @extra_instances.clear
    
          num_running = 0
    
    
    Severity: Minor
    Found in lib/health_manager/droplet.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 process_next_batch has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def process_next_batch(bulk_token, start_time, &block)
          with_credentials do |user, password|
            options = {
              :head => { 'authorization' => [user, password] },
              :query => {
    Severity: Minor
    Found in lib/health_manager/desired_state.rb - About 1 hr to fix

      Method update_extra_instances has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def update_extra_instances
            @extra_instances.clear
      
            num_running = 0
      
      
      Severity: Minor
      Found in lib/health_manager/droplet.rb - About 1 hr to fix

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

            def deep_merge(first_hash, other_hash)
              first_hash.merge(other_hash) do |_, oldval, newval|
                oldval = oldval.to_hash if oldval.respond_to?(:to_hash)
                newval = newval.to_hash if newval.respond_to?(:to_hash)
                oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? deep_merge(oldval, newval) : newval
        Severity: Minor
        Found in lib/health_manager/varz.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 has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(varz, nudger, scheduler, actual_state, desired_state, droplet_registry)
        Severity: Minor
        Found in lib/health_manager/harmonizer.rb - About 45 mins to fix

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

              def with_credentials
                if @user && @password
                  yield @user, @password
                else
                  logger.info("bulk: requesting API credentials over message bus...")
          Severity: Minor
          Found in lib/health_manager/desired_state.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 schedule has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def schedule(options, &block)
                raise ArgumentError unless options.length == 1
                raise ArgumentError, 'block required' unless block_given?
                arg = options.first
                sendee = {
          Severity: Minor
          Found in lib/health_manager/scheduler.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 update_user_counts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_user_counts
                with_credentials do |user, password|
                  options = {
                    :head => { 'authorization' => [user, password] },
                    :query => { 'model' => 'user' }
          Severity: Minor
          Found in lib/health_manager/desired_state.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 on_missing_instances has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def on_missing_instances(droplet)
                unless actual_state.available?
                  logger.warn "harmonizer.actual-state.unavailable"
                  return
                end
          Severity: Minor
          Found in lib/health_manager/harmonizer.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

          Severity
          Category
          Status
          Source
          Language