Method add_element
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_element(doc, metadata, parent, contents, parent_array: nil)
# backward compatibility. Keys are sorted and needs old ycp sort to be able to compare also classes
Builtins.sort(contents.keys).each do |key|
raise XMLSerializationError.new("Cannot represent non-string key '#{key.inspect}', part of #{contents.inspect}", contents) unless key.is_a?(::String)
Method parse_node
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def parse_node(node, result)
name = node.name
# use only element children
children = node.children
children = children.select(&:element?)
- 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 add_element
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def add_element(doc, metadata, parent, contents, parent_array: nil)
# backward compatibility. Keys are sorted and needs old ycp sort to be able to compare also classes
Builtins.sort(contents.keys).each do |key|
raise XMLSerializationError.new("Cannot represent non-string key '#{key.inspect}', part of #{contents.inspect}", contents) unless key.is_a?(::String)
- 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 parse_node
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_node(node, result)
name = node.name
# use only element children
children = node.children
children = children.select(&:element?)
Method xmlCreateDoc
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def xmlCreateDoc(doc, doc_settings)
doc_settings = deep_copy(doc_settings)
current_settings = {
"cdataSections" => Ops.get_list(
doc_settings,
Method validate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate(xml, schema)
xml = SCR.Read(path(".target.string"), xml.to_s) if xml.is_a?(Pathname)
if schema.is_a?(::String)
validator = Nokogiri::XML::RelaxNG(schema)
else
- 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 detect_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def detect_type(text, children, node)
# backward compatibility. Newly maps should have its type
if text.empty? && !children.empty?
"map"
elsif (!text.empty? && children.empty?) ||
- 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"