wakproductions/tdameritrade_api

View on GitHub

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

Severity: Minor
Found in lib/tdameritrade_api/streamer.rb - About 3 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

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
Severity: Minor
Found in lib/tdameritrade_api/streamer.rb - About 2 hrs to fix

    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
    
    
    Severity: Minor
    Found in lib/tdameritrade_api/streamer.rb - About 1 hr to fix

      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)
      Severity: Minor
      Found in lib/tdameritrade_api/price_history.rb - About 1 hr to fix

        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
        Severity: Minor
        Found in lib/tdameritrade_api/price_history.rb - About 1 hr to fix

          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)
          Severity: Minor
          Found in lib/tdameritrade_api/price_history.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

          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
          Severity: Minor
          Found in lib/tdameritrade_api/watchlist.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/tdameritrade_api/watchlist.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

            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
            Severity: Minor
            Found in lib/tdameritrade_api/watchlist.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

            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
            Severity: Minor
            Found in lib/tdameritrade_api/watchlist.rb - About 1 hr to fix

              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
              Severity: Minor
              Found in lib/tdameritrade_api/streamer.rb - About 1 hr to fix

                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)
                Severity: Minor
                Found in lib/tdameritrade_api/streamer.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

                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)
                Severity: Minor
                Found in lib/tdameritrade_api/balances_and_positions.rb - About 35 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

                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?
                Severity: Minor
                Found in lib/tdameritrade_api/streamer.rb - About 35 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 too many return statements within this method.
                Open

                          return nil
                Severity: Major
                Found in lib/tdameritrade_api/streamer.rb - About 30 mins to fix

                  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
                  Severity: Minor
                  Found in lib/tdameritrade_api/price_history.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

                  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
                  Severity: Minor
                  Found in lib/tdameritrade_api/streamer.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

                  Severity
                  Category
                  Status
                  Source
                  Language