cloudfoundry/cloud_controller_ng

View on GitHub

Showing 558 of 2,662 total issues

Method parse_maintenance_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_maintenance_info(maintenance_info)
      return {} unless maintenance_info
      return maintenance_info if maintenance_info.is_a?(Hash)

      Oj.load(maintenance_info)
Severity: Minor
Found in app/presenters/mixins/services_presentation_helpers.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_process!(process)
      raise CloudController::Errors::ApiError.new_from_details('AppNotFound', process.guid) unless process.web?

      raise CloudController::Errors::ApiError.new_from_details('StagingError', 'App must have at least 1 instance to stage.') if process.instances < 1

Severity: Minor
Found in app/controllers/runtime/restages_controller.rb - About 25 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 message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def message
        return unless args && details

        formatted_args = args.map do |arg|
          (arg.is_a? Array) ? arg.map(&:to_s).join(', ') : arg.to_s
Severity: Minor
Found in lib/cloud_controller/errors/api_error.rb - About 25 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 http_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def http_info(process_eager)
          route_mappings = process_eager[0].route_mappings.reject do |route_mapping|
            route_mapping.route.internal? || route_mapping.route.tcp?
          end

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

      def self.provide(ca_cert_path: nil, connect_timeout: nil, receive_timeout: nil)
        client = HTTPClient.new
        client.connect_timeout = connect_timeout if connect_timeout
        client.receive_timeout = receive_timeout if receive_timeout
        client.ssl_config.verify_mode = VCAP::CloudController::Config.config.get(:skip_cert_verify) ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER
Severity: Minor
Found in lib/cloud_controller/blobstore/webdav/http_client_provider.rb - About 25 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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(params, query_string=nil)
      @logger.debug "parse_params: #{params} #{query_string}"
      # Sinatra squashes duplicate query parms into a single entry rather
      # than an array (which we might have for q)
      res = {}
Severity: Minor
Found in lib/cloud_controller/rest_controller/common_params.rb - About 25 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_uaa_changeset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def create_uaa_changeset(requested_clients, existing_uaa_clients)
      requested_ids = requested_clients.map { |client| client.fetch('id') }

      create_and_update_commands = requested_clients.map do |requested_client|
        existing_uaa_client = existing_uaa_clients.detect { |client| client == requested_client.fetch('id') }
Severity: Minor
Found in lib/services/sso/dashboard_client_differ.rb - About 25 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 fill_unreported_instances_with_down_instances has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def fill_unreported_instances_with_down_instances(reported_instances, process, flat:)
        process.instances.times do |i|
          next if reported_instances[i]

          down_instance = { state: VCAP::CloudController::Diego::LRP_DOWN }
Severity: Minor
Found in lib/cloud_controller/diego/reporters/reporter_mixins.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.validate(rule)
      errs = super
      return errs unless errs.empty?

      icmp_type = rule['type']
Severity: Minor
Found in lib/cloud_controller/icmp_rule_validator.rb - About 25 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 uploaded_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def uploaded_file(params, resource_name)
    raise MissingFilePathError.new('File field missing path information') if HashUtils.dig(params, VCAP::CloudController::Constants::INVALID_NGINX_UPLOAD_PARAM)

    file_path = nginx_uploaded_file(params, resource_name) || rack_temporary_file(params, resource_name)
    return unless file_path
Severity: Minor
Found in lib/cloud_controller/upload_handler.rb - About 25 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 taken_names has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def taken_names(new_services_names)
      clashing_names = []
      clashing_services = service_broker.services_dataset.where(label: new_services_names)
      clashing_services.each do |old_service|
        new_service = services.detect { |ns| ns.name == old_service.name }
Severity: Minor
Found in lib/services/service_brokers/v2/catalog.rb - About 25 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 num_cores has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def num_cores
      if RUBY_PLATFORM.match?(/linux/)
        `cat /proc/cpuinfo | grep processor | wc -l`.to_i
      elsif RUBY_PLATFORM.match?(/darwin/)
        `sysctl -n hw.ncpu`.strip.to_i
Severity: Minor
Found in lib/vcap/host_system.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(uaa_config, grace_period_in_seconds: 0, alternate_reference_time: nil)
      @config = uaa_config
      @logger = Steno.logger('cc.uaa_token_decoder')

      raise ArgumentError.new('grace period should be an integer') unless grace_period_in_seconds.is_a? Integer
Severity: Minor
Found in lib/cloud_controller/uaa/uaa_token_decoder.rb - About 25 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 registered has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.registered(app)
      app.helpers VCAP::Helpers

      app.not_found do
        # sinatra wants to drive us through the not_found block for *every*
Severity: Minor
Found in lib/sinatra/vcap.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

      def filter(message, dataset)
        if message.requested?(:after_guid)
          last_event = dataset.first(guid: message.after_guid[0])
          invalid_after_guid! unless last_event

Severity: Minor
Found in app/fetchers/service_usage_event_list_fetcher.rb - About 25 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 human_readable_byte_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def human_readable_byte_value(bytes)
      return nil if bytes.blank?

      raise InvalidBytesError unless bytes.is_a?(Integer)

Severity: Minor
Found in lib/cloud_controller/app_manifest/byte_converter.rb - About 25 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 6 (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 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    def with_request_error_handling
      tries ||= 3
      yield
    rescue StandardError
      retry unless (tries -= 1).zero?
Severity: Minor
Found in lib/cloud_controller/uaa/uaa_token_decoder.rb - About 25 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 cached_dependencies has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def cached_dependencies
          return nil if @config.get(:diego, :enable_declarative_asset_downloads)

          dependencies = [
            ::Diego::Bbs::Models::CachedDependency.new(
Severity: Minor
Found in lib/cloud_controller/diego/buildpack/staging_action_builder.rb - About 25 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 convert_to_b has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def convert_to_b(human_readable_byte_value)
      return nil if human_readable_byte_value.blank?
      raise NonNumericError unless human_readable_byte_value.to_s.match?(/\A-?\d+(?:\.\d+)?/)

      PalmCivet.to_bytes(human_readable_byte_value.to_s)
Severity: Minor
Found in lib/cloud_controller/app_manifest/byte_converter.rb - About 25 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