algolia/algoliasearch-rails

View on GitHub

Showing 31 of 31 total issues

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

      Severity
      Category
      Status
      Source
      Language