unageanu/jiji2

View on GitHub

Showing 122 of 840 total issues

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

    def read_backtest_id_from(source, key = 'backtest_id', nullable = false)
      id = source[key]
      return nullable ? nil : not_nil(key) if id.nil? || id.empty?

      id == 'rmt' ? nil : BSON::ObjectId.from_string(id)
Severity: Minor
Found in src/jiji/web/services/helpers/request_parameter_reader.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 create_indexes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create_indexes
    Mongoid.models.each do |m|
      next if m.index_specifications.empty?
      next if m.embedded? && !m.cyclic?

Severity: Minor
Found in src/jiji/db/index_builder.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 carried_out? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def carried_out?(tick) #:nodoc:
      current = Utils::PricingUtils
        .calculate_entry_price(tick, pair_name, sell_or_buy)
      case @type
      when :market     then true
Severity: Minor
Found in src/jiji/model/trading/order.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

Function initializeActiveTabData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  initializeActiveTabData() {
    if (this.activeTab === "trades") {
      this.positionTable.initialize( this.selectedBacktest.id );
      this.positionTable.load();
      this.positionDownloader.initialize(this.selectedBacktest);
Severity: Minor
Found in sites/src/js/viewmodel/pages/backtests-page-model.js - 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 convert_option_value_from_oanda has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.convert_option_value_from_oanda(key, value)
      key = key.to_s
      if  value.nil?
        nil
      elsif value.is_a? Hash
Severity: Minor
Found in src/jiji/model/securities/internal/utils/converter.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 false unless yield(a[i], b[i])
Severity: Major
Found in src/jiji/utils/value_object.rb - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return <BacktestPropertiesView model={this.model()} />;
    Severity: Major
    Found in sites/src/js/view/components/backtests/backtest-details-panel.js - About 30 mins to fix

      Method collect_properties_for_modify has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def collect_properties_for_modify
            instance_variables.map { |n| n[1..-1].to_sym }.each_with_object({}) do |name, obj|
              next if name == :broker
      
              v = instance_variable_get("@#{name}")
      Severity: Minor
      Found in src/jiji/model/trading/order.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 create_mock_positions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def create_mock_positions(type)
          [
            create_mock_position(:AUDJPY, type == :sell_a ? :sell : :buy, 5000),
            create_mock_position(:NZDJPY, type == :sell_a ? :buy : :sell, 5000)
          ]
      Severity: Minor
      Found in sample_agents/spec/statistical_arbitrage/position_spec.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 get_or_create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.get_or_create(get, create)
            entity = get.call
            return entity if entity
      
            begin
      Severity: Minor
      Found in src/jiji/utils/persistence_utils.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 extract_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def extract_value(column, hash)
              if column.is_a?(Array)
                column.reduce(hash) { |a, e| a.nil? ? nil : a[e] }
              else
                hash[column]
      Severity: Minor
      Found in src/jiji/web/services/helpers/batch_download_support.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

      Function adjustStep has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        static adjustStep( step, diff ) {
          let s     = step;
          for (let count = diff/s; count > 3; count = diff/s) {
            if ( count > 10 ) {
              s = s * 10;
      Severity: Minor
      Found in sites/src/js/viewmodel/chart/candle-sticks.js - 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 rsi has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def rsi(data)
          prev = nil
          tmp = data.each_with_object([0.0, 0.0]) do |i, r|
            r[i > prev ? 0 : 1] += (i - prev).abs if prev
            prev = i
      Severity: Minor
      Found in src/jiji/model/agents/builtin_files/signals.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

      Function onPropertyChanged has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        onPropertyChanged(k, e) {
          if ( e.key === "pageWidth" ) {
            this.setState({ handleWidth: e.newValue});
          } else if ( e.key === "positionX" || e.key === "temporaryPositionX") {
            if (this.state.handlePosition != e.newValue) {
      Severity: Minor
      Found in sites/src/js/view/components/chart/slider.js - 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

      Function insertThousandsSeparator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

         static insertThousandsSeparator(price) {
            if (price === 0) return "0";
            if (!price) return "";
      
            const result = /^([\-\+]?)(\d+)(\.\d+)?$/.exec(String(price));
      Severity: Minor
      Found in sites/src/js/viewmodel/utils/number-formatter.js - 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_action has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def process_action(action, positions)
          return nil unless action =~ /trailing\_stop\_\_([a-z]+)_(.*)$/
      
          case Regexp.last_match(1)
          when 'close' then
      Severity: Minor
      Found in sample_agents/src/trailing_stop_manager.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

      Function push has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        push(event) {
          if (event.type !== "routing") {
            if (this.exist(event)) return;
              // 通信エラー等同じメッセージを複数回出しても意味がないので、
              // 同じエラーがすでにあれば登録しない
      Severity: Minor
      Found in sites/src/js/viewmodel/widgets/event-queue.js - 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 calculate_slope_signals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def calculate_slope_signals(signals, ma10, ma25, ma50)
          signals.merge!({
            slope_10: ma10 ? @ma10v.next_data(ma10) : nil,
            slope_25: ma25 ? @ma25v.next_data(ma25) : nil,
            slope_50: ma50 ? @ma50v.next_data(ma50) : nil
      Severity: Minor
      Found in sample_agents/src/tensorflow_sample_agent.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 rename_source has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def rename_source(old_name, new_name)
            return if old_name == new_name
      
            @mutex.synchronize do
              not_found(AgentSource, name: old_name) unless @agents[old_name]
      Severity: Minor
      Found in src/jiji/model/agents/agent_registry.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 validate_take_profit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_take_profit(options, sell_or_buy)
            price = options[:price]
            take_profit = options[:takeProfitOnFill]
            return if take_profit.nil?
      
      
      Severity: Minor
      Found in src/jiji/model/securities/internal/utils/order_validator.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