cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

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

      def buildpack_entries(buildpack_infos, stack_name)
        return default_admin_buildpacks(stack_name) if buildpack_infos.empty?

        buildpack_infos.map do |buildpack_info|
          if buildpack_info.buildpack_exists_in_db? && buildpack_info.buildpack_enabled?
Severity: Minor
Found in lib/cloud_controller/diego/buildpack_entry_generator.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 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 updated has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def updated(process)
        changes = process.previous_changes
        return unless changes

        with_diego_communication_handling do
Severity: Minor
Found in lib/cloud_controller/process_observer.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

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

      def filter(message, dataset)
        dataset = dataset.where(table_column_name(PackageModel, :state) => message.states) if message.requested? :states

        dataset = dataset.where(table_column_name(PackageModel, :type) => message.types) if message.requested? :types

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

        def save_staging_result(payload)
          lifecycle_data = payload[:result][:lifecycle_metadata]
          buildpack_key  = nil
          buildpack_url  = nil

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

    def convert_to_mb(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_megabytes(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

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

      def scoped_space_guids(permitted_space_guids:, filtered_space_guids:)
        return nil unless permitted_space_guids || filtered_space_guids
        return filtered_space_guids & permitted_space_guids if filtered_space_guids && permitted_space_guids
        return permitted_space_guids if permitted_space_guids

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

            def run_delayed_job
              Delayed::Worker.new.work_off if Delayed::Job.last
            end
Severity: Minor
Found in spec/unit/controllers/base/model_controller_spec.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 make_preflight_request_with_origin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def make_preflight_request_with_origin(origin, method=nil, extra_headers={})
          headers = {}
          headers = headers.merge({ 'Origin' => origin })
          headers = headers.merge({ 'Access-Control-Request-Method' => method }) unless method.nil?
          headers = headers.merge(extra_headers)
Severity: Minor
Found in spec/integration/cors_spec.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def parse
      Query.uuid ||= SecureRandom.uuid
      segments = []

      query.each do |q|
Severity: Minor
Found in lib/vcap/rest_api/query.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 compatible? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def compatible?
      services.each do |service|
        if service.route_service? && route_services_disabled?
          incompatibility_errors.add("Service #{service.name} is declared to be a route service but support for route services is disabled.")
        end
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 query_filter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def query_filter(key, comparison, val)
      foreign_key_association = foreign_key_association(key)
      values = comparison == ' IN ' ? val.split(',') : [val]

      return clean_up_foreign_key(key, values, foreign_key_association) if foreign_key_association
Severity: Minor
Found in lib/vcap/rest_api/query.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 env_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def env_for(uri, env)
        params = env[:params]
        new_env = orig_env_for(uri, env)

        if %w[GET DELETE].include?(env[:method])
Severity: Minor
Found in spec/support/rack_test_monkey_patch.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