cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

Method add_organization_role has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def add_organization_role(user_guid, relationship, org_guid)
      organization = Organization.first(guid: org_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 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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    buildpack = Buildpack.find(guid: hashed_params[:guid])
    buildpack_not_found! unless buildpack

    unauthorized! unless permission_queryer.can_write_globally?
Severity: Minor
Found in app/controllers/v3/buildpacks_controller.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 transform has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def transform(users, opts={})
      user_guids = users.map(&:guid)
      username_mapping = uaa_client.usernames_for_ids(user_guids)
      organization_id = opts[:organization_id]
      space_id = opts[:space_id]
Severity: Minor
Found in app/collection_transformers/usernames_and_roles_populator.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 filter_by_org_guid has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def filter_by_org_guid(org_guids, plan_dataset, broker_dataset, omniscient, readable_orgs_query, readable_spaces_query, dataset)
        authorized_org_guids = if !omniscient && !readable_orgs_query.nil?
                                 readable_orgs_query.where(guid: org_guids).select_map(:guid)
                               else
                                 org_guids
Severity: Minor
Found in app/fetchers/base_service_list_fetcher.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 filter_by_space_guid has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def filter_by_space_guid(space_guids, plan_dataset, broker_dataset, omniscient, readable_orgs_query, readable_spaces_query, dataset)
        authorized_space_guids = if !omniscient && !readable_spaces_query.nil?
                                   readable_spaces_query.where(guid: space_guids).select_map(:guid)
                                 else
                                   space_guids
Severity: Minor
Found in app/fetchers/base_service_list_fetcher.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 validate_encryption_key_values_unchanged! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def validate_encryption_key_values_unchanged!(config)
        encryption_key_labels = config.get(:database_encryption, :keys)
        return if encryption_key_labels.blank?

        labels_with_changed_keys = []
Severity: Minor
Found in lib/cloud_controller/validate_database_keys.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 process_workpool_exceptions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def process_workpool_exceptions(exceptions)
        invalid_lrps = 0
        exceptions.each do |e|
          error_name = e.is_a?(CloudController::Errors::ApiError) ? e.name : e.class.name
          if error_name == 'RunnerInvalidRequest'
Severity: Minor
Found in lib/cloud_controller/diego/processes_sync.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 create_socket has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def create_socket(host, port)
      @debug_dev << "! CONNECT TO #{host}:#{port}\n" if @debug_dev
      clean_host = host.delete('[]')
      if @socket_local == HTTPClient::Site::EMPTY
        socket = TCPSocket.new(clean_host, port, connect_timeout: @client.socket_connect_timeout)
Severity: Minor
Found in lib/http/httpclient.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 build_api_error_matcher has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def build_api_error_matcher(error_class, api_error_name, *api_error_args)
  supports_block_expectations

  match do |actual|
    actual.call
Severity: Minor
Found in spec/support/matchers/raise_api_error.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 call has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def call(env)
        header_token = env['HTTP_AUTHORIZATION']
        request_path = env['REQUEST_PATH']

        security_context_configurer = @security_context_configurer
Severity: Minor
Found in middleware/security_context_setter.rb - About 1 hr to fix

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

          def precursor(service_instance, message:)
            validate_service_instance!(service_instance)
            key = ServiceKey.first(service_instance: service_instance, name: message.name)
            validate_key!(key, message.name)
    
    
    Severity: Minor
    Found in app/actions/service_credential_binding_key_create.rb - About 1 hr to fix

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

              def process_create_operation(logger, service_binding, last_operation_result, intended_operation)
                if state_succeeded?(last_operation_result)
                  client = VCAP::Services::ServiceClientProvider.provide(instance: service_binding.service_instance)
      
                  begin
      Severity: Minor
      Found in app/jobs/v2/services/service_binding_state_fetch.rb - About 1 hr to fix

        Method summary has 27 lines of code (exceeds 25 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 1 hr to fix

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

              def create(message)
                instance = nil
                attributes = {
                  name: message.name,
                  space_guid: message.space_guid,
          Severity: Minor
          Found in app/actions/service_instance_create_user_provided.rb - About 1 hr to fix

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

                    def to_hash
                      {
                        guid: build.guid,
                        created_at: build.created_at,
                        updated_at: build.updated_at,
            Severity: Minor
            Found in app/presenters/v3/build_presenter.rb - About 1 hr to fix

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

                      def image_layers
                        return [] unless @config.get(:diego, :enable_declarative_asset_downloads)
              
                        lifecycle_bundle_key = :"buildpack/#{@stack}"
                        lifecycle_bundle = @config.get(:diego, :lifecycle_bundles)[lifecycle_bundle_key]
              Severity: Minor
              Found in lib/cloud_controller/diego/buildpack/desired_lrp_builder.rb - About 1 hr to fix

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

                        def image_layers
                          return [] unless @config.get(:diego, :enable_declarative_asset_downloads)
                
                          lifecycle_bundle_key = :"cnb/#{@stack}"
                          lifecycle_bundle = @config.get(:diego, :lifecycle_bundles)[lifecycle_bundle_key]
                Severity: Minor
                Found in lib/cloud_controller/diego/cnb/desired_lrp_builder.rb - About 1 hr to fix

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

                    def create_app_binding_request(service_instance_guid, app_guid)
                      {
                        type: 'app',
                        metadata: {
                          annotations: {
                  Severity: Minor
                  Found in spec/support/lifecycle_tests_helpers.rb - About 1 hr to fix

                    Method perform has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def perform
                            logger = Steno.logger('cc.background')
                            logger.info("Applying app manifest to app: #{resource_guid}")
                    
                            app_guid_message_hash.each do |app_guid, message|
                    Severity: Minor
                    Found in app/jobs/space_apply_manifest_action_job.rb - About 1 hr to fix

                      Method cleanup has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              def cleanup(day_of_week)
                                logger.info("Started orphaned blobs cleanup job for day of week: #{day_of_week}")
                      
                                update_existing_orphaned_blobs
                      
                      
                      Severity: Minor
                      Found in app/jobs/runtime/orphaned_blobs_cleanup.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language