openjaf/cenit

View on GitHub
app/models/setup/flow.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method validates_configuration has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
Open

    def validates_configuration
      format_triggers_on(:scope_filter) if scope_filter.present?
      unless requires(:name, :translator)
        if event.present?
          unless translator.type == :Import || requires(:data_type_scope)
Severity: Minor
Found in app/models/setup/flow.rb - About 1 day 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 flow.rb has 537 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'nokogiri'

module Setup
  class Flow
    # = Flow
Severity: Major
Found in app/models/setup/flow.rb - About 1 day to fix

    Method translate_export has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        def translate_export(message, &block)
          limit = translator.try(:bulk_source) ? lot_size || 1000 : 1
          source_scope = sources(message)
          max = source_scope.count - 1
          translation_options = nil
    Severity: Minor
    Found in app/models/setup/flow.rb - About 6 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

    Method simple_translate has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def simple_translate(message, &block)
          unless (options = message[:options]).is_a?(Hash)
            options = {}
          end
          task = message[:task]
    Severity: Minor
    Found in app/models/setup/flow.rb - About 4 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

    Method source_ids_from has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def source_ids_from(message)
          if (object_ids = message[:object_ids])
            object_ids
          elsif (id = message[:source_id])
            [id]
    Severity: Minor
    Found in app/models/setup/flow.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

    Class Flow has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Flow
        # = Flow
        #
        # Defines how data is processed by the execution of one or more actions.
    
    
    Severity: Minor
    Found in app/models/setup/flow.rb - About 3 hrs to fix

      Method validates_configuration has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def validates_configuration
            format_triggers_on(:scope_filter) if scope_filter.present?
            unless requires(:name, :translator)
              if event.present?
                unless translator.type == :Import || requires(:data_type_scope)
      Severity: Major
      Found in app/models/setup/flow.rb - About 3 hrs to fix

        Method translate_export has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def translate_export(message, &block)
              limit = translator.try(:bulk_source) ? lot_size || 1000 : 1
              source_scope = sources(message)
              max = source_scope.count - 1
              translation_options = nil
        Severity: Major
        Found in app/models/setup/flow.rb - About 3 hrs to fix

          Method translate_import has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def translate_import(message, &block)
                options =
                  {
                    headers: message['headers'] || {},
                    parameters: message['parameters'] || {},
          Severity: Minor
          Found in app/models/setup/flow.rb - About 2 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

          Method simple_translate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def simple_translate(message, &block)
                unless (options = message[:options]).is_a?(Hash)
                  options = {}
                end
                task = message[:task]
          Severity: Minor
          Found in app/models/setup/flow.rb - About 1 hr to fix

            Method translate_import has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def translate_import(message, &block)
                  options =
                    {
                      headers: message['headers'] || {},
                      parameters: message['parameters'] || {},
            Severity: Minor
            Found in app/models/setup/flow.rb - About 1 hr to fix

              Method source_ids_from has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def source_ids_from(message)
                    if (object_ids = message[:object_ids])
                      object_ids
                    elsif (id = message[:source_id])
                      [id]
              Severity: Minor
              Found in app/models/setup/flow.rb - About 1 hr to fix

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

                    def selector_from(message)
                      if (selector = message[:selector])
                        if selector.is_a?(Hash) || selector.is_a?(Array)
                          selector
                        else
                Severity: Minor
                Found in app/models/setup/flow.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 translate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def translate(message, &block)
                      if translator.present?
                        begin
                          flow_execution = current_thread_cache
                          flow_execution << (message[:execution_graph] || {}).merge('trigger_flow_id' => id.to_s)
                Severity: Minor
                Found in app/models/setup/flow.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

                Avoid deeply nested control flow statements.
                Open

                                unless scope_evaluator.parameters.first.name == 'scope'
                                  errors.add(:scope_evaluator, "argument name should be 'scope'")
                                end
                Severity: Major
                Found in app/models/setup/flow.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                if response_translator.data_type
                                  rejects(:response_data_type)
                                else
                                  requires(:response_data_type)
                                end
                  Severity: Major
                  Found in app/models/setup/flow.rb - About 45 mins to fix

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

                        def process(message = {}, &block)
                          execution_graph = current_thread_cache.last || {}
                          if (trigger_flow_id = execution_graph['trigger_flow_id'])
                            execution_graph[trigger_flow_id] ||= []
                            adjacency_list = execution_graph[trigger_flow_id]
                    Severity: Minor
                    Found in app/models/setup/flow.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 scope_symbol has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def scope_symbol
                          if data_type_scope.present?
                            if data_type_scope.start_with?('Event')
                              :event_source
                            elsif data_type_scope.start_with?('Filter')
                    Severity: Minor
                    Found in app/models/setup/flow.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

                    There are no issues that match your filters.

                    Category
                    Status