lib/ruby-serial/versions/1/serializer.rb
Method get_msgpack_compatible_rec
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_msgpack_compatible_rec(obj, check_shared = true)
if obj.is_a?(Fixnum) ||
obj.is_a?(Bignum) ||
obj.is_a?(Float) ||
obj.nil? ||
- 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_msgpack_compatible_rec
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def get_msgpack_compatible_rec(obj, check_shared = true)
if obj.is_a?(Fixnum) ||
obj.is_a?(Bignum) ||
obj.is_a?(Float) ||
obj.nil? ||
Method gather_ids_rec
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def gather_ids_rec(obj)
if !obj.is_a?(Fixnum) &&
!obj.is_a?(Bignum) &&
!obj.is_a?(Float) &&
!obj.is_a?(Symbol) &&
- 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
Consider simplifying this complex logical expression. Open
Open
if !obj.is_a?(Fixnum) &&
!obj.is_a?(Bignum) &&
!obj.is_a?(Float) &&
!obj.is_a?(Symbol) &&
!obj.is_a?(Encoding) &&
Method gather_ids_rec
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def gather_ids_rec(obj)
if !obj.is_a?(Fixnum) &&
!obj.is_a?(Bignum) &&
!obj.is_a?(Float) &&
!obj.is_a?(Symbol) &&
Consider simplifying this complex logical expression. Open
Open
if obj.is_a?(Fixnum) ||
obj.is_a?(Bignum) ||
obj.is_a?(Float) ||
obj.nil? ||
obj == true ||
Avoid too many return
statements within this method. Open
Open
return obj.map { |item| get_msgpack_compatible_rec(item) }
Avoid too many return
statements within this method. Open
Open
return hash_to_store
Avoid too many return
statements within this method. Open
Open
return obj
Avoid too many return
statements within this method. Open
Open
return {
OBJECT_CLASSNAME_REFERENCE => CLASS_ID_RANGE,
OBJECT_CONTENT_REFERENCE => [get_msgpack_compatible_rec(obj.first), get_msgpack_compatible_rec(obj.last), obj.exclude_end?]
}
Avoid too many return
statements within this method. Open
Open
return {
OBJECT_CLASSNAME_REFERENCE => obj.class.name,
OBJECT_CONTENT_REFERENCE => serialized_instance_vars
}