cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

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

      def validate_changing_plan(current_plan, service, service_instance, requested_plan_guid)
        return unless plan_update_requested?(requested_plan_guid, current_plan)

        plan_not_updateable! unless service_allows_plan_update?(service, current_plan)

Severity: Minor
Found in app/controllers/services/validators/service_update_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_staging_spaces has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create_staging_spaces
    resource_not_found!(:security_group) unless permission_queryer.readable_security_group_guids.include?(hashed_params[:guid])
    security_group = SecurityGroup.first(guid: hashed_params[:guid])

    message = SecurityGroupApplyMessage.new(hashed_params[:body])
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 net_info_to_instance_ports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def net_info_to_instance_ports(net_info_ports)
          return [] if net_info_ports.nil?

          net_info_ports.map do |ports|
            external_tls_proxy_port_raw = HashUtils.dig(ports, :host_tls_proxy_port)
Severity: Minor
Found in app/presenters/v3/process_stats_presenter.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 unshare_from_all_spaces has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def unshare_from_all_spaces(service_instance)
      errors = []

      service_instance.reload if service_instance.exists?

Severity: Minor
Found in app/actions/services/service_instance_delete.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 build_links has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def build_links
          {
            self: { href: url_builder.build_url(path: "/v3/droplets/#{droplet.guid}") },
            app: { href: url_builder.build_url(path: "/v3/apps/#{droplet.app_guid}") },
            assign_current_droplet: { href: url_builder.build_url(path: "/v3/apps/#{droplet.app_guid}/relationships/current_droplet"), method: 'PATCH' }
Severity: Minor
Found in app/presenters/v3/droplet_presenter.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 to_param_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def to_param_hash(exclude: [], fields: [])
      params = {}
      (requested_keys - exclude).each do |key|
        val = try(key)

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

    def get_shared_domain(guid)
      domain = find_guid_and_validate_access(:read, guid)
      unless domain.router_group_guid.nil?
        begin
          rtr_grp = routing_api_client.router_group(domain.router_group_guid)
Severity: Minor
Found in app/controllers/runtime/shared_domains_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 present_pagination_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def present_pagination_hash(filters=nil)
          pagination_options = @paginated_result.pagination_options

          last_page     = (@paginated_result.total.to_f / pagination_options.per_page).ceil
          last_page     = 1 if last_page < 1
Severity: Minor
Found in app/presenters/v3/paginated_list_presenter.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(record)
        return unless record.requested?(:data)

        values = record.data
        return unless values.is_a? Array
Severity: Minor
Found in app/messages/to_many_relationship_message.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_process_types has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def valid_process_types
      return unless process_types

      unless process_types.is_a?(Hash)
        errors.add(:process_types, 'must be an object')
Severity: Minor
Found in app/messages/droplet_create_message.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 data_content has a Cognitive Complexity of 7 (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/space_update_isolation_segment_message.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_running_spaces has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create_running_spaces
    resource_not_found!(:security_group) unless permission_queryer.readable_security_group_guids.include?(hashed_params[:guid])
    security_group = SecurityGroup.first(guid: hashed_params[:guid])

    message = SecurityGroupApplyMessage.new(hashed_params[:body])
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 intermediate_domains has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def intermediate_domains
      return [] unless name && valid_format?

      name.split(DOMAIN_DELIMITER).reverse.inject([]) do |array, member|
        array.push(array.empty? ? member : "#{member}#{DOMAIN_DELIMITER}#{array.last}")
Severity: Minor
Found in lib/cloud_controller/domain_decorator.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 parse_docker_uri has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.parse_docker_uri(docker_uri)
    name_parts = docker_uri.split('/', 2)

    host = name_parts[0]
    path = name_parts[1]
Severity: Minor
Found in lib/utils/uri_utils.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(db, max_migration_duration_in_minutes=nil, max_migration_statement_runtime_in_seconds=nil, migration_psql_worker_memory_kb=nil)
    @db = db
    @timeout_in_minutes = default_two_weeks(max_migration_duration_in_minutes)

    @max_statement_runtime_in_milliseconds = if max_migration_statement_runtime_in_seconds.nil? || max_migration_statement_runtime_in_seconds <= 0
Severity: Minor
Found in lib/cloud_controller/db_migrator.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 complete_task has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def complete_task(task, payload)
        begin
          response_parser.validate(payload)
        rescue Membrane::SchemaValidationError => e
          logger.error('failure.invalid-message', task_guid: task.guid, payload: payload, error: e.to_s)
Severity: Minor
Found in lib/cloud_controller/diego/task_completion_handler.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 routing_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def routing_info
          process_eager = ProcessModel.eager(route_mappings: { route: %i[domain route_binding] }).where(id: process.id).all

          return {} if process_eager.empty?

Severity: Minor
Found in lib/cloud_controller/diego/protocol/routing_info.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 filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def filter(message, dataset)
        dataset = dataset.where(name: message.names) if message.requested?(:names)

        if message.requested?(:default)
          condition = { name: Stack.default.name }.then do |c|
Severity: Minor
Found in app/fetchers/stack_list_fetcher.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 router_groups has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def router_groups
      raise RoutingApiUnavailable if @routing_api_uri.nil?

      client = HTTPClient.new
      client.ssl_config.set_default_paths
Severity: Minor
Found in lib/cloud_controller/routing_api/routing_api_client.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 image_layers has a Cognitive Complexity of 7 (exceeds 5 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 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