wakproductions/tdameritrade_api

View on GitHub
lib/tdameritrade_api/streamer.rb

Summary

Maintainability
C
1 day
Test Coverage

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 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 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 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

          There are no issues that match your filters.

          Category
          Status