Method run
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def run(opt={}, &block)
@quit = false
@message_block = block
@buffer = String.new
- 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
File streamer.rb
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'net/http'
require 'tdameritrade_api/streamer_types'
module TDAmeritradeApi
module Streamer
Method run
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(opt={}, &block)
@quit = false
@message_block = block
@buffer = String.new
Method read_stream_column
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_stream_column(data, column_type)
# First byte of data should still contain the column number
case column_type
when :string
Method process_heartbeat
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def process_heartbeat
return false if @buffer.length < 2
if @buffer[0] == 'H'
hb = StreamData.new(:heartbeat)
- 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 process_buffer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def process_buffer
@buffer = String.new and return if @quit # empty buffer and stop processing
# advance until we get a recognizable code in the stream
until @buffer.length == 0 || !next_record_type_in_buffer.nil?
- 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 nil
Method process_snapshot
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def process_snapshot
return false if @buffer[0] != 'N' || @buffer.length < 3
n = StreamData.new(:snapshot)
service_id_length = @buffer[1..2].reverse.unpack('S').first
- 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"