cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

Method create has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    message = ServiceBrokerCreateMessage.new(hashed_params[:body])
    unprocessable!(message.errors.full_messages) unless message.valid?

    if message.space_guid
Severity: Minor
Found in app/controllers/v3/service_brokers_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

Class Updater has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Updater
      attr_reader :deployment, :logger

      def initialize(deployment, logger)
        @deployment = deployment
Severity: Minor
Found in lib/cloud_controller/deployment_updater/updater.rb - About 2 hrs to fix

    File application_controller_spec.rb has 284 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'spec_helper'
    require 'rails_helper'
    
    ## NOTICE: Prefer request specs over controller specs as per ADR #0003 ##
    
    
    Severity: Minor
    Found in spec/unit/controllers/v3/application_controller_spec.rb - About 2 hrs to fix

      Method validate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate(record)
          unless record.rules.is_a?(Array)
            record.errors.add :rules, 'must be an array'
            return
          end
      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 destroy has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        def destroy
          service_broker = VCAP::CloudController::ServiceBroker.find(guid: hashed_params[:guid])
          broker_not_found! unless service_broker
      
          if service_broker.space.nil?
      Severity: Minor
      Found in app/controllers/v3/service_brokers_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 sync has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def sync
              logger.info('run-task-sync')
              @bump_freshness = true
      
              diego_tasks = bbs_task_client.fetch_tasks.index_by(&:task_guid)
      Severity: Minor
      Found in lib/cloud_controller/diego/tasks_sync.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 define_message has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def define_message(type)
              attrs   = Array(attributes)
              to_one  = @to_one_relationships ||= []
              to_many = @to_many_relationships ||= []
      
      
      Severity: Minor
      Found in lib/cloud_controller/rest_controller/messages.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 extract_table_of_contents has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        def extract_table_of_contents(html)
          page = Nokogiri::HTML(html)
      
          headings = []
          page.css('h1,h2,h3').each do |heading|
      Severity: Minor
      Found in docs/v3/helpers/docs_helpers.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

      Class DropletModel has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class DropletModel < Sequel::Model(:droplets)
          include Serializer
      
          DROPLET_STATES = [
            STAGING_STATE = 'STAGING'.freeze,
      Severity: Minor
      Found in app/models/runtime/droplet_model.rb - About 2 hrs to fix

        File buildpack_installer_factory_spec.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'spec_helper'
        
        module VCAP::CloudController
          module Jobs::Runtime
            RSpec.describe BuildpackInstallerFactory do
        Severity: Minor
        Found in spec/unit/jobs/runtime/buildpack_installer_factory_spec.rb - About 2 hrs to fix

          File app_create_message_spec.rb has 275 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'spec_helper'
          require 'messages/app_create_message'
          
          module VCAP::CloudController
            RSpec.describe AppCreateMessage do
          Severity: Minor
          Found in spec/unit/messages/app_create_message_spec.rb - About 2 hrs to fix

            Method scale has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                def scale
                  raise InvalidProcess.new('Cannot scale this process while a deployment is in flight.') if @process.web? && @process.app.deploying?
            
                  @process.db.transaction do
                    @process.app.lock!
            Severity: Minor
            Found in app/actions/process_scale.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 valid? has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

              def valid?
                attributes.each do |attribute_name, details|
                  field = fields[attribute_name]
                  if field
                    @attributes_with_bad_default << [attribute_name, details[:default], field.default] unless details[:default] == field.default
            Severity: Minor
            Found in spec/support/matchers/have_attributes.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 list_message_spec.rb has 273 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'spec_helper'
            require 'messages/list_message'
            
            class VCAP::CloudController::ListMessage
              register_allowed_keys []
            Severity: Minor
            Found in spec/unit/messages/list_message_spec.rb - About 2 hrs to fix

              File staging_action_builder_spec.rb has 273 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'spec_helper'
              require 'cloud_controller/diego/cnb/staging_action_builder'
              
              module VCAP::CloudController
                module Diego

                File service_binding_create_message_spec.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require 'spec_helper'
                require 'messages/service_binding_create_message'
                
                module VCAP::CloudController
                  RSpec.describe ServiceBindingCreateMessage do
                Severity: Minor
                Found in spec/unit/messages/service_binding_create_message_spec.rb - About 2 hrs to fix

                  File organization.rb has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'models/helpers/process_types'
                  
                  module VCAP::CloudController
                    class Organization < Sequel::Model
                      ORG_NAME_REGEX = /\A[[:alnum:][:punct:][:print:]]+\Z/
                  Severity: Minor
                  Found in app/models/runtime/organization.rb - About 2 hrs to fix

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

                        def update(service_instance, message)
                          logger = Steno.logger('cc.action.user_provided_service_instance_update')
                    
                          updates = {}
                          updates[:name] = message.name if message.requested?(:name)
                    Severity: Minor
                    Found in app/actions/service_instance_update_user_provided.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 perform has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def perform
                              logger = Steno.logger('cc-background')
                    
                              service_binding = ServiceBinding.first(guid: service_binding_guid)
                              return if service_binding.nil? # assume the binding has been purged
                    Severity: Minor
                    Found in app/jobs/v2/services/service_binding_state_fetch.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_contents has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def validate_destination_contents
                          app_to_ports_hash = {}
                    
                          destinations.each_with_index do |dst, index|
                            unless dst.is_a?(Hash)
                    Severity: Minor
                    Found in app/messages/route_update_destinations_message.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

                    Severity
                    Category
                    Status
                    Source
                    Language