BallAerospace/COSMOS

View on GitHub
cosmos/lib/cosmos/logs/packet_log_reader.rb

Summary

Maintainability
D
1 day
Test Coverage

Method read has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    def read(identify_and_define = true)
      # Read entry length
      length = @file.read(4)
      return nil if !length or length.length <= 0

Severity: Minor
Found in cosmos/lib/cosmos/logs/packet_log_reader.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 each has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def each(filename, identify_and_define = true, start_time = nil, end_time = nil)
      reached_end_time = false
      open(filename)

      # seek_to_time(start_time) if start_time
Severity: Minor
Found in cosmos/lib/cosmos/logs/packet_log_reader.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 identify_and_define_packet_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def identify_and_define_packet_data(cmd_or_tlm, target_name, packet_name, received_time, packet_data)
      packet = nil
      unless target_name and packet_name
        if cmd_or_tlm == :CMD
          packet = System.commands.identify(packet_data)
Severity: Minor
Found in cosmos/lib/cosmos/logs/packet_log_reader.rb - About 55 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

Avoid deeply nested control flow statements.
Open

      elsif flags & COSMOS5_ENTRY_TYPE_MASK == COSMOS5_OFFSET_MARKER_ENTRY_TYPE_MASK
        @redis_offset = entry[2..-1]
        return read(identify_and_define)
      else
        raise "Invalid Entry Flags: #{flags}"
Severity: Major
Found in cosmos/lib/cosmos/logs/packet_log_reader.rb - About 45 mins to fix

    Method read_file_header has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def read_file_header
          header = @file.read(COSMOS5_HEADER_LENGTH)
          if header and header.length == COSMOS5_HEADER_LENGTH
            if header == COSMOS5_FILE_HEADER
              # Found COSMOS 5 File Header - That's all we need to do
    Severity: Minor
    Found in cosmos/lib/cosmos/logs/packet_log_reader.rb - About 45 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

    Avoid deeply nested control flow statements.
    Open

            if id
              id = entry[(packet_name_length + 4)..-1]
              @packet_ids << id
            end
    Severity: Major
    Found in cosmos/lib/cosmos/logs/packet_log_reader.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

              packet_name_length -= COSMOS5_ID_FIXED_SIZE if id
      Severity: Major
      Found in cosmos/lib/cosmos/logs/packet_log_reader.rb - About 45 mins to fix

        Method identify_and_define_packet_data has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def identify_and_define_packet_data(cmd_or_tlm, target_name, packet_name, received_time, packet_data)
        Severity: Minor
        Found in cosmos/lib/cosmos/logs/packet_log_reader.rb - About 35 mins to fix

          Avoid too many return statements within this method.
          Open

                  return read(identify_and_define)
          Severity: Major
          Found in cosmos/lib/cosmos/logs/packet_log_reader.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return read(identify_and_define)
            Severity: Major
            Found in cosmos/lib/cosmos/logs/packet_log_reader.rb - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status