Method adv_search_button_saveid
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def adv_search_button_saveid
if @edit[:new_search_name].nil? || @edit[:new_search_name] == ""
add_flash(_("Search Name is required"), :error) if params[:button] == 'saveit'
false
else
- 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 adv_search_build is too high. [13/11] Open
def adv_search_build(model)
# Restore @edit hash if it's saved in @settings
@expkey = :expression # Reset to use default expression key
if session.fetch_path(:adv_search, model.to_s) && %w[tag service_tag].exclude?(@sb[:action])
adv_search_model = session[:adv_search][model.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
Method adv_search_build
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def adv_search_build(model)
# Restore @edit hash if it's saved in @settings
@expkey = :expression # Reset to use default expression key
if session.fetch_path(:adv_search, model.to_s) && %w[tag service_tag].exclude?(@sb[:action])
adv_search_model = session[:adv_search][model.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 adv_search_clear
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def adv_search_clear
respond_to do |format|
format.js do
@explorer = true
if x_active_tree.to_s =~ /_filter_tree$/ &&
- Create a ticketCreate a ticket
Method adv_search_button
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def adv_search_button
@edit = session[:edit]
@view = session[:view]
# setting default to false
- Create a ticketCreate a ticket
Method adv_search_build
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def adv_search_build(model)
# Restore @edit hash if it's saved in @settings
@expkey = :expression # Reset to use default expression key
if session.fetch_path(:adv_search, model.to_s) && %w[tag service_tag].exclude?(@sb[:action])
adv_search_model = session[:adv_search][model.to_s]
- Create a ticketCreate a ticket
Method adv_search_button_delete
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def adv_search_button_delete
s = MiqSearch.find(@edit[@expkey][:selected][:id])
id = s.id
sname = s.description
begin
- Create a ticketCreate a ticket
Method adv_search_clear
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def adv_search_clear
respond_to do |format|
format.js do
@explorer = true
if x_active_tree.to_s =~ /_filter_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 adv_search_load_choice
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def adv_search_load_choice
@edit = session[:edit]
if params[:chosen_search]
@edit[@expkey][:exp_chosen_report] = nil
if params[:chosen_search] == "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
Method adv_search_button
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def adv_search_button
@edit = session[:edit]
@view = session[:view]
# setting default to 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 adv_search_button_loadit
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def adv_search_button_loadit
if @edit[@expkey][:exp_chosen_search]
@edit[:selected] = true
s = MiqSearch.find(@edit[@expkey][:exp_chosen_search].to_s)
@edit[:new][@expkey] = s.filter.exp
- 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 adv_search_redraw_left_div
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def adv_search_redraw_left_div
if @edit[:in_explorer] || %w[storage_tree configuration_scripts_tree].include?(x_active_tree.to_s)
tree_type = x_active_tree.to_s.sub(/_tree/, '').to_sym
builder = TreeBuilder.class_for_type(tree_type)
tree = builder.new(x_active_tree, @sb)
- 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 adv_search_button_apply
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def adv_search_button_apply
@edit[@expkey][:selected] = @edit[@expkey][:exp_last_loaded] # Save the last search loaded (saved)
@edit[:adv_search_applied] ||= {}
@edit[:adv_search_applied][:exp] = {}
adv_search_set_text # Set search text filter suffix
- 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 adv_search_button_delete
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def adv_search_button_delete
s = MiqSearch.find(@edit[@expkey][:selected][:id])
id = s.id
sname = s.description
begin
- 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"