File ci_processing.rb
has 775 lines of code (exceeds 400 allowed). Consider refactoring. Open
module ApplicationController::CiProcessing
extend ActiveSupport::Concern
included do
include Mixins::Actions::VmActions::Ownership
- Create a ticketCreate a ticket
Cyclomatic complexity for process_vm_buttons is too high. [39/11] Open
def process_vm_buttons(pfx)
case params[:pressed]
when "#{pfx}_policy_sim" then polsimvms
when "#{pfx}_compare" then comparemiq
when "#{pfx}_scan" then scanvms
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.
def each_child_node(*types) # count begins: 1
unless block_given? # unless: +1
return to_enum(__method__, *types)
children.each do |child| # each{}: +1
next unless child.is_a?(Node) # unless: +1
yield child if types.empty? || # if: +1, ||: +1
types.include?(child.type)
end
self
end # total: 6
Method edit_record
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def edit_record
assert_privileges(params[:pressed])
obj = find_checked_items
db = params[:db] if params[:db]
- Read upRead up
- Create a ticketCreate a ticket
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 process_elements
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def process_elements(elements, klass, task, display_name = nil, order_field = nil)
order_field ||= %w[name description title].find { |field| klass.column_names.include?(field) }
order_by = order_field == "ems_id" ? order_field : klass.arel_table[order_field].lower
- Read upRead up
- Create a ticketCreate a ticket
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 process_objects
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def process_objects(objs, task, display_name = nil)
klass = record_class
klass_str = klass.to_s
assert_rbac(klass, objs)
- Read upRead up
- Create a ticketCreate a ticket
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 process_show_list
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def process_show_list(options = {})
session["#{self.class.session_key_prefix}_display".to_sym] = nil
@display = nil
@lastaction = "show_list"
@gtl_url = "/show_list"
- Read upRead up
- Create a ticketCreate a ticket
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
Cyclomatic complexity for edit_record is too high. [16/11] Open
def edit_record
assert_privileges(params[:pressed])
obj = find_checked_items
db = params[:db] if params[:db]
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.
def each_child_node(*types) # count begins: 1
unless block_given? # unless: +1
return to_enum(__method__, *types)
children.each do |child| # each{}: +1
next unless child.is_a?(Node) # unless: +1
yield child if types.empty? || # if: +1, ||: +1
types.include?(child.type)
end
self
end # total: 6
Method process_storage
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def process_storage(storages, task, _ = nil)
storages, _storages_out_region = filter_ids_in_region(storages, _("Datastore"))
return if storages.empty?
if task == "destroy"
- Read upRead up
- Create a ticketCreate a ticket
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
Cyclomatic complexity for process_show_list is too high. [13/11] Open
def process_show_list(options = {})
session["#{self.class.session_key_prefix}_display".to_sym] = nil
@display = nil
@lastaction = "show_list"
@gtl_url = "/show_list"
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.
def each_child_node(*types) # count begins: 1
unless block_given? # unless: +1
return to_enum(__method__, *types)
children.each do |child| # each{}: +1
next unless child.is_a?(Node) # unless: +1
yield child if types.empty? || # if: +1, ||: +1
types.include?(child.type)
end
self
end # total: 6
Method delete_elements
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def delete_elements(model_class, destroy_method, model_name = nil)
model_name ||= model_class.table_name
elements = find_records_with_rbac(model_class, checked_or_params)
send(destroy_method, elements.ids, 'destroy')
if params[:miq_grid_checks].present? || @lastaction == "show_list" || (@lastaction == "show" && @layout != model_name.singularize) # showing a list
- Read upRead up
- Create a ticketCreate a ticket
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 process_vm_buttons
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_vm_buttons(pfx)
case params[:pressed]
when "#{pfx}_policy_sim" then polsimvms
when "#{pfx}_compare" then comparemiq
when "#{pfx}_scan" then scanvms
- Create a ticketCreate a ticket
Method deletestorages
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def deletestorages
assert_privileges("storage_delete")
storages = find_records_with_rbac(Storage, checked_or_params)
unless records_support_feature?(storages, 'delete')
add_flash(_("Only storage without VMs and Hosts can be removed"), :error)
- Read upRead up
- Create a ticketCreate a ticket
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 process_storage
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_storage(storages, task, _ = nil)
storages, _storages_out_region = filter_ids_in_region(storages, _("Datastore"))
return if storages.empty?
if task == "destroy"
- Create a ticketCreate a ticket
Method process_objects
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_objects(objs, task, display_name = nil)
klass = record_class
klass_str = klass.to_s
assert_rbac(klass, objs)
- Create a ticketCreate a ticket
Method process_elements
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_elements(elements, klass, task, display_name = nil, order_field = nil)
order_field ||= %w[name description title].find { |field| klass.column_names.include?(field) }
order_by = order_field == "ems_id" ? order_field : klass.arel_table[order_field].lower
- Create a ticketCreate a ticket
Method process_resourcepools
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process_resourcepools(rps, task)
rps, _rps_out_region = filter_ids_in_region(rps, "Resource Pool")
return if rps.empty?
if task == "destroy"
- Read upRead up
- Create a ticketCreate a ticket
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 process_clusters
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process_clusters(clusters, task, _ = nil)
clusters, _clusters_out_region = filter_ids_in_region(clusters, _("Cluster"))
return if clusters.empty?
if task == "destroy"
- Read upRead up
- Create a ticketCreate a ticket
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 edit_record
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def edit_record
assert_privileges(params[:pressed])
obj = find_checked_items
db = params[:db] if params[:db]
- Create a ticketCreate a ticket
Method process_managers
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process_managers(managers, task)
controller_class = request.parameters[:controller]
provider_class = case controller_class
when 'ems_automation' then ManageIQ::Providers::AutomationManager
when 'ems_configuration' then ManageIQ::Providers::ConfigurationManager
- Read upRead up
- Create a ticketCreate a ticket
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 process_elements
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_elements(elements, klass, task, display_name = nil, order_field = nil)
- Create a ticketCreate a ticket
Method cloud_object_store_button_operation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def cloud_object_store_button_operation(klass, task)
display_name = _(task.capitalize)
method = "#{klass.name.underscore.to_sym}_#{task}"
task = method unless task == 'delete'
items = find_records_with_rbac(klass, checked_or_params)
- Read upRead up
- Create a ticketCreate a ticket
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 screen_redirection
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def screen_redirection(options)
if options[:redirect].present?
javascript_redirect(:controller => options[:redirect][:controller],
:action => options[:redirect][:action])
return
- Read upRead up
- Create a ticketCreate a ticket
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 get_record
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_record(db)
if db == "host"
@host = @record = identify_record(params[:id], Host)
elsif db == "miq_template"
@miq_template = @record = identify_record(params[:id], MiqTemplate)
- Read upRead up
- Create a ticketCreate a ticket
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 process_element_destroy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def process_element_destroy(element, klass, name)
return unless element.respond_to?(:destroy)
audit = {:event => "#{klass.name.downcase}_record_delete",
:message => "[#{name}] Record deleted",
- Read upRead up
- Create a ticketCreate a ticket
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"