cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

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

    def decode_token(auth_token)
      return unless token_format_valid?(auth_token)

      if symmetric_key
        decode_token_with_symmetric_key(auth_token)
Severity: Minor
Found in lib/cloud_controller/uaa/uaa_token_decoder.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 = :"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 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def fetch(klass, message, omniscient: false, readable_orgs_query: nil, readable_spaces_query: nil, eager_loaded_associations: [])
        # The base dataset for the given model; other tables might be joined later on for filtering,
        # but we are only interested in the columns from the base table.
        dataset = klass.dataset.select_all(klass.table_name)

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

    def validate_process(process)
      raise CloudController::Errors::ApiError.new_from_details('DockerDisabled') if process.docker? && FeatureFlag.disabled?(:diego_docker)

      raise CloudController::Errors::ApiError.new_from_details('AppPackageInvalid', 'The app package hash is empty') if process.package_hash.blank?

Severity: Minor
Found in lib/cloud_controller/backends/stagers.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(type: message.types) if message.requested?(:types)

        if message.requested?(:target_guids)
          dataset = if message.exclude_target_guids?
Severity: Minor
Found in app/fetchers/event_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 filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def filter(message, dataset, klass)
        dataset = dataset.where { Sequel[:service_plans][:active] =~ message.available? } if message.requested?(:available)

        dataset = dataset.where { Sequel[:service_plans][:name] =~ message.names } if message.requested?(:names)

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

    def format(validation_errors)
      message = "\n"
      validation_errors.messages.each { |e| message += "#{e}\n" }
      validation_errors.nested_errors.each do |service, service_errors|
        next if service_errors.empty?
Severity: Minor
Found in lib/services/service_brokers/validation_errors_formatter.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 String has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def String(name, opts={})
    if opts[:case_insensitive]
      raise Error.new('DB adapter does not support case insensitive strings') unless @db.respond_to?(:case_insensitive_string_column_type)

      column(
Severity: Minor
Found in lib/vcap/sequel_case_insensitive_string_monkeypatch.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!
      validate_string!(:broker_provided_id, broker_provided_id, required: true)
      validate_string!(:name, name, required: true)
      validate_description!(:description, description, required: true)
      validate_hash!(:metadata, metadata) if metadata
Severity: Minor
Found in lib/services/service_brokers/v2/catalog_plan.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 with_request_error_handling has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def with_request_error_handling(_source_guid)
      tries ||= 3
      yield
    rescue StandardError => e
      raise CloudController::Errors::ApiError.new_from_details('ServiceUnavailable', 'Connection to Log Cache timed out') if e.is_a?(GRPC::DeadlineExceeded)
Severity: Minor
Found in lib/logcache/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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    starts.each_with_index do |block, index|
      thread = Thread.start do
        sleep 0.01
        block.call
Severity: Minor
Found in spec/support/stepper.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 on_send has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def on_send(node)
        return unless node.send_type?

        if node.children[1] == :require
          @requires << node.child_nodes[0].children[0]
Severity: Minor
Found in spec/linters/match_requires_with_includes.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 instrument has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def instrument(target, method_name, before: nil, after: nil, &block)
    example.allow(target).
      to example.receive(method_name).and_wrap_original do |original_method, *args, **kwargs, &method_block|
      result = nil
      if before
Severity: Minor
Found in spec/support/stepper.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 step has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def step(message, &block)
    full_message = "[#{Thread.current.name}] #{message}"
    puts("expecting #{full_message}") if debug

    retries = 0
Severity: Minor
Found in spec/support/stepper.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

Avoid too many return statements within this function.
Open

    if (pivotElem === elem) return pivot
Severity: Major
Found in docs/v3/source/javascripts/lib/_lunr.js - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return if verify_ports
    Severity: Major
    Found in app/models/runtime/constraints/ports_policy.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return MetadataError.error('key cannot be empty string') unless valid_key_presence?(name)
      Severity: Major
      Found in app/messages/metadata_validator_helper.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return false unless has_valid_optional_binding_name(service)
        Severity: Major
        Found in app/messages/manifest_service_binding_create_message.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return MetadataError.error("prefix 'cloudfoundry.org' is reserved") unless is_not_reserved
          Severity: Major
          Found in app/messages/metadata_validator_helper.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return MetadataError.error("'#{name[0...8]}...' is greater than #{MetadataValidatorHelper::MAX_METADATA_KEY_SIZE} characters") unless valid_size?(name)
            Severity: Major
            Found in app/messages/metadata_validator_helper.rb - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language