File catalog_controller.rb
has 2111 lines of code (exceeds 400 allowed). Consider refactoring. Open
class CatalogController < ApplicationController
include AutomateTreeHelper
include Mixins::ServiceDialogCreationMixin
include Mixins::BreadcrumbsMixin
include Mixins::AutomationMixin
- Create a ticketCreate a ticket
Method st_get_form_vars
has a Cognitive Complexity of 131 (exceeds 5 allowed). Consider refactoring. Open
def st_get_form_vars
get_form_vars
if params[:resource_id]
# adding new service resource, so need to lookup actual vm or service template record and set defaults
sr = ServiceTemplate.find(params[:resource_id])
- 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
Class CatalogController
has 131 methods (exceeds 20 allowed). Consider refactoring. Open
class CatalogController < ApplicationController
include AutomateTreeHelper
include Mixins::ServiceDialogCreationMixin
include Mixins::BreadcrumbsMixin
include Mixins::AutomationMixin
- Create a ticketCreate a ticket
Method replace_right_cell
has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring. Open
def replace_right_cell(options = {})
action, replace_trees, presenter = options.values_at(:action, :replace_trees, :presenter)
@explorer = true
# FIXME: make this functional
- 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 atomic_req_submit
has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring. Open
def atomic_req_submit
id = session[:edit][:req_id] || "new"
return unless load_edit("prov_edit__#{id}", "show_list")
if @edit[:new][:name].blank?
- 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 replace_right_cell is too high. [68/11] Open
def replace_right_cell(options = {})
action, replace_trees, presenter = options.values_at(:action, :replace_trees, :presenter)
@explorer = true
# FIXME: make this functional
- 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 atomic_form_field_changed
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def atomic_form_field_changed
assert_privileges(session&.fetch_path(:edit, :rec_id) ? "atomic_catalogitem_edit" : "atomic_catalogitem_new")
# need to check req_id in session since we are using common code for prov requests and atomic ST screens
id = session[:edit][:req_id] || "new"
- 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 atomic_req_submit is too high. [50/11] Open
def atomic_req_submit
id = session[:edit][:req_id] || "new"
return unless load_edit("prov_edit__#{id}", "show_list")
if @edit[:new][:name].blank?
- 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 st_edit
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def st_edit
assert_privileges(params[:id] ? 'catalogitem_edit' : 'catalogitem_new')
# reset the active tree back to :sandt_tree, it was changed temporairly to display automate entry point tree in a popup div
self.x_active_tree = 'sandt_tree'
- 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 replace_right_cell
has 120 lines of code (exceeds 25 allowed). Consider refactoring. Open
def replace_right_cell(options = {})
action, replace_trees, presenter = options.values_at(:action, :replace_trees, :presenter)
@explorer = true
# FIXME: make this functional
- Create a ticketCreate a ticket
Cyclomatic complexity for st_get_form_vars is too high. [36/11] Open
def st_get_form_vars
get_form_vars
if params[:resource_id]
# adding new service resource, so need to lookup actual vm or service template record and set defaults
sr = ServiceTemplate.find(params[:resource_id])
- 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 atomic_req_submit
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
def atomic_req_submit
id = session[:edit][:req_id] || "new"
return unless load_edit("prov_edit__#{id}", "show_list")
if @edit[:new][:name].blank?
- Create a ticketCreate a ticket
Cyclomatic complexity for atomic_form_field_changed is too high. [31/11] Open
def atomic_form_field_changed
assert_privileges(session&.fetch_path(:edit, :rec_id) ? "atomic_catalogitem_edit" : "atomic_catalogitem_new")
# need to check req_id in session since we are using common code for prov requests and atomic ST screens
id = session[:edit][:req_id] || "new"
- 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 atomic_st_edit
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def atomic_st_edit
assert_privileges(params[:id] ? 'atomic_catalogitem_edit' : 'atomic_catalogitem_new')
# reset the active tree back to :sandt_tree, it was changed temporairly to display automate entry point tree in a popup div
self.x_active_tree = 'sandt_tree'
- 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_node_info_handle_leaf_node
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def get_node_info_handle_leaf_node(id)
show_record(id)
if @record.atomic? && need_prov_dialogs?(@record.prov_type)
@miq_request = MiqRequest.find_by(:id => @record.service_resources[0].resource_id) if @record.service_resources[0]&.resource_id
if @miq_request
- 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 st_get_form_vars
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
def st_get_form_vars
get_form_vars
if params[:resource_id]
# adding new service resource, so need to lookup actual vm or service template record and set defaults
sr = ServiceTemplate.find(params[:resource_id])
- Create a ticketCreate a ticket
Method get_form_vars
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def get_form_vars
copy_params_if_present(@edit[:new], params, %i[st_prov_type name description provision_cost catalog_id dialog_id generic_subtype long_description zone_id price retire_fqname reconfigure_fqname fqname])
@edit[:new][:display] = params[:display] == "1" if params[:display] # @edit[:new][:display] should't be changed if params[:display] is not set
# saving it in @edit as well, to use it later because prov_set_form_vars resets @edit[:new]
- 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 atomic_form_field_changed
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
def atomic_form_field_changed
assert_privileges(session&.fetch_path(:edit, :rec_id) ? "atomic_catalogitem_edit" : "atomic_catalogitem_new")
# need to check req_id in session since we are using common code for prov requests and atomic ST screens
id = session[:edit][:req_id] || "new"
- Create a ticketCreate a ticket
Cyclomatic complexity for form_available_vars_ovf_template is too high. [22/11] Open
def form_available_vars_ovf_template
@edit[:available_ovf_templates] = ManageIQ::Providers::Vmware::InfraManager::OrchestrationTemplate.all
.collect { |m| [m.name, m.id] }
.sort
@edit[:disk_formats] = {
- 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 open_parent_nodes
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def open_parent_nodes(record)
existing_node = nil # Init var
if record.kind_of?(OrchestrationTemplate)
parents = [:id => template_to_node_name(record)]
- 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 fetch_playbook_details
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def fetch_playbook_details
playbook_details = {}
provision = @record.config_info[:provision]
playbook_details[:provisioning] = {}
playbook_details[:provisioning][:repository] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource, provision[:repository_id])
- 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 set_form_vars is too high. [19/11] Open
def set_form_vars
@edit[:new][:name] = @record.name
@edit[:new][:description] = @record.description
@edit[:new][:long_description] = @record.long_description
@edit[:new][:provision_cost] = @record.provision_cost
- 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
Cyclomatic complexity for get_form_vars is too high. [19/11] Open
def get_form_vars
copy_params_if_present(@edit[:new], params, %i[st_prov_type name description provision_cost catalog_id dialog_id generic_subtype long_description zone_id price retire_fqname reconfigure_fqname fqname])
@edit[:new][:display] = params[:display] == "1" if params[:display] # @edit[:new][:display] should't be changed if params[:display] is not set
# saving it in @edit as well, to use it later because prov_set_form_vars resets @edit[:new]
- 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 st_edit
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def st_edit
assert_privileges(params[:id] ? 'catalogitem_edit' : 'catalogitem_new')
# reset the active tree back to :sandt_tree, it was changed temporairly to display automate entry point tree in a popup div
self.x_active_tree = 'sandt_tree'
- Create a ticketCreate a ticket
Cyclomatic complexity for st_edit is too high. [18/11] Open
def st_edit
assert_privileges(params[:id] ? 'catalogitem_edit' : 'catalogitem_new')
# reset the active tree back to :sandt_tree, it was changed temporairly to display automate entry point tree in a popup div
self.x_active_tree = 'sandt_tree'
- 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
Cyclomatic complexity for get_node_info_handle_leaf_node is too high. [18/11] Open
def get_node_info_handle_leaf_node(id)
show_record(id)
if @record.atomic? && need_prov_dialogs?(@record.prov_type)
@miq_request = MiqRequest.find_by(:id => @record.service_resources[0].resource_id) if @record.service_resources[0]&.resource_id
if @miq_request
- 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 default_entry_point
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def default_entry_point(prov_type, service_type)
klass = class_service_template(prov_type)
ENTRY_POINT_TYPES.each do |key, _prefix|
fields = entry_point_fields(key)
type = fields[:type]
- 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 atomic_st_edit is too high. [17/11] Open
def atomic_st_edit
assert_privileges(params[:id] ? 'atomic_catalogitem_edit' : 'atomic_catalogitem_new')
# reset the active tree back to :sandt_tree, it was changed temporairly to display automate entry point tree in a popup div
self.x_active_tree = 'sandt_tree'
- 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 form_available_vars_ovf_template
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def form_available_vars_ovf_template
@edit[:available_ovf_templates] = ManageIQ::Providers::Vmware::InfraManager::OrchestrationTemplate.all
.collect { |m| [m.name, m.id] }
.sort
@edit[:disk_formats] = {
- Create a ticketCreate a ticket
Method set_record_vars_ovf_template
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def set_record_vars_ovf_template
options = {}
options[:name] = @edit[:new][:name]
options[:description] = @edit[:new][:description]
options[:long_description] = @edit[:new][:display] ? @edit[:new][:long_description] : nil
- 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 set_form_vars
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def set_form_vars
@edit[:new][:name] = @record.name
@edit[:new][:description] = @record.description
@edit[:new][:long_description] = @record.long_description
@edit[:new][:provision_cost] = @record.provision_cost
- 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 set_record_vars_ovf_template is too high. [16/11] Open
def set_record_vars_ovf_template
options = {}
options[:name] = @edit[:new][:name]
options[:description] = @edit[:new][:description]
options[:long_description] = @edit[:new][:display] ? @edit[:new][:long_description] : nil
- 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 set_form_vars
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_form_vars
@edit[:new][:name] = @record.name
@edit[:new][:description] = @record.description
@edit[:new][:long_description] = @record.long_description
@edit[:new][:provision_cost] = @record.provision_cost
- Create a ticketCreate a ticket
Cyclomatic complexity for st_set_form_vars is too high. [14/11] Open
def st_set_form_vars
@edit = {}
@edit[:rec_id] = @record.id
@edit[:key] = "st_edit__#{@record.id || "new"}"
@edit[:url] = "servicetemplate_edit"
- 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 form_available_vars_ovf_template
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def form_available_vars_ovf_template
@edit[:available_ovf_templates] = ManageIQ::Providers::Vmware::InfraManager::OrchestrationTemplate.all
.collect { |m| [m.name, m.id] }
.sort
@edit[:disk_formats] = {
- 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 st_set_record_vars
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def st_set_record_vars(st)
common_st_record_vars(st)
st.remove_all_resources
@add_rsc = true
unless @edit[:new][:selected_resources].empty?
- 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 x_edit_tags_reset
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def x_edit_tags_reset(db)
@tagging = session[:tag_db] = db
checked_ids = find_checked_items.empty? ? [params[:id]] : find_checked_items
@object_ids = find_records_with_rbac(db.safe_constantize, checked_ids).ids
if params[:button] == 'reset'
- 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 atomic_st_edit
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def atomic_st_edit
assert_privileges(params[:id] ? 'atomic_catalogitem_edit' : 'atomic_catalogitem_new')
# reset the active tree back to :sandt_tree, it was changed temporairly to display automate entry point tree in a popup div
self.x_active_tree = 'sandt_tree'
- Create a ticketCreate a ticket
Method get_node_info_handle_leaf_node
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_node_info_handle_leaf_node(id)
show_record(id)
if @record.atomic? && need_prov_dialogs?(@record.prov_type)
@miq_request = MiqRequest.find_by(:id => @record.service_resources[0].resource_id) if @record.service_resources[0]&.resource_id
if @miq_request
- Create a ticketCreate a ticket
Cyclomatic complexity for st_form_field_changed is too high. [12/11] Open
def st_form_field_changed
assert_privileges(session&.fetch_path(:edit, :rec_id) ? "catalogitem_edit" : "catalogitem_new")
id = session[:edit][:rec_id] || 'new'
return unless load_edit("st_edit__#{id}", "replace_cell__explorer")
- 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 st_form_field_changed
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def st_form_field_changed
assert_privileges(session&.fetch_path(:edit, :rec_id) ? "catalogitem_edit" : "catalogitem_new")
id = session[:edit][:rec_id] || 'new'
return unless load_edit("st_edit__#{id}", "replace_cell__explorer")
- 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 st_set_form_vars
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def st_set_form_vars
@edit = {}
@edit[:rec_id] = @record.id
@edit[:key] = "st_edit__#{@record.id || "new"}"
@edit[:url] = "servicetemplate_edit"
- Create a ticketCreate a ticket
Method st_upload_image
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def st_upload_image
assert_privileges("st_catalog_edit")
err = false
identify_catalog(params[:id])
- 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 st_upload_image
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def st_upload_image
assert_privileges("st_catalog_edit")
err = false
identify_catalog(params[:id])
- Create a ticketCreate a ticket
Method explorer
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def explorer
@explorer = true
@lastaction = "explorer"
@report_deleted = params[:report_deleted] == 'true' if params[:report_deleted]
@sb[:action] = nil
- 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 fetch_form_vars_ansible_or_ct
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def fetch_form_vars_ansible_or_ct
if params[:manager_id]
if params[:manager_id] == ""
@edit[:new][:available_templates] = []
@edit[:new][:template_id] = nil
- 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_node_info
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_node_info(treenodeid, _show_list = true)
@explorer ||= true
@nodetype, id = parse_nodetype_and_id(valid_active_node(treenodeid))
# saving this so it can be used while adding buttons/groups in buttons editor
@sb[:applies_to_id] = id
- 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 set_resource_action
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def set_resource_action(st)
d = @edit[:new][:dialog_id].nil? ? nil : Dialog.where(:id => @edit[:new][:dialog_id]).first
entry_point_keys.each do |action|
ra = st.resource_actions
- 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 rearrange_groups_array
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def rearrange_groups_array
# keep count of how many groups are deleted
g_idx = 0
# flag to check whether an empty group was deleted so next group elements can be moved up
arr_delete = false
- 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_form_vars
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_form_vars
copy_params_if_present(@edit[:new], params, %i[st_prov_type name description provision_cost catalog_id dialog_id generic_subtype long_description zone_id price retire_fqname reconfigure_fqname fqname])
@edit[:new][:display] = params[:display] == "1" if params[:display] # @edit[:new][:display] should't be changed if params[:display] is not set
# saving it in @edit as well, to use it later because prov_set_form_vars resets @edit[:new]
- Create a ticketCreate a ticket
Method fetch_playbook_details
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch_playbook_details
playbook_details = {}
provision = @record.config_info[:provision]
playbook_details[:provisioning] = {}
playbook_details[:provisioning][:repository] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource, provision[:repository_id])
- Create a ticketCreate a ticket
Method common_st_record_vars
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def common_st_record_vars(st)
st.name = @edit[:new][:name]
st.description = @edit[:new][:description]
st.long_description = @edit[:new][:display] ? @edit[:new][:long_description] : nil
st.provision_cost = @edit[:new][:provision_cost]
- 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 open_parent_nodes
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def open_parent_nodes(record)
existing_node = nil # Init var
if record.kind_of?(OrchestrationTemplate)
parents = [:id => template_to_node_name(record)]
- Create a ticketCreate a ticket
Method st_set_record_vars
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def st_set_record_vars(st)
common_st_record_vars(st)
st.remove_all_resources
@add_rsc = true
unless @edit[:new][:selected_resources].empty?
- Create a ticketCreate a ticket
Method explorer
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def explorer
@explorer = true
@lastaction = "explorer"
@report_deleted = params[:report_deleted] == 'true' if params[:report_deleted]
@sb[:action] = nil
- Create a ticketCreate a ticket
Method x_show
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def x_show
@sb[:action] = nil
@explorer = true
if x_active_tree == :stcat_tree
assert_privileges("st_catalog_view")
- 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 st_catalog_delete
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def st_catalog_delete
assert_privileges("st_catalog_delete")
elements = []
if params[:id]
elements.push(params[:id])
- 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 st_set_form_vars
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def st_set_form_vars
@edit = {}
@edit[:rec_id] = @record.id
@edit[:key] = "st_edit__#{@record.id || "new"}"
@edit[:url] = "servicetemplate_edit"
- 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_node_info
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_node_info(treenodeid, _show_list = true)
@explorer ||= true
@nodetype, id = parse_nodetype_and_id(valid_active_node(treenodeid))
# saving this so it can be used while adding buttons/groups in buttons editor
@sb[:applies_to_id] = id
- Create a ticketCreate a ticket
Method features
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def features
[
{
:role => "svc_catalog_accord",
:role_any => true,
- Create a ticketCreate a ticket
Method svc_catalog_provision
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def svc_catalog_provision
assert_privileges("svc_catalog_provision")
checked = find_checked_items
checked[0] = params[:id] if checked.blank? && params[:id]
st = find_record_with_rbac(ServiceTemplate, checked[0])
- Create a ticketCreate a ticket
Method ot_remove_submit
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def ot_remove_submit
assert_privileges("orchestration_template_remove")
elements = find_records_with_rbac(OrchestrationTemplate, checked_or_params)
elements.each do |ot|
if ot.in_use?
- 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 svc_catalog_provision
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def svc_catalog_provision
assert_privileges("svc_catalog_provision")
checked = find_checked_items
checked[0] = params[:id] if checked.blank? && params[:id]
st = find_record_with_rbac(ServiceTemplate, checked[0])
- 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
Avoid deeply nested control flow statements. Open
template_locals.merge!(fetch_playbook_details) if need_ansible_locals?
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
g[key] = param_value.to_i * 60 if param_value
- Create a ticketCreate a ticket
Method servicetemplate_edit
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def servicetemplate_edit
assert_privileges_for_servicetemplate_edit
checked_id = find_checked_items.first || params[:id]
@sb[:cached_waypoint_ids] = MiqAeClass.waypoint_ids_for_state_machines
- 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
Avoid deeply nested control flow statements. Open
if param_value
p_index = @edit[:new][:rsc_groups].flatten.collect { |rg| rg[:provision_index].to_i }.sort
# if index that came in is being used more than once
if p_index.count(g[key]) > 1
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
template_locals.merge!(fetch_ct_details) if need_container_template_locals?
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
g[key] = param_value if param_value
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
g[key] = param_value.to_i if param_value
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
g[key] = param_value.to_i if param_value
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
g[:scaling_max] = g[:scaling_min] if g[:scaling_max] < g[:scaling_min]
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
template_locals.merge!(fetch_ovf_template_details) if need_ovf_template_locals?
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
elsif record_showing || @in_a_form || @sb[:buttons_node] ||
(@pages && (@items_per_page == ONE_MILLION || @pages[:items] == 0))
if %w[button_edit group_edit group_reorder at_st_new st_new st_catalog_new st_catalog_edit copy_catalog].include?(action)
presenter.hide(:toolbar).show(:paging_div)
# incase it was hidden for summary screen, and incase there were no records on show_list
- Create a ticketCreate a ticket
Method st_catalog_edit
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def st_catalog_edit
assert_privileges((params[:id] || session&.fetch_path(:edit, :rec_id)) ? "st_catalog_edit" : "st_catalog_new")
case params[:button]
when "cancel"
- 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 resource_delete
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def resource_delete
assert_new_or_edit_by_service_type
return unless load_edit("st_edit__#{params[:id]}", "replace_cell__explorer")
- 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 add_container_template_vars
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_container_template_vars
st_options = {}
st_options[:name] = @edit[:new][:name]
st_options[:description] = @edit[:new][:description]
st_options[:long_description] = @edit[:new][:display] ? @edit[:new][:long_description] : nil
- 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 st_catalog_set_form_vars
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def st_catalog_set_form_vars
checked = find_checked_items
checked[0] = params[:id] if checked.blank? && params[:id]
@record = checked[0] ? find_record_with_rbac(ServiceTemplateCatalog, checked[0]) : ServiceTemplateCatalog.new
- 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 identify_catalog
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def identify_catalog(id = nil)
kls = TreeBuilder.get_model_for_prefix(@nodetype) == "MiqTemplate" ? VmOrTemplate : ServiceTemplate
@record = identify_record(id || params[:id], kls)
@tenants_tree = build_tenants_tree if kls == ServiceTemplate # Build the tree with available tenants for the Catalog Item/Bundle
add_flash(_("This item is invalid"), :warning) unless @flash_array || @record.try(:template_valid?)
- 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
Avoid more than 3 levels of block nesting. Open
case key
when :start_delay, :stop_delay
g[key] = param_value.to_i * 60 if param_value
when :scaling_min
g[key] = param_value.to_i if param_value
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for excessive nesting of conditional and looping constructs.
You can configure if blocks are considered using the CountBlocks
option. When set to false
(the default) blocks are not counted
towards the nesting level. Set to true
to count blocks as well.
The maximum level of nesting allowed is configurable.
Avoid more than 3 levels of block nesting. Open
locals[:action_url] = @edit[:rec_id] ? 'button_update' : 'button_create'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for excessive nesting of conditional and looping constructs.
You can configure if blocks are considered using the CountBlocks
option. When set to false
(the default) blocks are not counted
towards the nesting level. Set to true
to count blocks as well.
The maximum level of nesting allowed is configurable.
Avoid more than 3 levels of block nesting. Open
locals[:action_url] = @edit[:rec_id] ? 'group_update' : 'group_create'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for excessive nesting of conditional and looping constructs.
You can configure if blocks are considered using the CountBlocks
option. When set to false
(the default) blocks are not counted
towards the nesting level. Set to true
to count blocks as well.
The maximum level of nesting allowed is configurable.
Avoid more than 3 levels of block nesting. Open
flash_key = if params[:button] == "save"
_("Catalog Bundle \"%{name}\" was saved")
else
_("Catalog Bundle \"%{name}\" was added")
end
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for excessive nesting of conditional and looping constructs.
You can configure if blocks are considered using the CountBlocks
option. When set to false
(the default) blocks are not counted
towards the nesting level. Set to true
to count blocks as well.
The maximum level of nesting allowed is configurable.
Use filter_map
instead. Open
workflow_templates = all_templates.collect { |t| [t.name, t.id] if t.kind_of?(ManageIQ::Providers::AutomationManager::ConfigurationWorkflow) }.compact
- Create a ticketCreate a ticket
- Exclude checks
Use filter_map
instead. Open
job_templates = all_templates.collect { |t| [t.name, t.id] if t.kind_of?(ManageIQ::Providers::AutomationManager::ConfigurationScript) }.compact - workflow_templates
- Create a ticketCreate a ticket
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
def features
[
{
:role => "svc_catalog_accord",
:role_any => true,
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 50.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
when "cancel"
if session[:edit][:rec_id]
add_flash(_("Edit of Service Catalog Item \"%{name}\" was cancelled by the user") %
{:name => session[:edit][:new][:description]})
else
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 34.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
when "cancel"
if session[:edit][:rec_id]
add_flash(_("Edit of Catalog Bundle \"%{name}\" was cancelled by the user") %
{:name => session[:edit][:new][:description]})
else
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 34.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
@edit[:new][:rsc_groups].push([]) if @edit[:new][:selected_resources].length > 1 && !@edit[:new][:rsc_groups][@edit[:new][:rsc_groups].length - 1].empty?
end
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
@edit[:new][:rsc_groups].push([]) if @edit[:new][:selected_resources].length > 1 && !@edit[:new][:rsc_groups][@edit[:new][:rsc_groups].length - 1].empty?
# push a new resource into highest existing/populated group
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
id = params[:id] if params[:id]
return unless load_edit("#{session[:tag_db]}_edit_tags__#{id}", 'replace_cell__explorer')
@object_ids = @edit[:object_ids]
session[:tag_db] = @tagging = @edit[:tagging]
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 32.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
@st.errors.each do |error|
add_flash("#{error.attribute.to_s.capitalize} #{error.message}", :error)
end
@changed = session[:changed] = (@edit[:new] != @edit[:current])
javascript_flash
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 30.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Wrap expressions with varying precedence with parentheses to avoid ambiguity. Open
if checked_id.present? && composite_type || checked_id.nil? && !new_atomic_item
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Looks for expressions containing multiple binary operators
where precedence is ambiguous due to lack of parentheses. For example,
in 1 + 2 * 3
, the multiplication will happen before the addition, but
lexically it appears that the addition will happen first.
The cop does not consider unary operators (ie. !a
or -b
) or comparison
operators (ie. a =~ b
) because those are not ambiguous.
NOTE: Ranges are handled by Lint/AmbiguousRange
.
Example:
# bad
a + b * c
a || b && c
a ** b + c
# good (different precedence)
a + (b * c)
a || (b && c)
(a ** b) + c
# good (same precedence)
a + b + c
a * b / c % d
Wrap expressions with varying precedence with parentheses to avoid ambiguity. Open
presenter[:lock_sidebar] = @edit && @edit[:current] || action == 'copy_catalog'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Looks for expressions containing multiple binary operators
where precedence is ambiguous due to lack of parentheses. For example,
in 1 + 2 * 3
, the multiplication will happen before the addition, but
lexically it appears that the addition will happen first.
The cop does not consider unary operators (ie. !a
or -b
) or comparison
operators (ie. a =~ b
) because those are not ambiguous.
NOTE: Ranges are handled by Lint/AmbiguousRange
.
Example:
# bad
a + b * c
a || b && c
a ** b + c
# good (different precedence)
a + (b * c)
a || (b && c)
(a ** b) + c
# good (same precedence)
a + b + c
a * b / c % d
Wrap expressions with varying precedence with parentheses to avoid ambiguity. Open
if checked_id.present? && composite_type || checked_id.nil? && !new_atomic_item
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Looks for expressions containing multiple binary operators
where precedence is ambiguous due to lack of parentheses. For example,
in 1 + 2 * 3
, the multiplication will happen before the addition, but
lexically it appears that the addition will happen first.
The cop does not consider unary operators (ie. !a
or -b
) or comparison
operators (ie. a =~ b
) because those are not ambiguous.
NOTE: Ranges are handled by Lint/AmbiguousRange
.
Example:
# bad
a + b * c
a || b && c
a ** b + c
# good (different precedence)
a + (b * c)
a || (b && c)
(a ** b) + c
# good (same precedence)
a + b + c
a * b / c % d