algolia/algoliasearch-rails

View on GitHub
lib/algoliasearch-rails.rb

Summary

Maintainability
F
1 wk
Test Coverage

File algoliasearch-rails.rb has 847 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'algolia'

require 'algoliasearch/version'
require 'algoliasearch/utilities'

Severity: Major
Found in lib/algoliasearch-rails.rb - About 2 days to fix

    Method algoliasearch has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        def algoliasearch(options = {}, &block)
          self.algoliasearch_settings = IndexSettings.new(options, &block)
          self.algoliasearch_options = { :type => algolia_full_const_get(model_name.to_s), :per_page => algoliasearch_settings.get_setting(:hitsPerPage) || 10, :page => 1 }.merge(options)
    
          attr_accessor :highlight_result, :snippet_result
    Severity: Minor
    Found in lib/algoliasearch-rails.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 extended has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.extended(base)
          class <<base
            alias_method :without_auto_index, :algolia_without_auto_index unless method_defined? :without_auto_index
            alias_method :reindex!, :algolia_reindex! unless method_defined? :reindex!
            alias_method :reindex, :algolia_reindex unless method_defined? :reindex
    Severity: Minor
    Found in lib/algoliasearch-rails.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 algoliasearch has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def algoliasearch(options = {}, &block)
          self.algoliasearch_settings = IndexSettings.new(options, &block)
          self.algoliasearch_options = { :type => algolia_full_const_get(model_name.to_s), :per_page => algoliasearch_settings.get_setting(:hitsPerPage) || 10, :page => 1 }.merge(options)
    
          attr_accessor :highlight_result, :snippet_result
    Severity: Major
    Found in lib/algoliasearch-rails.rb - About 3 hrs to fix

      Method algolia_index! has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def algolia_index!(object, synchronous = false)
            return if algolia_without_auto_index_scope
            algolia_configurations.each do |options, settings|
              next if algolia_indexing_disabled?(options)
              object_id = algolia_object_id_of(object, options)
      Severity: Minor
      Found in lib/algoliasearch-rails.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

      Method algolia_reindex has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def algolia_reindex(batch_size = AlgoliaSearch::IndexSettings::DEFAULT_BATCH_SIZE, synchronous = false)
            return if algolia_without_auto_index_scope
            algolia_configurations.each do |options, settings|
              next if algolia_indexing_disabled?(options)
              next if options[:replica]
      Severity: Minor
      Found in lib/algoliasearch-rails.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 algolia_reindex! has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def algolia_reindex!(batch_size = AlgoliaSearch::IndexSettings::DEFAULT_BATCH_SIZE, synchronous = false)
            return if algolia_without_auto_index_scope
            algolia_configurations.each do |options, settings|
              next if algolia_indexing_disabled?(options)
              index = algolia_ensure_init(options, settings)
      Severity: Minor
      Found in lib/algoliasearch-rails.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 algolia_must_reindex? has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def algolia_must_reindex?(object)
            # use +algolia_dirty?+ method if implemented
            return object.send(:algolia_dirty?) if (object.respond_to?(:algolia_dirty?))
            # Loop over each index to see if a attribute used in records has changed
            algolia_configurations.each do |options, settings|
      Severity: Minor
      Found in lib/algoliasearch-rails.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 algolia_ensure_init has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def algolia_ensure_init(options = nil, settings = nil, index_settings = nil)
            raise ArgumentError.new('No `algoliasearch` block found in your model.') if algoliasearch_settings.nil?
      
            @algolia_indexes ||= {}
      
      
      Severity: Minor
      Found in lib/algoliasearch-rails.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 algoliasearch_settings_changed? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def algoliasearch_settings_changed?(prev, current)
            return true if prev.nil?
            current.each do |k, v|
              prev_v = prev[k.to_s]
              if v.is_a?(Array) and prev_v.is_a?(Array)
      Severity: Minor
      Found in lib/algoliasearch-rails.rb - About 1 hr 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 algolia_remove_from_index! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def algolia_remove_from_index!(object, synchronous = false)
            return if algolia_without_auto_index_scope
            object_id = algolia_object_id_of(object)
            raise ArgumentError.new("Cannot index a record with a blank objectID") if object_id.blank?
            algolia_configurations.each do |options, settings|
      Severity: Minor
      Found in lib/algoliasearch-rails.rb - About 1 hr 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 algolia_reindex has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def algolia_reindex(batch_size = AlgoliaSearch::IndexSettings::DEFAULT_BATCH_SIZE, synchronous = false)
            return if algolia_without_auto_index_scope
            algolia_configurations.each do |options, settings|
              next if algolia_indexing_disabled?(options)
              next if options[:replica]
      Severity: Minor
      Found in lib/algoliasearch-rails.rb - About 1 hr to fix

        Method algolia_find_in_batches has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def algolia_find_in_batches(batch_size, &block)
              if (defined?(::ActiveRecord) && ancestors.include?(::ActiveRecord::Base)) || respond_to?(:find_in_batches)
                find_in_batches(:batch_size => batch_size, &block)
              elsif defined?(::Sequel) && defined?(::Sequel::Model) && self < Sequel::Model
                dataset.extension(:pagination).each_page(batch_size, &block)
        Severity: Minor
        Found in lib/algoliasearch-rails.rb - About 1 hr 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 to_settings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_settings
              settings = {}
              OPTIONS.each do |k|
                v = get_setting(k)
                settings[k] = v if !v.nil?
        Severity: Minor
        Found in lib/algoliasearch-rails.rb - About 1 hr 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 algolia_search has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def algolia_search(q, params = {})
              if AlgoliaSearch.configuration[:pagination_backend]
                # kaminari, will_paginate, and pagy start pagination at 1, Algolia starts at 0
                params[:page] = (params.delete('page') || params.delete(:page)).to_i
                params[:page] -= 1 if params[:page].to_i > 0
        Severity: Minor
        Found in lib/algoliasearch-rails.rb - About 1 hr 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_attributes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_attributes(object)
              # If a serializer is set, we ignore attributes
              # everything should be done via the serializer
              if not @serializer.nil?
                attributes = @serializer.new(object).attributes
        Severity: Minor
        Found in lib/algoliasearch-rails.rb - About 1 hr 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 algolia_search has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def algolia_search(q, params = {})
              if AlgoliaSearch.configuration[:pagination_backend]
                # kaminari, will_paginate, and pagy start pagination at 1, Algolia starts at 0
                params[:page] = (params.delete('page') || params.delete(:page)).to_i
                params[:page] -= 1 if params[:page].to_i > 0
        Severity: Minor
        Found in lib/algoliasearch-rails.rb - About 1 hr to fix

          Method get_attributes has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def get_attributes(object)
                # If a serializer is set, we ignore attributes
                # everything should be done via the serializer
                if not @serializer.nil?
                  attributes = @serializer.new(object).attributes
          Severity: Minor
          Found in lib/algoliasearch-rails.rb - About 1 hr to fix

            Method algolia_clear_index! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def algolia_clear_index!(synchronous = false)
                  algolia_configurations.each do |options, settings|
                    next if algolia_indexing_disabled?(options)
                    index = algolia_ensure_init(options, settings)
                    next if options[:replica]
            Severity: Minor
            Found in lib/algoliasearch-rails.rb - About 1 hr 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 algolia_index_objects has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def algolia_index_objects(objects, synchronous = false)
                  algolia_configurations.each do |options, settings|
                    next if algolia_indexing_disabled?(options)
                    index = algolia_ensure_init(options, settings)
                    next if options[:replica]
            Severity: Minor
            Found in lib/algoliasearch-rails.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 algolia_attribute_changed? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def algolia_attribute_changed?(object, attr_name, default)
                  # if one of two method is implemented, we return its result
                  # true/false means whether it has changed or not
                  # +#{attr_name}_changed?+ always defined for automatic attributes but deprecated after Rails 5.2
                  # +will_save_change_to_#{attr_name}?+ should be use instead for Rails 5.2+, also defined for automatic attributes.
            Severity: Minor
            Found in lib/algoliasearch-rails.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 tags has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def tags(*args, &block)
                  raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:replica]
                  add_attribute :_tags do |o|
                    v = block_given? ? o.instance_eval(&block) : args
                    v.is_a?(Array) ? v : [v]
            Severity: Minor
            Found in lib/algoliasearch-rails.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 add_attribute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def add_attribute(*names, &block)
                  raise ArgumentError.new('Cannot pass multiple attribute names if block given') if block_given? and names.length > 1
                  raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:replica]
                  @additional_attributes ||= {}
                  names.each do |name|
            Severity: Minor
            Found in lib/algoliasearch-rails.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 algolia_full_const_get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def algolia_full_const_get(name)
                  list = name.split('::')
                  list.shift if list.first.blank?
                  obj = Object.const_defined?(:RUBY_VERSION) && RUBY_VERSION.to_f < 1.9 ? Object : self
                  list.each do |x|
            Severity: Minor
            Found in lib/algoliasearch-rails.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 attribute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def attribute(*names, &block)
                  raise ArgumentError.new('Cannot pass multiple attribute names if block given') if block_given? and names.length > 1
                  raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:replica]
                  @attributes ||= {}
                  names.flatten.each do |name|
            Severity: Minor
            Found in lib/algoliasearch-rails.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 true
            Severity: Major
            Found in lib/algoliasearch-rails.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return false
              Severity: Major
              Found in lib/algoliasearch-rails.rb - About 30 mins to fix

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

                    def self.log_or_throw(method, raise_on_failure, &block)
                      begin
                        yield
                      rescue Algolia::AlgoliaError => e
                        raise e if raise_on_failure
                Severity: Minor
                Found in lib/algoliasearch-rails.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 algolia_set_settings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def algolia_set_settings(synchronous = false)
                      algolia_configurations.each do |options, settings|
                        if options[:primary_settings] && options[:inherit]
                          primary = options[:primary_settings].to_settings
                          primary.delete :replicas
                Severity: Minor
                Found in lib/algoliasearch-rails.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 algolia_enqueue_remove_from_index! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def algolia_enqueue_remove_from_index!(synchronous)
                      if algoliasearch_options[:enqueue]
                        algoliasearch_options[:enqueue].call(self, true) unless self.class.send(:algolia_indexing_disabled?, algoliasearch_options)
                      else
                        algolia_remove_from_index!(synchronous || algolia_synchronous?)
                Severity: Minor
                Found in lib/algoliasearch-rails.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 included has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.included(base)
                      base.instance_eval do
                        alias_method :index!, :algolia_index! unless method_defined? :index!
                        alias_method :remove_from_index!, :algolia_remove_from_index! unless method_defined? :remove_from_index!
                      end
                Severity: Minor
                Found in lib/algoliasearch-rails.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

                There are no issues that match your filters.

                Category
                Status