cloudfoundry/cloud_controller_ng

View on GitHub

Showing 570 of 2,676 total issues

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 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 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 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 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 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

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

                        def create(message, lifecycle)
                          app = nil
                          AppModel.db.transaction do
                            app = AppModel.create(
                              name: message.name,
                    Severity: Minor
                    Found in app/actions/app_create.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 render_json has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def render_json(controller, obj, opts)
                              inline_relations_depth = opts[:inline_relations_depth] || @default_inline_relations_depth
                              if inline_relations_depth > @max_inline_relations_depth
                                raise CloudController::Errors::ApiError.new_from_details('BadQueryParameter',
                                                                                         "inline_relations_depth must be <= #{@max_inline_relations_depth}")
                        Severity: Minor
                        Found in lib/cloud_controller/rest_controller/object_renderer.rb - About 1 hr to fix

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

                            def create_route_binding_request(route_guid, service_instance_guid)
                              {
                                metadata: {
                                  annotations: {
                                    foo: 'bar'
                          Severity: Minor
                          Found in spec/request/lifecycle/service_route_bindings_synoptic_spec.rb - About 1 hr to fix

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

                              def start_cc(opts={})
                                @cc_pids ||= []
                            
                                config_file = opts[:config] || 'config/cloud_controller.yml'
                                config = VCAP::CloudController::YAMLConfig.safe_load_file(config_file)
                            Severity: Minor
                            Found in spec/support/integration/setup.rb - About 1 hr to fix

                              Method record_create has 8 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                    def self.record_create(deployment, droplet, user_audit_info, v3_app_name, space_guid, org_guid, params, type)
                              Severity: Major
                              Found in app/repositories/deployment_event_repository.rb - About 1 hr to fix

                                Method serialize_to_one_relationship has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        def serialize_to_one_relationship(response, associated_model_instance, associated_controller, relationship_name, depth, opts, parents, orphans)
                                Severity: Major
                                Found in app/presenters/v2/relations_presenter.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language