lib/prestashop/api/converter.rb
Method xml_node_to_hash
has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.xml_node_to_hash node
# If we are at the root of the document, start the hash
if node.element?
result_hash = {}
if node.attributes != {}
- Read upRead up
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 build_nodes
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.build_nodes ml, source, mkey = nil
unless source[:attr] and source[:val]
source.each do |key, value|
if value.kind_of? Hash
if value[:attr]
- Read upRead up
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 xml_node_to_hash
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.xml_node_to_hash node
# If we are at the root of the document, start the hash
if node.element?
result_hash = {}
if node.attributes != {}
Method build_nodes
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.build_nodes ml, source, mkey = nil
unless source[:attr] and source[:val]
source.each do |key, value|
if value.kind_of? Hash
if value[:attr]
Avoid deeply nested control flow statements. Open
Open
elsif result_hash[child.name.to_sym]
if result_hash[child.name.to_sym].is_a?(Object::Array)
result_hash[child.name.to_sym] << prepare(result)
else
result_hash[child.name.to_sym] = [result_hash[child.name.to_sym]] << prepare(result)
Avoid deeply nested control flow statements. Open
Open
if !result_hash.empty?
result_hash[:val] = prepare(result)
return result_hash
end
Avoid deeply nested control flow statements. Open
Open
if !result_hash.empty?
result_hash[:val] = prepare(result)
return result_hash
end
Avoid deeply nested control flow statements. Open
Open
result_hash[:attr] = {} unless result_hash[:attr]
Avoid too many return
statements within this method. Open
Open
return prepare(node.content.to_s)
Avoid too many return
statements within this method. Open
Open
return result_hash
Avoid too many return
statements within this method. Open
Open
return result_hash