BallAerospace/COSMOS

View on GitHub
cosmos/lib/cosmos/interfaces/protocols/preidentified_protocol.rb

Summary

Maintainability
C
1 day
Test Coverage

Method reduce_to_single_packet has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def reduce_to_single_packet
      # Discard sync pattern if present
      if @sync_pattern
        if @reduction_state == :START
          return :STOP if @data.length < @sync_pattern.length
Severity: Minor
Found in cosmos/lib/cosmos/interfaces/protocols/preidentified_protocol.rb - About 4 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 write_packet has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def write_packet(packet)
      received_time = packet.received_time
      received_time = Time.now unless received_time
      @write_time_seconds = [received_time.tv_sec].pack('N') # UINT32
      @write_time_microseconds = [received_time.tv_usec].pack('N') # UINT32
Severity: Minor
Found in cosmos/lib/cosmos/interfaces/protocols/preidentified_protocol.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

Avoid too many return statements within this method.
Open

        return :STOP if @read_packet_name == :STOP
Severity: Major
Found in cosmos/lib/cosmos/interfaces/protocols/preidentified_protocol.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return :STOP if @read_target_name == :STOP
    Severity: Major
    Found in cosmos/lib/cosmos/interfaces/protocols/preidentified_protocol.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return :STOP if packet_data == :STOP
      Severity: Major
      Found in cosmos/lib/cosmos/interfaces/protocols/preidentified_protocol.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return packet_data
        Severity: Major
        Found in cosmos/lib/cosmos/interfaces/protocols/preidentified_protocol.rb - About 30 mins to fix

          Method read_length_field_followed_by_string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def read_length_field_followed_by_string(length_num_bytes)
                # Read bytes for string length
                return :STOP if @data.length < length_num_bytes
          
                string_length = @data[0..(length_num_bytes - 1)]
          Severity: Minor
          Found in cosmos/lib/cosmos/interfaces/protocols/preidentified_protocol.rb - About 25 mins 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

          There are no issues that match your filters.

          Category
          Status