cloudfoundry/cloud_controller_ng

View on GitHub

Showing 569 of 2,678 total issues

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 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

      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 organization.rb has 262 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

          File base_message_spec.rb has 261 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

            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

                  Class DropletModel has 21 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

                    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 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 routes.rb has 255 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

                            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

                                Method filter_manifest_app_hash has a Cognitive Complexity of 16 (exceeds 5 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: Minor
                                Found in app/actions/space_diff_manifest.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 enabled? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def self.enabled?(feature_flag_name, raise_unless_enabled: false)
                                      return true if ADMIN_SKIPPABLE.include?(feature_flag_name) && admin?
                                      return true if ADMIN_READ_ONLY_SKIPPABLE.include?(feature_flag_name) && admin_read_only?
                                
                                      feature_flag = FeatureFlag.find(name: feature_flag_name.to_s)
                                Severity: Minor
                                Found in app/models/runtime/feature_flag.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