Class ToolbarBuilder
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
class ApplicationHelper::ToolbarBuilder
include MiqAeClassHelper
include RestfulControllerMixin
include ApplicationHelper::Toolbar::Mixins::CustomButtonToolbarMixin
- Create a ticketCreate a ticket
Method build_select_button
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def build_select_button(bgi, index)
bs_children = false
props = toolbar_button(bgi, :id => bgi[:id], :type => :buttonSelect)
return nil if props.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
Cyclomatic complexity for twostate_button_selected is too high. [20/11] Open
def twostate_button_selected(id)
return true if id.starts_with?("view_") && id.ends_with?("textual") # Summary view buttons
return true if @ght_type && id.starts_with?("view_") && id.ends_with?(@ght_type) # GHT view buttons on report show
return true if id.starts_with?("compare_") && id.ends_with?(settings(:views, :compare).to_s)
return true if id.starts_with?("drift_") && id.ends_with?(settings(:views, :drift).to_s)
- 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 build_select_button is too high. [14/11] Open
def build_select_button(bgi, index)
bs_children = false
props = toolbar_button(bgi, :id => bgi[:id], :type => :buttonSelect)
return nil if props.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
Cyclomatic complexity for get_custom_buttons is too high. [13/11] Open
def get_custom_buttons(model, record, toolbar_result)
cbses = CustomButtonSet.find_all_by_class_name(button_class_name(model), service_template_id(record))
cbses = CustomButtonSet.filter_with_visibility_expression(cbses, record)
cbses.sort_by { |cbs| cbs.set_data[:group_index] }.collect do |cbs|
- 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 get_custom_buttons
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_custom_buttons(model, record, toolbar_result)
cbses = CustomButtonSet.find_all_by_class_name(button_class_name(model), service_template_id(record))
cbses = CustomButtonSet.filter_with_visibility_expression(cbses, record)
cbses.sort_by { |cbs| cbs.set_data[:group_index] }.collect do |cbs|
- 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 twostate_button_selected
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def twostate_button_selected(id)
return true if id.starts_with?("view_") && id.ends_with?("textual") # Summary view buttons
return true if @ght_type && id.starts_with?("view_") && id.ends_with?(@ght_type) # GHT view buttons on report show
return true if id.starts_with?("compare_") && id.ends_with?(settings(:views, :compare).to_s)
return true if id.starts_with?("drift_") && id.ends_with?(settings(:views, :drift).to_s)
- 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 create_custom_button
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create_custom_button(input, model, record)
button_id = input[:id]
button_name = input[:name].to_s
record_id = if cb_send_checked_list
'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 get_custom_buttons
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_custom_buttons(model, record, toolbar_result)
cbses = CustomButtonSet.find_all_by_class_name(button_class_name(model), service_template_id(record))
cbses = CustomButtonSet.filter_with_visibility_expression(cbses, record)
cbses.sort_by { |cbs| cbs.set_data[:group_index] }.collect do |cbs|
- Create a ticketCreate a ticket
Method build_select_button
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_select_button(bgi, index)
bs_children = false
props = toolbar_button(bgi, :id => bgi[:id], :type => :buttonSelect)
return nil if props.nil?
- Create a ticketCreate a ticket
Method apply_common_props
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def apply_common_props(button, input)
button.update(
:color => input[:color],
:data => button.data(input[:data]),
:hidden => button[:hidden] || !!input[:hidden],
- Create a ticketCreate a ticket
Method custom_button_selects
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def custom_button_selects(model, record, toolbar_result)
get_custom_buttons(model, record, toolbar_result).collect do |group|
buttons = group[:buttons].collect { |b| create_custom_button(b, model, record) }
enabled = if cb_send_checked_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 apply_common_props
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def apply_common_props(button, input)
button.update(
:color => input[:color],
:data => button.data(input[:data]),
:hidden => button[:hidden] || !!input[:hidden],
- 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 custom_button_add_related_buttons
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def custom_button_add_related_buttons(model, record, toolbar)
# For Service, we include buttons for ServiceTemplate.
# These buttons are added as a single group with multiple buttons
if record.kind_of?(Service)
service_buttons = record_to_service_buttons(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
Avoid too many return
statements within this method. Open
return true if id.starts_with?("comparemode_") && id.ends_with?(settings(:views, :compare_mode).to_s)
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return true if id.starts_with?("driftmode_") && id.ends_with?(settings(:views, :drift_mode).to_s)
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return true if id == "view_dashboard" && @showtype == "dashboard"
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return true if id == "compare_all"
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return true if id == "view_summary" && @showtype == "main"
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return true if id == "drift_all"
- Create a ticketCreate a ticket
Method custom_toolbar_class
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def custom_toolbar_class(toolbar_result)
record = @record
if @display == 'generic_objects'
model = GenericObjectDefinition
record = GenericObject.find_by(:id => @sb[:rec_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"