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?
- Read upRead up
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
- Read upRead up
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) }
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
File cors_spec.rb
has 263 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'spec_helper'
require 'cors'
module CloudFoundry
module Middleware
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
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'
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|
- Read upRead up
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)
- Read upRead up
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',
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
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
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'
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
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)
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)
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
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
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' }
Method perform
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def perform
return finish if binding.nil?
compute_maximum_duration
- Read upRead up
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"