aki017/ZeroFormatter.rb

View on GitHub

Showing 5 of 7 total issues

Method load has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def load(klass, bytes)
      object_size = Utils.read_s4(bytes, 0)
      raise "Object size missmatch, expected=#{object_size}, actual=#{bytes.bytesize}" if object_size != bytes.bytesize

      last_index = Utils.read_s4(bytes, 4)
Severity: Minor
Found in lib/zero_formatter/serializer.rb - About 3 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 dump has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def dump(value)
      last_index = value.class.fields.last[:index]

      data_headers = []
      data_header = "".force_encoding("ASCII-8bit")
Severity: Minor
Found in lib/zero_formatter/serializer.rb - About 3 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 dump has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def dump(value)
      last_index = value.class.fields.last[:index]

      data_headers = []
      data_header = "".force_encoding("ASCII-8bit")
Severity: Major
Found in lib/zero_formatter/serializer.rb - About 2 hrs to fix

    Class Utils has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Utils
        class << self
          def read_s1(bytes, index)
            to_signed(bytes.getbyte(index), 1 << (8 -1))
          end
    Severity: Minor
    Found in lib/zero_formatter/utils.rb - About 2 hrs to fix

      Method load has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def load(klass, bytes)
            object_size = Utils.read_s4(bytes, 0)
            raise "Object size missmatch, expected=#{object_size}, actual=#{bytes.bytesize}" if object_size != bytes.bytesize
      
            last_index = Utils.read_s4(bytes, 4)
      Severity: Minor
      Found in lib/zero_formatter/serializer.rb - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language