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
- 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 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
- 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
Avoid too many return
statements within this method. Open
return :STOP if @read_packet_name == :STOP
Avoid too many return
statements within this method. Open
return :STOP if @read_target_name == :STOP
Avoid too many return
statements within this method. Open
return :STOP if packet_data == :STOP
Avoid too many return
statements within this method. Open
return packet_data
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)]
- 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"