doximity/es-elasticity

View on GitHub

Showing 9 of 11 total issues

Method remap has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

      def remap(index_def, retry_delete_on_recoverable_errors: false, retry_delay: 0, max_delay: 0)
        main_indexes   = self.main_indexes
        update_indexes = self.update_indexes

        if main_indexes.size != 1 || update_indexes.size != 1 || main_indexes != update_indexes
Severity: Minor
Found in lib/elasticity/strategies/alias_index.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 remap has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def remap(index_def, retry_delete_on_recoverable_errors: false, retry_delay: 0, max_delay: 0)
        main_indexes   = self.main_indexes
        update_indexes = self.update_indexes

        if main_indexes.size != 1 || update_indexes.size != 1 || main_indexes != update_indexes
Severity: Major
Found in lib/elasticity/strategies/alias_index.rb - About 3 hrs to fix

    Class AliasIndex has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class AliasIndex
          SNAPSHOT_ERROR_SNIPPET =  "Cannot delete indices that are being snapshotted"
          RETRYABLE_ERROR_SNIPPETS = [
            SNAPSHOT_ERROR_SNIPPET
          ].freeze
    Severity: Minor
    Found in lib/elasticity/strategies/alias_index.rb - About 3 hrs to fix

      File search.rb has 268 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Elasticity
        module Search
          def self.build(client, index_name, document_types, body, search_args = {})
            search_def = Search::Definition.new(index_name, document_types, body, search_args)
            Search::Facade.new(client, search_def)
      Severity: Minor
      Found in lib/elasticity/search.rb - About 2 hrs to fix

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

            def self.build(client, index_name, document_types, body, search_args = {})
        Severity: Minor
        Found in lib/elasticity/search.rb - About 35 mins to fix

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

                def initialize(client, index_base_name, document_type, use_new_timestamp_format = nil, include_type_name_on_create = nil)
          Severity: Minor
          Found in lib/elasticity/strategies/alias_index.rb - About 35 mins to fix

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

                  def initialize(client, index_name, document_type, use_new_timestamp_format = nil, include_type_name_on_create = nil)
            Severity: Minor
            Found in lib/elasticity/strategies/single_index.rb - About 35 mins to fix

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

                  def log_event(event)
                    bt = event.payload[:backtrace]
              
                    if bt.present? && defined?(Rails)
                      bt = Rails.backtrace_cleaner.clean(bt)
              Severity: Minor
              Found in lib/elasticity/log_subscriber.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 map_hit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def map_hit(hit)
                    attrs = { _id: hit["_id"] }
                    attrs.merge!(_score: hit["_score"])
                    attrs.merge!(sort: hit["sort"])
                    attrs.merge!(hit["_source"]) if hit["_source"]
              Severity: Minor
              Found in lib/elasticity/index_mapper.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