rviney/ig_markets

View on GitHub

Showing 12 of 12 total issues

Method validate_trailing_stop_constraints has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def validate_trailing_stop_constraints
          if trailing_stop
            raise ArgumentError, 'do not set stop_level when trailing_stop is true' if stop_level
            raise ArgumentError, 'set stop_distance when trailing_stop is true' unless stop_distance
            raise ArgumentError, 'set trailing_stop_increment when trailing_stop is true' unless trailing_stop_increment
Severity: Minor
Found in lib/ig_markets/dealing_platform/position_methods.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 instantiate_model_from_attributes_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def instantiate_model_from_attributes_hash(model_class, attributes)
      model_class.new.tap do |model|
        model.instance_variable_set :@dealing_platform, self

        attributes.each do |attribute, value|
Severity: Minor
Found in lib/ig_markets/dealing_platform.rb - About 45 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 parse_date_time has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def parse_date_time(attributes, attribute, klass, format, display_format)
Severity: Minor
Found in lib/ig_markets/cli/main.rb - About 35 mins to fix

    Method cell_color has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def cell_color(_value, sprint, _row_index, column_index)
              return unless headings[column_index] == 'Payout'
    
              if current_level(sprint) > sprint.strike_level && sprint.direction == :buy ||
                 current_level(sprint) < sprint.strike_level && sprint.direction == :sell
    Severity: Minor
    Found in lib/ig_markets/cli/tables/sprint_market_positions_table.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 filter_options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def filter_options(options, whitelist)
              options.each_with_object({}) do |(key, value), new_hash|
                next unless whitelist.include? key.to_sym
    
                new_hash[key.to_sym] = value == key ? nil : value
    Severity: Minor
    Found in lib/ig_markets/cli/main.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 begin_session has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def begin_session(options)
              platform = options[:demo] ? :demo : :live
    
              @dealing_platform ||= DealingPlatform.new
              @dealing_platform.session.log_sinks = [$stdout] if options[:verbose]
    Severity: Minor
    Found in lib/ig_markets/cli/main.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def validate
              required = %i[currency_code direction epic guaranteed_stop level size time_in_force type]
              required.each do |attribute|
                raise ArgumentError, "#{attribute} attribute must be set" if send(attribute).nil?
              end
    Severity: Minor
    Found in lib/ig_markets/dealing_platform/working_order_methods.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 on_market_update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def on_market_update(market_update)
            market_models.each do |model|
              next unless model.market.epic == market_update.epic
    
              attributes_to_copy = { bid: :bid, high: :high, low: :low, net_change: :change, offer: :offer,
    Severity: Minor
    Found in lib/ig_markets/streaming/account_state.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 parse_date_time has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def parse_date_time(attributes, attribute, klass, format, display_format)
              return unless attributes.key? attribute
    
              if !['', attribute.to_s].include? attributes[attribute].to_s
                begin
    Severity: Minor
    Found in lib/ig_markets/cli/main.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 historical_price_result has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def historical_price_result(dealing_platform)
            market = dealing_platform.markets[options[:epic]]
    
            raise ArgumentError, 'invalid EPIC' unless market
    
    
    Severity: Minor
    Found in lib/ig_markets/cli/commands/prices_command.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_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_response(response, options)
          body = parse_body response
    
          if body.is_a?(Hash) && body.key?(:error_code)
            error = IGMarketsError.build body[:error_code]
    Severity: Minor
    Found in lib/ig_markets/session.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 build has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.build(error_code)
          if API_ERROR_CODE_TO_CLASS.key? error_code
            API_ERROR_CODE_TO_CLASS[error_code].new ''
          else
            @reported_unrecognized_error_codes ||= []
    Severity: Minor
    Found in lib/ig_markets/errors.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