Showing 583 of 2,698 total issues
Method crashed_instances_for_app
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def crashed_instances_for_app(process)
crashed_instances = []
bbs_instances_client.lrp_instances(process).each do |actual_lrp|
next unless actual_lrp.state == ::Diego::ActualLRPState::CRASHED
next unless actual_lrp.actual_lrp_key.index < process.instances
- 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 run_cmd
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def run_cmd(cmd, opts={})
opts[:env] ||= {}
project_path = File.join(File.dirname(__FILE__), '../../..')
spawn_opts = { chdir: project_path }
- 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 to_hash
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def to_hash
app_name = @process.name
if @process.is_a?(VCAP::CloudController::AppModel)
uris = @process.routes.map(&:uri)
- 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 on_block
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def on_block(node)
node.each_descendant(:send) do |send_node|
method = method_name(send_node)
next unless constraint_adding_method?(method) || column_adding_method?(method)
- 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 stage
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def stage(process)
@stagers.validate_process(process)
message = BuildCreateMessage.new({
staging_memory_in_mb: process.memory,
Method create_and_stage
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_and_stage(package:, lifecycle:, metadata: nil, start_after_staging: false)
logger.info("creating build for package #{package.guid}")
staging_in_progress! if package.app.staging_in_progress?
raise InvalidPackage.new('Cannot stage package whose state is not ready.') if package.state != PackageModel::READY_STATE
Function _on
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
_on: function( suppressDisabledCheck, element, handlers ) {
var delegateElement,
instance = this;
// no suppressDisabledCheck flag, shuffle arguments
Method update
has 38 lines of code (exceeds 25 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
Method update
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update(process, message, strategy_class)
raise InvalidProcess.new('Cannot update this process while a deployment is in flight.') if process.web? && process.app.deploying?
strategy = strategy_class.new(message, process)
process.db.transaction do
Method sync
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sync
logger.info('run-process-sync')
@bump_freshness = true
diego_lrps = bbs_apps_client.fetch_scheduling_infos.index_by { |d| d.desired_lrp_key.process_guid }
logger.info('fetched-scheduling-infos')
Method fetch
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch(klass, message, omniscient: false, readable_orgs_query: nil, readable_spaces_query: nil, eager_loaded_associations: [])
# The base dataset for the given model; other tables might be joined later on for filtering,
# but we are only interested in the columns from the base table.
dataset = klass.dataset.select_all(klass.table_name)
Function search
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
lunr.Index.prototype.search = function (query) {
var queryTokens = this.pipeline.run(lunr.tokenizer(query)),
queryVector = new lunr.Vector,
documentSets = [],
fieldBoosts = this._fields.reduce(function (memo, f) { return memo + f.boost }, 0)
Method upload
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upload(guid)
process = find_guid_and_validate_access(:upload, guid)
raise CloudController::Errors::ApiError.new_from_details('UnprocessableEntity', 'cannot upload bits to a docker app') if process.docker?
Method to_hash
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_hash
{
guid: deployment.guid,
created_at: deployment.created_at,
updated_at: deployment.updated_at,
Method filter
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def filter(message, dataset)
dataset = dataset.where(host: message.hosts) if message.requested?(:hosts)
dataset = dataset.where(path: message.paths) if message.requested?(:paths)
Method can_be_decorated_with_include_binding_service_instance_decorator
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.can_be_decorated_with_include_binding_service_instance_decorator(klazz)
RSpec.describe IncludeBindingServiceInstanceDecorator do
subject(:decorator) { described_class }
let(:bindings) do
Function _setEventHandlers
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
_setEventHandlers: function() {
var self = this;
this.element.on("click.tocify", "a", function() {
self.element.find("." + self.focusClass).removeClass(self.focusClass);
Method install
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def install(buildpacks)
return unless buildpacks
CloudController::DependencyLocator.instance.buildpack_blobstore.ensure_bucket_exists
job_factory = VCAP::CloudController::Jobs::Runtime::BuildpackInstallerFactory.new
Method generate_default_org_quota_response
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_default_org_quota_response(global_read)
# our request specs are seeded with an org that uses the default org quota
# the visibility of this org depends on the user's permissions
seeded_org_guid = VCAP::CloudController::Organization.where(name: 'the-system_domain-org-name').first.guid
seeded_org = global_read ? [{ guid: seeded_org_guid }] : []
Method error
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def error(job, exception)
begin
api_error = convert_to_v3_api_error(exception)
save_error(api_error, job)
rescue Sequel::DatabaseError
- 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"