cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

Method render_json has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def render_json(controller, dataset, path, opts, request_params)
Severity: Minor
Found in lib/cloud_controller/rest_controller/paginated_collection_renderer.rb - About 35 mins to fix

    Method build_eager_load_hash has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def build_eager_load_hash(controller_class, model_class, default_visibility_filter, additional_visibility_filters, depth)
    Severity: Minor
    Found in lib/cloud_controller/rest_controller/secure_eager_loader.rb - About 35 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(blobstore_options, package_blobstore, buildpack_cache_blobstore, admin_buildpack_blobstore, droplet_blobstore)
      Severity: Minor
      Found in lib/cloud_controller/blobstore/url_generator/local_url_generator.rb - About 35 mins to fix

        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def initialize(blobstore_options, package_blobstore, buildpack_cache_blobstore, admin_buildpack_blobstore, droplet_blobstore)
        Severity: Minor
        Found in lib/cloud_controller/blobstore/url_generator.rb - About 35 mins to fix

          Method handle_errors has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def handle_errors(actions_that_should_not_exist, actions_that_should_exist, controller, association_name, errors)
          Severity: Minor
          Found in spec/support/matchers/have_nested_routes.rb - About 35 mins to fix

            Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def initialize(src_process, dest_process, app_event_repo, user, email)
            Severity: Minor
            Found in spec/unit/controllers/runtime/app_bits_upload_controller_spec.rb - About 35 mins to fix

              Method validate_rules has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_rules
                    return true unless rules
              
                    unless rules.is_a?(Array) && rules.all? { |r| r.is_a?(Hash) }
                      errors.add(:rules, "value must be an array of hashes. rules: '#{rules}'")
              Severity: Minor
              Found in app/models/runtime/security_group.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

              Method around_save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def around_save
                    yield
                  rescue Sequel::UniqueConstraintViolation => e
                    raise e unless e.message.include?('apps_v3_space_guid_name_index')
              
              
              Severity: Minor
              Found in app/models/runtime/app_model.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

              Method create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def create(message)
                    org_quota = nil
              
                    QuotaDefinition.db.transaction do
                      org_quota = VCAP::CloudController::QuotaDefinition.create(
              Severity: Minor
              Found in app/actions/organization_quotas_create.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

              Method validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def validate
                  return unless policy_target
                  return unless additional_checks
              
                  return unless instance_memory_limit != VCAP::CloudController::QuotaDefinition::UNLIMITED && resource_memory > instance_memory_limit
              Severity: Minor
              Found in app/models/runtime/constraints/max_instance_memory_policy.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

              Method create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def create(message, organization:)
                    space_quota = nil
              
                    SpaceQuotaDefinition.db.transaction do
                      space_quota = VCAP::CloudController::SpaceQuotaDefinition.create(
              Severity: Minor
              Found in app/actions/space_quotas_create.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

              Method before_enqueue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def before_enqueue(job)
                      if existing_guid && (existing = PollableJobModel.find(guid: existing_guid))
                        state = @handler.try(:pollable_job_state) || PollableJobModel::POLLING_STATE
                        existing.update(
                          delayed_job_guid: job.guid,
              Severity: Minor
              Found in app/jobs/pollable_job_wrapper.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

              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

              Method apply has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def apply(org_quota, message)
                    orgs = valid_orgs(message.organization_guids)
              
                    if org_quota.log_rate_limit != QuotaDefinition::UNLIMITED
                      affected_processes = Organization.where(Sequel[:organizations][:id] => orgs.map(&:id)).
              Severity: Minor
              Found in app/actions/organization_quota_apply.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

              Method apply has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def apply(space_quota, message, visible_space_guids: [], all_spaces_visible: false)
                    spaces = valid_spaces(message.space_guids, visible_space_guids, all_spaces_visible, space_quota.organization_id)
              
                    if space_quota.log_rate_limit != QuotaDefinition::UNLIMITED
                      affected_processes = Space.where(Sequel[:spaces][:id] => spaces.map(&:id)).
              Severity: Minor
              Found in app/actions/space_quota_apply.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

              Method create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def create
                  unauthorized! unless permission_queryer.can_write_globally?
              
                  message = StackCreateMessage.new(hashed_params[:body])
                  unprocessable!(message.errors.full_messages) unless message.valid?
              Severity: Minor
              Found in app/controllers/v3/stacks_controller.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

              Method create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def create
                  unauthorized! unless permission_queryer.can_write_globally?
              
                  message = SecurityGroupCreateMessage.new(hashed_params[:body])
                  unprocessable!(message.errors.full_messages) unless message.valid?
              Severity: Minor
              Found in app/controllers/v3/security_groups_controller.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

              Method valid_destination_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def valid_destination_type(destination, record, index)
                  error_message = 'destination must be a valid CIDR, IP address, or IP address range'
                  if CloudController::RuleValidator.comma_delimited_destinations_enabled?
                    error_message = 'nil destination; destination must be a comma-delimited list of valid CIDRs, IP addresses, or IP address ranges'
                  end
              Severity: Minor
              Found in app/messages/validators/security_group_rule_validator.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

              Method create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def create
                  unauthorized! unless permission_queryer.can_write_globally?
              
                  message = BuildpackCreateMessage.new(hashed_params[:body])
                  unprocessable!(message.errors.full_messages) unless message.valid?
              Severity: Minor
              Found in app/controllers/v3/buildpacks_controller.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

              Method fetch_credentials_from_cache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def fetch_credentials_from_cache(item)
                    if item[:is_managed_service]
                      credentials = item.credentials
                      cert = credentials&.fetch('cert', '') || ''
                      key = credentials&.fetch('key', '') || ''
              Severity: Minor
              Found in app/controllers/internal/syslog_drain_urls_controller.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

              Severity
              Category
              Status
              Source
              Language