lib/ruby-serial/versions/1/deserializer.rb
Method get_original_rec
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_original_rec(decoded_obj, container_to_fill = nil)
if decoded_obj.is_a?(Array)
if container_to_fill.nil?
return decoded_obj.map { |serialized_item| get_original_rec(serialized_item) }
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 get_original_rec
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def get_original_rec(decoded_obj, container_to_fill = nil)
if decoded_obj.is_a?(Array)
if container_to_fill.nil?
return decoded_obj.map { |serialized_item| get_original_rec(serialized_item) }
else
Avoid deeply nested control flow statements. Open
Open
new_obj = ((container_to_fill.nil?) ? eval(decoded_obj[OBJECT_CLASSNAME_REFERENCE]).allocate : container_to_fill)
Avoid deeply nested control flow statements. Open
Open
hash_obj = ((container_to_fill.nil?) ? {} : container_to_fill)
Avoid deeply nested control flow statements. Open
Open
return (exclude_end ? (get_original_rec(serialized_first)...get_original_rec(serialized_last)) : (get_original_rec(serialized_first)..get_original_rec(serialized_last)))
Avoid deeply nested control flow statements. Open
Open
new_obj.rubyserial_onload if new_obj.respond_to?(:rubyserial_onload)
Avoid too many return
statements within this method. Open
Open
return @decoded_shared_objs[obj_id]
Avoid too many return
statements within this method. Open
Open
return container_to_fill
Avoid too many return
statements within this method. Open
Open
return hash_obj
Avoid too many return
statements within this method. Open
Open
return (exclude_end ? (get_original_rec(serialized_first)...get_original_rec(serialized_last)) : (get_original_rec(serialized_first)..get_original_rec(serialized_last)))
Avoid too many return
statements within this method. Open
Open
return new_obj
Avoid too many return
statements within this method. Open
Open
return decoded_obj