wakproductions/tdameritrade_api

View on GitHub
lib/tdameritrade_api/price_history.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

      There are no issues that match your filters.

      Category
      Status