Muriel-Salvan/ruby-serial

View on GitHub

Showing 24 of 26 total issues

Method get_original_rec has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
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
Severity: Minor
Found in lib/ruby-serial/versions/1/deserializer.rb - About 6 hrs to fix

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 a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
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? ||
Severity: Minor
Found in lib/ruby-serial/versions/1/serializer.rb - About 2 hrs to fix

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

          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
Severity: Minor
Found in lib/ruby-serial/versions/1/deserializer.rb - About 1 hr to fix

    Method get_msgpack_compatible_rec has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    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? ||
    Severity: Minor
    Found in lib/ruby-serial/versions/1/serializer.rb - About 1 hr to fix

      Method gather_ids_rec has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

                def gather_ids_rec(obj)
                  if !obj.is_a?(Fixnum) &&
                     !obj.is_a?(Bignum) &&
                     !obj.is_a?(Float) &&
                     !obj.is_a?(Symbol) &&
      Severity: Minor
      Found in lib/ruby-serial/versions/1/serializer.rb - About 1 hr to fix

      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

                  if !obj.is_a?(Fixnum) &&
                     !obj.is_a?(Bignum) &&
                     !obj.is_a?(Float) &&
                     !obj.is_a?(Symbol) &&
                     !obj.is_a?(Encoding) &&
      Severity: Critical
      Found in lib/ruby-serial/versions/1/serializer.rb - About 1 hr to fix

        Method gather_ids_rec has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                  def gather_ids_rec(obj)
                    if !obj.is_a?(Fixnum) &&
                       !obj.is_a?(Bignum) &&
                       !obj.is_a?(Float) &&
                       !obj.is_a?(Symbol) &&
        Severity: Minor
        Found in lib/ruby-serial/versions/1/serializer.rb - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                            new_obj = ((container_to_fill.nil?) ? eval(decoded_obj[OBJECT_CLASSNAME_REFERENCE]).allocate : container_to_fill)
          Severity: Major
          Found in lib/ruby-serial/versions/1/deserializer.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                              return (exclude_end ? (get_original_rec(serialized_first)...get_original_rec(serialized_last)) : (get_original_rec(serialized_first)..get_original_rec(serialized_last)))
            Severity: Major
            Found in lib/ruby-serial/versions/1/deserializer.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                hash_obj = ((container_to_fill.nil?) ? {} : container_to_fill)
              Severity: Major
              Found in lib/ruby-serial/versions/1/deserializer.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                  new_obj.rubyserial_onload if new_obj.respond_to?(:rubyserial_onload)
                Severity: Major
                Found in lib/ruby-serial/versions/1/deserializer.rb - About 45 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                              if obj.is_a?(Fixnum) ||
                                 obj.is_a?(Bignum) ||
                                 obj.is_a?(Float) ||
                                 obj.nil? ||
                                 obj == true ||
                  Severity: Major
                  Found in lib/ruby-serial/versions/1/serializer.rb - About 40 mins to fix

                    Avoid too many return statements within this method.
                    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?]
                                  }
                    Severity: Major
                    Found in lib/ruby-serial/versions/1/serializer.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                        return (exclude_end ? (get_original_rec(serialized_first)...get_original_rec(serialized_last)) : (get_original_rec(serialized_first)..get_original_rec(serialized_last)))
                      Severity: Major
                      Found in lib/ruby-serial/versions/1/deserializer.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                      return obj
                        Severity: Major
                        Found in lib/ruby-serial/versions/1/serializer.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                        return {
                                          OBJECT_CLASSNAME_REFERENCE => obj.class.name,
                                          OBJECT_CONTENT_REFERENCE => serialized_instance_vars
                                        }
                          Severity: Major
                          Found in lib/ruby-serial/versions/1/serializer.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                              return hash_obj
                            Severity: Major
                            Found in lib/ruby-serial/versions/1/deserializer.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                return new_obj
                              Severity: Major
                              Found in lib/ruby-serial/versions/1/deserializer.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                              return hash_to_store
                                Severity: Major
                                Found in lib/ruby-serial/versions/1/serializer.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                return decoded_obj
                                  Severity: Major
                                  Found in lib/ruby-serial/versions/1/deserializer.rb - About 30 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language