cloudfoundry/cloud_controller_ng

View on GitHub
app/actions/space_diff_manifest.rb

Summary

Maintainability
D
1 day
Test Coverage

Method generate_diff has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def generate_diff(app_manifests, space)
        json_diff = []

        recognized_top_level_keys = AppManifestMessage.allowed_keys.map(&:to_s).map(&:dasherize)

Severity: Minor
Found in app/actions/space_diff_manifest.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

Method filter_manifest_app_hash has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def filter_manifest_app_hash(manifest_app_hash)
        if manifest_app_hash.key? 'sidecars'
          manifest_app_hash['sidecars'] = manifest_app_hash['sidecars'].map do |hash|
            hash.slice(
              'name',
Severity: Major
Found in app/actions/space_diff_manifest.rb - About 2 hrs to fix

    Method filter_manifest_app_hash has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def filter_manifest_app_hash(manifest_app_hash)
            if manifest_app_hash.key? 'sidecars'
              manifest_app_hash['sidecars'] = manifest_app_hash['sidecars'].map do |hash|
                hash.slice(
                  'name',
    Severity: Minor
    Found in app/actions/space_diff_manifest.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 create_similarity has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

          def create_similarity
            lambda do |before, after|
              return nil unless before.is_a?(Hash) && after.is_a?(Hash)
    
              if before.key?('type') && after.key?('type')
    Severity: Minor
    Found in app/actions/space_diff_manifest.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 generate_diff has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def generate_diff(app_manifests, space)
            json_diff = []
    
            recognized_top_level_keys = AppManifestMessage.allowed_keys.map(&:to_s).map(&:dasherize)
    
    
    Severity: Minor
    Found in app/actions/space_diff_manifest.rb - About 1 hr to fix

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

            def normalize_units(manifest_app_hash)
              byte_measurement_key_words = %w[memory disk-quota disk_quota]
              manifest_app_hash.each_with_index do |process_hash, index|
                byte_measurement_key_words.each do |key|
                  value = process_hash[key]
      Severity: Minor
      Found in app/actions/space_diff_manifest.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 remove_default_missing_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def remove_default_missing_fields(existing_value, current_key, value)
              identifying_field = IDENTIFIERS[current_key]
              existing_value.each_with_index do |resource, i|
                manifest_app_hash_resource = value.find { |hash_resource| hash_resource[identifying_field] == resource[identifying_field] }
                if manifest_app_hash_resource.nil?
      Severity: Minor
      Found in app/actions/space_diff_manifest.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

      There are no issues that match your filters.

      Category
      Status