cloudfoundry/cloud_controller_ng

View on GitHub

Showing 582 of 2,696 total issues

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

    def validate_buildpacks_are_ready(app)
      return unless app.buildpack_lifecycle_data

      app.buildpack_lifecycle_data.buildpack_lifecycle_buildpacks.each do |blb|
        next if blb.custom?
Severity: Minor
Found in app/actions/app_create.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 decorate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def decorate(hash, resources)
      hash[:included] ||= {}

      spaces = resources.map { |r| r.try(:space) || r }.uniq
      orgs = spaces.map(&:organization).uniq
Severity: Minor
Found in app/decorators/field_service_instance_organization_decorator.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def initialize(process, health_check_timeout, health_check_invocation_timeout, health_check_type, health_check_http_endpoint, health_check_interval)
Severity: Minor
Found in app/models/runtime/constraints/base_health_check_policy.rb - About 45 mins to fix

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

          def perform
            not_found! unless service_instance
    
            raise_if_other_operations_in_progress!
    
    
    Severity: Minor
    Found in app/jobs/v3/update_service_instance_job.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 raise_if_cannot_update! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def raise_if_cannot_update!
            error_code = 'ServiceInstanceWithInaccessiblePlanNotUpdateable'.freeze
            update_error = ->(x) { UnprocessableUpdate.new_from_details(error_code, x) }
            return if service_instance.service_plan.active?
            raise update_error.call('parameters') unless message.parameters.nil?
    Severity: Minor
    Found in app/actions/v3/service_instance_update_managed.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 entity_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def entity_hash(controller, org, opts, depth, parents, orphans=nil)
    Severity: Minor
    Found in app/presenters/v2/organization_presenter.rb - About 45 mins to fix

      Method entity_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def entity_hash(controller, route_mapping, opts, depth, parents, orphans=nil)
      Severity: Minor
      Found in app/presenters/v2/route_mapping_presenter.rb - About 45 mins to fix

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

            def get_exception_from_errors(registration)
              errors = registration.errors
              broker = registration.broker
        
              if errors.on(:broker_url) && errors.on(:broker_url).include?(:url)
        Severity: Minor
        Found in app/actions/services/mixins/service_broker_registration_error_parser.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 data_content has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def data_content
              return if data.nil?
        
              errors.add(:data, 'can only accept one key') unless data.keys.length == 1
              errors.add(:data, "can only accept key 'guid'") unless data.key?(:guid)
        Severity: Minor
        Found in app/messages/orgs_default_iso_seg_update_message.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 costs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def costs
                  cost_result = []
                  if metadata[:costs]
                    validation_errors = JSON::Validator.fully_validate(costs_schema, metadata[:costs])
                    return cost_result unless validation_errors.none?
        Severity: Minor
        Found in app/presenters/v3/service_plan_presenter.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 to_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def to_hash(controller, obj, opts, depth, parents, orphans=nil)
        Severity: Minor
        Found in app/presenters/v2/base_presenter.rb - About 45 mins to fix

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

            def destroy
              sidecar = SidecarModel.find(guid: hashed_params[:guid])
              resource_not_found!(:sidecar) unless sidecar
              space = sidecar.app.space
              resource_not_found!(:sidecar) unless permission_queryer.can_read_from_space?(space.id, space.organization_id)
          Severity: Minor
          Found in app/controllers/v3/sidecars_controller.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 size_validator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def size_validator(size)
                unless size.is_a?(Integer)
                  errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-integer size_in_bytes") unless errors.added?(
                    :resources, "#{RESOURCE_ERROR_PREAMBLE} a non-integer size_in_bytes"
                  )
          Severity: Minor
          Found in app/messages/resource_match_create_message.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 entity_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def entity_hash(controller, plan, opts, depth, parents, orphans=nil)
          Severity: Minor
          Found in app/presenters/v2/service_plan_presenter.rb - About 45 mins to fix

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

                def summary(guid)
                  org = find_guid_and_validate_access(:read, guid)
                  spaces = visible_spaces(org).map do |space|
                    # when we do the quota work, this and the service counts will be kept
                    # as a running total so that we don't have to compute them on the
            Severity: Minor
            Found in app/controllers/runtime/organization_summaries_controller.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 entity_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def entity_hash(controller, service_binding, opts, depth, parents, orphans=nil)
            Severity: Minor
            Found in app/presenters/v2/service_binding_presenter.rb - About 45 mins to fix

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

                def parsed_yaml
                  return @parsed_yaml if @parsed_yaml
              
                  bad_request!('Manifest size is too large. The maximum supported size is 1MB.') if request.body.size > 1.megabyte
              
              
              Severity: Minor
              Found in app/controllers/v3/application_controller.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 entity_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      def entity_hash(controller, obj, opts, depth, parents, orphans=nil)
              Severity: Minor
              Found in app/presenters/v2/route_presenter.rb - About 45 mins to fix

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

                    def value_error
                      return MetadataError.none if value.nil? || value == ''
                
                      return MetadataError.error("'#{value}' contains invalid characters") unless valid_characters?(value)
                      return MetadataError.error("'#{value}' starts or ends with invalid characters") unless start_end_alphanumeric?(value)
                Severity: Minor
                Found in app/messages/metadata_validator_helper.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 add_space_role has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def add_space_role(user_guid, relationship, space_guid)
                      space = Space.first(guid: space_guid)
                      user = User.first(guid: user_guid)
                      user.username = @uaa_username_lookup_client.usernames_for_ids([user.guid])[user.guid] || ''
                
                
                Severity: Minor
                Found in app/controllers/runtime/users_controller.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

                Severity
                Category
                Status
                Source
                Language