cloudfoundry/cloud_controller_ng

View on GitHub

Showing 569 of 2,678 total issues

Method update has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def update(package, message)
      package.db.transaction do
        if package.type == PackageModel::DOCKER_TYPE && (message.username || message.password)
          package.docker_username = message.username unless message.username.nil?
          package.docker_password = message.password unless message.password.nil?
Severity: Minor
Found in app/actions/package_update.rb - About 2 hrs 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 update has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def update(buildpack, message)
      Buildpack.db.transaction do
        Locking[name: 'buildpacks'].lock!

        MetadataUpdate.update(buildpack, message)
Severity: Minor
Found in app/actions/buildpack_update.rb - About 2 hrs 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 update has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    sidecar = SidecarModel.find(guid: params[:guid])

    resource_not_found!(:sidecar) unless sidecar
    space = sidecar.app.space
Severity: Minor
Found in app/controllers/v3/sidecars_controller.rb - About 2 hrs 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 delete_staging_spaces has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def delete_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])

    space = Space.find(guid: hashed_params[:space_guid])
Severity: Minor
Found in app/controllers/v3/security_groups_controller.rb - About 2 hrs 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_destination has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_destination(destination, record, index)
    error_message = 'destination must be a valid CIDR, IP address, or IP address range'
    error_message = 'destination must contain valid CIDR(s), IP address(es), or IP address range(s)' if CloudController::RuleValidator.comma_delimited_destinations_enabled?
    add_rule_error('empty destination specified in comma-delimited list', record, index) if destination.empty?

Severity: Minor
Found in app/messages/validators/security_group_rule_validator.rb - About 2 hrs 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 delete_running_spaces has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def delete_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])

    space = Space.find(guid: hashed_params[:space_guid])
Severity: Minor
Found in app/controllers/v3/security_groups_controller.rb - About 2 hrs 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 serialize_relationships has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

        def serialize_relationships(relationships, controller, depth, obj, opts, parents, orphans)
          response = {}
          (relationships || {}).each do |relationship_name, association|
            associated_model = get_associated_model_class_for(obj, association.association_name)
            next unless associated_model
Severity: Minor
Found in app/presenters/v2/relations_presenter.rb - About 2 hrs 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 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def build(config, request_metrics, request_logs)
      token_decoder = VCAP::CloudController::UaaTokenDecoder.new(config.get(:uaa))
      configurer = VCAP::CloudController::Security::SecurityContextConfigurer.new(token_decoder)

      logger = access_log(config)
Severity: Minor
Found in lib/cloud_controller/rack_app_builder.rb - About 2 hrs 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_port has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def self.validate_port(port)
      return false if /[^\d\s\-,]/.match?(port)

      port_range = /\A\s*(\d+)\s*-\s*(\d+)\s*\z/.match(port)
      if port_range
Severity: Minor
Found in lib/cloud_controller/transport_rule_validator.rb - About 2 hrs 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_destination has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def self.validate_destination(destination)
      unless destination.index(',').nil?
        return false unless comma_delimited_destinations_enabled?

        destinations = destination.partition(',')
Severity: Minor
Found in lib/cloud_controller/rule_validator.rb - About 2 hrs 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_eager_load_hash has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def build_eager_load_hash(controller_class, model_class, default_visibility_filter, additional_visibility_filters, depth)
      associated_controller = controller_class

      # model_class cannot just be inferred from controller_class.model
      # because ServiceInstancesController can be used to present objects
Severity: Minor
Found in lib/cloud_controller/rest_controller/secure_eager_loader.rb - About 2 hrs 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

File task_action_builder_spec.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'spec_helper'

module VCAP::CloudController
  module Diego
    module Buildpack

    Method read has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def read
          api_url_builder = VCAP::CloudController::Presenters::ApiUrlBuilder
    
          response = {
            links: {
    Severity: Major
    Found in app/controllers/runtime/root_controller.rb - About 2 hrs to fix

      Method create has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def create(app:, user_audit_info:, message:)
              deployment = nil
      
              DeploymentModel.db.transaction do
                app.lock!
      Severity: Minor
      Found in app/actions/deployment_create.rb - About 1 hr to fix

        Method clone_existing_web_process has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def clone_existing_web_process(app, revision)
                web_process = app.newest_web_process
                command = if revision
                            revision.commands_by_process_type[ProcessTypes::WEB]
                          else
        Severity: Minor
        Found in app/actions/deployment_create.rb - About 1 hr to fix

          Method update has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def update(security_group, message)
                  security_group.db.transaction do
                    security_group.lock!
          
                    security_group.name = message.name if message.requested? :name
          Severity: Minor
          Found in app/actions/security_group_update.rb - About 1 hr 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 update has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def update(app_guid, message, user_audit_info)
                  return unless message.requested?(:routes)
          
                  app = AppModel.find(guid: app_guid)
                  not_found! unless app
          Severity: Minor
          Found in app/actions/manifest_route_update.rb - About 1 hr 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_similarity has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def create_similarity
                  lambda do |before, after|
                    return nil unless before.is_a?(Hash) && after.is_a?(Hash)
          
                    if before.key?('type') && after.key?('type')
          Severity: Minor
          Found in app/actions/space_diff_manifest.rb - About 1 hr 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 perform has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def perform
                  not_found! unless resource
          
                  cancelled! if delete_in_progress?
          
          
          Severity: Minor
          Found in app/jobs/v3/create_binding_async_job.rb - About 1 hr 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 15 (exceeds 5 allowed). Consider refactoring.
          Open

            def create
              message = BuildCreateMessage.new(Oj.load(request.body))
              unprocessable!(message.errors.full_messages) unless message.valid?
          
              package = PackageModel.where(guid: message.package_guid).
          Severity: Minor
          Found in app/controllers/v3/builds_controller.rb - About 1 hr 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