cloudfoundry/cloud_controller_ng

View on GitHub

Showing 570 of 2,679 total issues

Method update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def update(org, message)
      org.db.transaction do
        org.lock!
        org.name = message.name if message.requested?(:name)
        LabelsUpdate.update(org, message.labels, OrganizationLabelModel)
Severity: Minor
Found in app/actions/organization_update.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 enumerate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def enumerate
      if SecurityContext.missing_token?
        raise CloudController::Errors::NotAuthenticated if VCAP::CloudController::FeatureFlag.enabled?(:hide_marketplace_from_unauthenticated_users)

        single_filter = @opts[:q][0] if @opts[:q]
Severity: Minor
Found in app/controllers/services/service_plans_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 upload has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def upload
    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 update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def update(space, org, message)
      isolation_segment_guid = message.isolation_segment_guid
      if isolation_segment_guid
        isolation_segment = IsolationSegmentModel.where(guid: isolation_segment_guid).first
        raise_invalid_relationship!(isolation_segment_guid) unless isolation_segment
Severity: Minor
Found in app/actions/space_update_isolation_segment.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 buildpacks_are_uri_or_nil has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def buildpacks_are_uri_or_nil
      buildpack_infos.each do |buildpack_info|
        next if buildpack_info.buildpack_record.present?
        next if buildpack_info.buildpack.nil?
        next if buildpack_info.buildpack_url

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 advanced_filtering has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def advanced_filtering(message, dataset, klass)
        advanced_filters = {}
        advanced_filters['created_at'] = message.created_ats if message.requested?(:created_ats)
        advanced_filters['updated_at'] = message.updated_ats if message.requested?(:updated_ats)

Severity: Minor
Found in app/fetchers/base_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 make_parent_app has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def make_parent_app(package_attributes, parent_app_attributes, process_attributes)
          return process_attributes[:app] if process_attributes[:app]

          parent_app_blueprint_type = package_attributes[:docker_image].present? ? :docker : nil
          parent_app_attributes[:desired_state] = process_attributes[:state] if process_attributes.key?(:state)
Severity: Minor
Found in spec/support/fakes/process_model_factory.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

Function checkInternalLinksAndExit has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function checkInternalLinksAndExit(htmlPath) {
  const duplicateHeadingIds = [];
  const seenHeadingIds = new Set();
  const badLinks = [];
  const $ = cheerio.load(fs.readFileSync(htmlPath, 'utf8'));
Severity: Minor
Found in docs/v3/gulpfile.js - About 1 hr to fix

    Method filter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def filter(dataset, message)
            dataset = dataset.where(service_instances__name: message.names) if message.requested?(:names)
    
            if message.requested?(:type)
              dataset = case message.type
    Severity: Minor
    Found in app/fetchers/service_instance_list_fetcher.rb - About 1 hr to fix

      Method build_app_task has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def build_app_task(config, task)
              task_completion_callback = VCAP::CloudController::Diego::TaskCompletionCallbackGenerator.new(config).generate(task)
              app_volume_mounts        = VCAP::CloudController::Diego::Protocol::AppVolumeMounts.new(task.app).as_json
              task_action_builder      = LifecycleProtocol.protocol_for_type(task.droplet.lifecycle_type).task_action_builder(config, task)
      
      
      Severity: Minor
      Found in lib/cloud_controller/diego/task_recipe_builder.rb - About 1 hr to fix

        Method list has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def list
              prepare_aggregate_function
              guid_to_drain_maps = AppModel.
                                   join(ServiceBinding.table_name, app_guid: :guid).
                                   join(Space.table_name, guid: :apps__space_guid).
        Severity: Minor
        Found in app/controllers/internal/syslog_drain_urls_controller.rb - About 1 hr to fix

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

                def create(request_attrs)
                  process = nil
          
                  AppModel.db.transaction do
                    app = AppModel.create(
          Severity: Minor
          Found in app/actions/v2/app_create.rb - About 1 hr to fix

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

                def create(app, service_instance, message, volume_mount_services_enabled, accepts_incomplete)
                  raise ServiceInstanceNotBindable unless service_instance.bindable?
                  raise VolumeMountServiceDisabled if service_instance.volume_service? && !volume_mount_services_enabled
                  raise SpaceMismatch unless bindable_in_space?(service_instance, app.space)
            
            
            Severity: Minor
            Found in app/actions/v2/services/service_binding_create.rb - About 1 hr to fix

              Method build_staging_task has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def build_staging_task(config, staging_details)
                      lifecycle_type = staging_details.lifecycle.type
                      action_builder = LifecycleProtocol.protocol_for_type(lifecycle_type).staging_action_builder(config, staging_details)
              
                      ::Diego::Bbs::Models::TaskDefinition.new({
              Severity: Minor
              Found in lib/cloud_controller/diego/task_recipe_builder.rb - About 1 hr to fix

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

                      def image_layers
                        return [] unless @config.get(:diego, :enable_declarative_asset_downloads)
                
                        layers = [
                          ::Diego::Bbs::Models::ImageLayer.new(
                Severity: Minor
                Found in lib/cloud_controller/diego/staging_action_builder.rb - About 1 hr to fix

                  Method catalog has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def catalog
                      {
                        'services' => [
                          {
                            'id' => 'catalog1',
                  Severity: Minor
                  Found in spec/support/lifecycle_tests_helpers.rb - About 1 hr to fix

                    Method make_space_quota_json has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def make_space_quota_json(space_quota, associated_spaces=space_quota.spaces)
                          {
                            guid: space_quota.guid,
                            created_at: iso8601,
                            updated_at: iso8601,
                    Severity: Minor
                    Found in spec/request/space_quotas_spec.rb - About 1 hr to fix

                      Method find_or_create_valid_route has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def find_or_create_valid_route(app, manifest_route, user_audit_info)
                              manifest_route[:candidate_host_domain_pairs].each do |candidate|
                                potential_domain = candidate[:domain]
                                existing_domain = Domain.find(name: potential_domain)
                                next unless existing_domain
                      Severity: Minor
                      Found in app/actions/manifest_route_update.rb - About 1 hr to fix

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

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

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

                                  def to_hash
                                    health_check_data = { timeout: process.health_check_timeout, invocation_timeout: process.health_check_invocation_timeout, interval: process.health_check_interval }
                                    health_check_data[:endpoint] = process.health_check_http_endpoint if process.health_check_type == HealthCheckTypes::HTTP
                          
                                    readiness_health_check_data = { invocation_timeout: process.readiness_health_check_invocation_timeout, interval: process.readiness_health_check_interval }
                          Severity: Minor
                          Found in app/presenters/v3/process_presenter.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language