doximity/es-elasticity

View on GitHub

Showing 11 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                        @client.index_update_aliases(body: {
                          actions: [
                            { remove: { index: original_index, alias: @update_alias } },
                            { add:    { index: new_index, alias: @update_alias } },
                            { add:    { index: new_index, alias: @main_alias }},
              Severity: Minor
              Found in lib/elasticity/strategies/alias_index.rb and 1 other location - About 20 mins to fix
              lib/elasticity/strategies/alias_index.rb on lines 121..127

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 28.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                        @client.index_update_aliases(body: {
                          actions: [
                            { add:    { index: original_index, alias: @main_alias } },
                            { add:    { index: original_index, alias: @update_alias } },
                            { remove: { index: new_index, alias: @update_alias } },
              Severity: Minor
              Found in lib/elasticity/strategies/alias_index.rb and 1 other location - About 20 mins to fix
              lib/elasticity/strategies/alias_index.rb on lines 51..57

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 28.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language