cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

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

    def key_error
      return MetadataError.error('key cannot be empty string') unless valid_key_presence?(key)
      return MetadataError.error("key has more than one '/'") unless valid_key_format?
      return MetadataError.error("prefix '#{prefix}' must be in valid dns format") unless valid_prefix_format?
      return MetadataError.error("prefix '#{prefix[0...8]}...' is greater than #{MAX_METADATA_PREFIX_SIZE} characters") unless valid_prefix_size?
Severity: Minor
Found in app/messages/metadata_validator_helper.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 create_job has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def create_job(job_class)
      params = job_class.instance_method(:initialize).parameters
      args = []
      kwargs = {}
      block = nil
Severity: Minor
Found in spec/support/shared_examples/jobs/delayed_job.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 quotas_apps_message_spec.rb has 267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'spec_helper'

module VCAP::CloudController
  RSpec.describe QuotasAppsMessage do
    subject { QuotasAppsMessage.new(params) }
Severity: Minor
Found in spec/unit/messages/quotas_apps_message_spec.rb - About 2 hrs to fix

    File base_message_spec.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      File cors_spec.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'spec_helper'
      require 'cors'
      
      module CloudFoundry
        module Middleware
      Severity: Minor
      Found in spec/unit/middleware/cors_spec.rb - About 2 hrs to fix

        File buildpack_bits_controller_spec.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'spec_helper'
        
        ## NOTICE: Prefer request specs over controller specs as per ADR #0003 ##
        
        module VCAP::CloudController
        Severity: Minor
        Found in spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb - About 2 hrs to fix

          File v3_error_hasher_spec.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'lightweight_spec_helper'
          require 'presenters/v3_error_hasher'
          require 'cloud_controller/errors/api_error'
          require 'cloud_controller/errors/not_authenticated'
          require 'cloud_controller/errors/compound_error'
          Severity: Minor
          Found in spec/unit/presenters/v3/v3_error_hasher_spec.rb - About 2 hrs to fix

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

                  def update(resource, labels, label_klass, destroy_nil: true)
                    starting_label_count_for_resource = label_klass.where(resource_guid: resource.guid).count
            
                    labels ||= {}
                    labels.each do |label_key, label_value|
            Severity: Minor
            Found in app/actions/labels_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 create has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def create(app, service_instance, message, volume_mount_services_enabled, accepts_incomplete)
                  raise ServiceInstanceNotBindable unless service_instance.bindable?
                  raise VolumeMountServiceDisabled if service_instance.volume_service? && !volume_mount_services_enabled
                  raise SpaceMismatch unless bindable_in_space?(service_instance, app.space)
            
            
            Severity: Minor
            Found in app/actions/v2/services/service_binding_create.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 filter_manifest_app_hash has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def filter_manifest_app_hash(manifest_app_hash)
                    if manifest_app_hash.key? 'sidecars'
                      manifest_app_hash['sidecars'] = manifest_app_hash['sidecars'].map do |hash|
                        hash.slice(
                          'name',
            Severity: Major
            Found in app/actions/space_diff_manifest.rb - About 2 hrs to fix

              Method tables_for_model_controller_spec has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def tables_for_model_controller_spec
                  db.create_table :test_models do
                    primary_key :id
                    String :guid
                    String :unique_value
              Severity: Major
              Found in spec/support/bootstrap/fake_model_tables.rb - About 2 hrs to fix

                File schema_spec.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require 'lightweight_spec_helper'
                require 'services/service_brokers/v2/schema'
                
                module VCAP::Services::ServiceBrokers::V2
                  RSpec.describe Schema do
                Severity: Minor
                Found in spec/unit/lib/services/service_brokers/v2/schema_spec.rb - About 2 hrs to fix

                  File routes.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  Rails.application.routes.draw do
                    get '/', to: 'root#v3_root'
                  
                    # admin actions
                    post '/admin/actions/clear_buildpack_cache', to: 'admin_actions#clear_buildpack_cache'
                  Severity: Minor
                  Found in config/routes.rb - About 2 hrs to fix

                    Class CatalogService has 21 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                      class CatalogService
                        include CatalogValidationHelper
                    
                        SUPPORTED_REQUIRES_VALUES = %w[syslog_drain route_forwarding volume_mount].freeze
                    
                    
                    Severity: Minor
                    Found in lib/services/service_brokers/v2/catalog_service.rb - About 2 hrs to fix

                      Method filter has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def filter(message, dataset)
                              dataset = dataset.where(name: message.names) if message.requested?(:names)
                      
                              dataset = dataset.where(space_guid: message.space_guids) if message.requested?(:space_guids)
                      
                      
                      Severity: Major
                      Found in app/fetchers/app_list_fetcher.rb - About 2 hrs to fix

                        Method build has 53 lines of code (exceeds 25 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: Major
                        Found in lib/cloud_controller/rack_app_builder.rb - About 2 hrs to fix

                          File resource_match_create_message_spec.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          require 'spec_helper'
                          require 'messages/resource_match_create_message'
                          
                          RSpec.describe VCAP::CloudController::ResourceMatchCreateMessage do
                            describe 'creation with v3' do
                          Severity: Minor
                          Found in spec/unit/messages/resource_match_create_message_spec.rb - About 2 hrs to fix

                            File stats_controller_spec.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            require 'spec_helper'
                            
                            ## NOTICE: Prefer request specs over controller specs as per ADR #0003 ##
                            
                            module VCAP::CloudController
                            Severity: Minor
                            Found in spec/unit/controllers/runtime/stats_controller_spec.rb - About 2 hrs to fix

                              File shared_domain_spec.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              require 'spec_helper'
                              
                              module VCAP::CloudController
                                RSpec.describe SharedDomain, type: :model do
                                  subject { SharedDomain.make name: 'test.example.com', router_group_guid: router_group_guid, router_group_type: 'tcp' }
                              Severity: Minor
                              Found in spec/unit/models/runtime/shared_domain_spec.rb - About 2 hrs to fix

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

                                      def perform
                                        return finish if binding.nil?
                                
                                        compute_maximum_duration
                                
                                
                                Severity: Minor
                                Found in app/jobs/v3/delete_binding_job.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