Showing 17 of 21 total issues
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 get_price_history
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_price_history(symbol, options={})
# TODO: allow multiple symbols by allowing user to pass and array of strings
# TODO: change this around so that it does not need a temporary file buffer and can handle the processing in memory
validate_price_history_options options
request_params = build_price_history_request_params(symbol, options)
Method get_quote
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_quote(symbols)
if symbols.is_a? Array
quote_list = symbols.join(',') if symbols.is_a? Array
else
quote_list=symbols
Method get_price_history
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_price_history(symbol, options={})
# TODO: allow multiple symbols by allowing user to pass and array of strings
# TODO: change this around so that it does not need a temporary file buffer and can handle the processing in memory
validate_price_history_options options
request_params = build_price_history_request_params(symbol, options)
- 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 edit_watchlist
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def edit_watchlist(opts={})
# valid values are watchlistname and symbollist - see the API docs for details
fail 'listid required!' unless opts[:listid]
fail 'symbollist required! (at least 1 symbol)' unless opts[:symbollist]
opts[:symbollist] = opts[:symbollist].join(',') if opts[:symbollist].is_a? Array
Method edit_watchlist
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def edit_watchlist(opts={})
# valid values are watchlistname and symbollist - see the API docs for details
fail 'listid required!' unless opts[:listid]
fail 'symbollist required! (at least 1 symbol)' unless opts[:symbollist]
opts[:symbollist] = opts[:symbollist].join(',') if opts[:symbollist].is_a? Array
- 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 create_watchlist
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create_watchlist(opts={})
# valid values are watchlistname and symbollist - see the API docs for details
fail 'watchlistname required!' unless opts[:watchlistname]
fail 'symbollist required! (at least 1 symbol)' unless opts[:symbollist]
opts[:symbollist] = opts[:symbollist].join(',') if opts[:symbollist].is_a? Array
- 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 create_watchlist
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_watchlist(opts={})
# valid values are watchlistname and symbollist - see the API docs for details
fail 'watchlistname required!' unless opts[:watchlistname]
fail 'symbollist required! (at least 1 symbol)' unless opts[:symbollist]
opts[:symbollist] = opts[:symbollist].join(',') if opts[:symbollist].is_a? Array
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 get_balances_and_positions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_balances_and_positions(account_id, options={})
request_params = build_bp_params(account_id, options)
uri = URI.parse BALANCES_AND_POSITIONS_URL
uri.query = URI.encode_www_form(request_params)
- 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 build_price_history_request_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build_price_history_request_params(symbol, options)
req = {source: @source_id, requestidentifiertype: 'SYMBOL'}.merge(options)
if symbol.kind_of? String
req[:requestvalue] = symbol
- 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_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"