unageanu/jiji2

View on GitHub

Showing 122 of 840 total issues

Consider simplifying this complex logical expression.
Open

if ENV['MONGOLAB_URI'] || ENV['MONGODB_URI']
  u = URI.parse(ENV['MONGOLAB_URI'] || ENV['MONGODB_URI'])

  config = YAML.load_file(mongoid_setting_file)['default']
  sessions = config['clients']['default']
Severity: Major
Found in src/jiji/configurations/mongoid_configuration.rb - About 1 hr to fix

    Method find_agent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_agent(source_name, m, checked, &block)
          return if checked.include? m
          return unless m
    
          checked << m
    Severity: Minor
    Found in src/jiji/model/agents/internal/agent_finder.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 convert_response_to_order_result has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def convert_response_to_order_result(res, type)
          order_opened = res['orderFillTransaction'] ? nil : convert_response_to_order(res['orderCreateTransaction'], type)
          trade_opened = nil
          trade_reduced = nil
          trades_closed = []
    Severity: Minor
    Found in src/jiji/model/securities/internal/oanda/ordering.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 find_class_by has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_class_by(root, path, name)
          mod = root
          path.each do |step|
            not_found(Agent, name: name) unless check_object_is(mod, Module)
            not_found(Agent, name: name, step: step) unless mod.const_defined? step
    Severity: Minor
    Found in src/jiji/model/agents/internal/agent_finder.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 create has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def self.create(agent, timestamp,
          backtest = nil, message = '', actions = [], note = nil, options = nil)
    Severity: Major
    Found in src/jiji/model/notification/notification.rb - About 50 mins to fix

      Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(pair1, pair2, units, distance, broker, logger = nil,
            resolver = StatisticalArbitrage::StaticConstantsResolver.new)
      Severity: Major
      Found in sample_agents/src/statistical_arbitrage_agent.rb - About 50 mins to fix

        Method build_from_tick has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def build_from_tick(internal_id, pair_name,
              units, sell_or_buy, tick, account_currency, options = {})
        Severity: Major
        Found in src/jiji/model/trading/internal/position_builder.rb - About 50 mins to fix

          Function calculateNewRange has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            calculateNewRange(start, end) {
              if (!this.range) {
                return {
                  start: start,
                  end:   end
          Severity: Minor
          Found in sites/src/js/model/trading/rates.js - 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

          Function createPageSelectorElement has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            createPageSelectorElement(selector, index) {
              if (selector.action) {
                const className = selector.selected ? "selected" : "";
                const palette = Theme.palette;
                return (
          Severity: Minor
          Found in sites/src/js/view/components/logs/log-viewer.js - 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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(name, internal_id, pip,
                max_trade_units, precision, margin_rate) #:nodoc:
          Severity: Minor
          Found in src/jiji/model/trading/pair.rb - About 45 mins to fix

            Method calculate_trailing_amount has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def calculate_trailing_amount(position, price, amount)
                  if position.sell_or_buy == :buy
                    new_price = (price - amount).to_f
                    trailing_amount&.zero? ?
                      new_price : [new_price, trailing_amount].max
            Severity: Minor
            Found in src/jiji/model/trading/closing_policy.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def initialize(target_pair, sell_or_buy = :buy, trap_interval_pips = 50,
                trade_units = 1, profit_pips = 100, logger = nil)
            Severity: Minor
            Found in sample_agents/src/trap_repeat_if_done.rb - About 45 mins to fix

              Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def initialize(backtest, agent,
                    push_notifier, mail_composer, time_source, logger) #:nodoc:
              Severity: Minor
              Found in src/jiji/model/notification/notificator.rb - About 45 mins to fix

                Method order has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def order(pair_id, sell_or_buy, units, type, options, agent)
                Severity: Minor
                Found in src/jiji/model/trading/brokers/abstract_broker.rb - About 45 mins to fix

                  Method get_or_create has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def self.get_or_create(label, type,
                        colors, axises, aggregation_type = :agerage, backtest = nil) #:nodoc:
                  Severity: Minor
                  Found in src/jiji/model/graphing/graph.rb - About 45 mins to fix

                    Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def initialize(backtest, type,
                          aggregation_type, label, colors, axises) #:nodoc:
                    Severity: Minor
                    Found in src/jiji/model/graphing/graph.rb - About 45 mins to fix

                      Method _eql? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def _eql?(other, &block)
                          return false if other.nil?
                          return true if equal? other
                          return false unless other.is_a?(Jiji::Utils::ValueObject)
                      
                      
                      Severity: Minor
                      Found in src/jiji/utils/value_object.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 initialize_trading_information has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def initialize_trading_information(position,
                            backtest, internal_id, pair_name, units, sell_or_buy)
                      Severity: Minor
                      Found in src/jiji/model/trading/internal/position_builder.rb - About 45 mins to fix

                        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def initialize(account_id, account_currency,
                              balance, margin_rate, &init) #:nodoc:
                        Severity: Minor
                        Found in src/jiji/model/trading/account.rb - About 35 mins to fix

                          Method order has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def order(pair_name, sell_or_buy, units, type = :market, options = {})
                          Severity: Minor
                          Found in src/jiji/model/securities/internal/virtual/ordering.rb - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language