Method miq_compare_elements
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def miq_compare_elements(node1, node2, delta, diff_elements, stats)
node1.each_element do |e1|
e2 = miq_find_element(e1, node2)
if e2
if miq_compare_attributes(e1, e2) == 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 miq_record_change
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def miq_record_change(node, _delta, diff_elements, stats)
srcPath = node[0].nil? ? node[1] : node[0]
if node[1].nil?
action = :adds
- 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 miq_record_change
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def miq_record_change(node, _delta, diff_elements, stats)
srcPath = node[0].nil? ? node[1] : node[0]
if node[1].nil?
action = :adds
- Create a ticketCreate a ticket
Method miq_compare_elements
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def miq_compare_elements(node1, node2, delta, diff_elements, stats)
- Create a ticketCreate a ticket
Method miq_compare_roots
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def miq_compare_roots(node1, xml2, delta, diff_elements, stats)
- Create a ticketCreate a ticket
Method miq_compare_attributes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def miq_compare_attributes(e1, e2)
# If the attribute count does not match, they can't be equal
return false if e1.attributes.length != e2.attributes.length
# Next check the element text (use to_s to convert nil to "")
- 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 miq_find_element
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def miq_find_element(e, node)
return nil unless node
found = nil
node.each_element do|e2|
found = e2 if miq_same_element(e, e2) == 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
Unused method argument - ele
. If it's necessary, use _
or _ele
as an argument name to indicate that it won't be used. If it's unnecessary, remove it. You can also write as miq_compare_get_element_index(*)
if you want the method to accept any arguments but don't care about them. Open
def miq_compare_get_element_index(ele)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for unused method arguments.
Example:
# bad
def some_method(used, unused, _unused_but_allowed)
puts used
end
# good
def some_method(used, _unused, _unused_but_allowed)
puts used
end
Example: AllowUnusedKeywordArguments: false (default)
# bad
def do_something(used, unused: 42)
used
end
Example: AllowUnusedKeywordArguments: true
# good
def do_something(used, unused: 42)
used
end
Example: IgnoreEmptyMethods: true (default)
# good
def do_something(unused)
end
Example: IgnoreEmptyMethods: false
# bad
def do_something(unused)
end
Example: IgnoreNotImplementedMethods: true (default)
# good
def do_something(unused)
raise NotImplementedError
end
def do_something_else(unused)
fail "TODO"
end
Example: IgnoreNotImplementedMethods: false
# bad
def do_something(unused)
raise NotImplementedError
end
def do_something_else(unused)
fail "TODO"
end