algolia/algoliasearch-client-ruby

View on GitHub

Showing 40 of 40 total issues

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

      def clear_synonyms(opts = {})
        forward_to_replicas = false
        request_options     = symbolize_hash(opts)

        if request_options[:forwardToReplicas]
Severity: Minor
Found in lib/algolia/search_index.rb and 1 other location - About 40 mins to fix
lib/algolia/search_index.rb on lines 528..539

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 37.

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

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

      def request(call_type, method, path, body = {}, opts = {})
Severity: Minor
Found in lib/algolia/transport/transport.rb - About 35 mins to fix

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

          def converted_object_ids_after_search(event_name, index_name,
            object_ids, query_id, opts = {})
    Severity: Minor
    Found in lib/algolia/insights_client.rb - About 35 mins to fix

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

            def custom_request(data, uri, method, call_type, opts = {})
      Severity: Minor
      Found in lib/algolia/search_client.rb - About 35 mins to fix

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

              def initialize(personalization_config, opts = {})
                @config      = personalization_config
                adapter      = opts[:adapter] || Defaults::ADAPTER
                logger       = opts[:logger] || LoggerHelper.create
                requester    = opts[:http_requester] || Defaults::REQUESTER_CLASS.new(adapter, logger)
        Severity: Major
        Found in lib/algolia/personalization_client.rb and 3 other locations - About 35 mins to fix
        lib/algolia/analytics_client.rb on lines 13..18
        lib/algolia/insights_client.rb on lines 13..18
        lib/algolia/recommend_client.rb on lines 18..23

        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 36.

        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 4 locations. Consider refactoring.
        Open

              def initialize(insights_config, opts = {})
                @config      = insights_config
                adapter      = opts[:adapter] || Defaults::ADAPTER
                logger       = opts[:logger] || LoggerHelper.create
                requester    = opts[:http_requester] || Defaults::REQUESTER_CLASS.new(adapter, logger)
        Severity: Major
        Found in lib/algolia/insights_client.rb and 3 other locations - About 35 mins to fix
        lib/algolia/analytics_client.rb on lines 13..18
        lib/algolia/personalization_client.rb on lines 11..16
        lib/algolia/recommend_client.rb on lines 18..23

        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 36.

        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 4 locations. Consider refactoring.
        Open

              def initialize(recommend_config, opts = {})
                @config      = recommend_config
                adapter      = opts[:adapter] || Defaults::ADAPTER
                logger       = opts[:logger] || LoggerHelper.create
                requester    = opts[:http_requester] || Defaults::REQUESTER_CLASS.new(adapter, logger)
        Severity: Major
        Found in lib/algolia/recommend_client.rb and 3 other locations - About 35 mins to fix
        lib/algolia/analytics_client.rb on lines 13..18
        lib/algolia/insights_client.rb on lines 13..18
        lib/algolia/personalization_client.rb on lines 11..16

        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 36.

        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 4 locations. Consider refactoring.
        Open

              def initialize(analytics_config, opts = {})
                @config      = analytics_config
                adapter      = opts[:adapter] || Defaults::ADAPTER
                logger       = opts[:logger] || LoggerHelper.create
                requester    = opts[:http_requester] || Defaults::REQUESTER_CLASS.new(adapter, logger)
        Severity: Major
        Found in lib/algolia/analytics_client.rb and 3 other locations - About 35 mins to fix
        lib/algolia/insights_client.rb on lines 13..18
        lib/algolia/personalization_client.rb on lines 11..16
        lib/algolia/recommend_client.rb on lines 18..23

        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 36.

        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

        Method wait has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def wait(opts = {})
              retries_count = 1
        
              until @done
                begin
        Severity: Minor
        Found in lib/algolia/responses/update_api_key_response.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 wait has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def wait(opts = {})
              retries_count = 1
        
              until @done
                begin
        Severity: Minor
        Found in lib/algolia/responses/delete_api_key_response.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 decide has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def decide(tryable_host, http_response_code: nil, is_timed_out: false, network_failure: false)
                @lock.synchronize do
                  if !is_timed_out && success?(http_response_code)
                    tryable_host.up       = true
                    tryable_host.last_use = Time.now.utc
        Severity: Minor
        Found in lib/algolia/transport/retry_strategy.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 check_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def check_object(object, in_array = false)
            case object
            when Array
              raise Algolia::AlgoliaError, in_array ? 'argument must be an array of objects' : 'argument must not be an array'
            when String, Integer, Float, TrueClass, FalseClass, NilClass
        Severity: Minor
        Found in lib/algolia/helpers.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 wait has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def wait(opts = {})
              retries_count = 1
        
              until @done
                begin
        Severity: Minor
        Found in lib/algolia/responses/add_api_key_response.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 wait has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def wait(opts = {})
              retries_count = 1
        
              until @done
                begin
        Severity: Minor
        Found in lib/algolia/responses/restore_api_key_response.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 3 locations. Consider refactoring.
        Open

          module Analytics
            class Config < BaseConfig
              attr_accessor :region, :default_hosts
        
              # Initialize a config
        Severity: Minor
        Found in lib/algolia/config/analytics_config.rb and 2 other locations - About 20 mins to fix
        lib/algolia/config/insights_config.rb on lines 2..16
        lib/algolia/config/personalization_config.rb on lines 2..16

        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 27.

        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 3 locations. Consider refactoring.
        Open

          module Personalization
            class Config < BaseConfig
              attr_accessor :region, :default_hosts
        
              # Initialize a config
        Severity: Minor
        Found in lib/algolia/config/personalization_config.rb and 2 other locations - About 20 mins to fix
        lib/algolia/config/analytics_config.rb on lines 2..16
        lib/algolia/config/insights_config.rb on lines 2..16

        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 27.

        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 3 locations. Consider refactoring.
        Open

          module Insights
            class Config < BaseConfig
              attr_accessor :region, :default_hosts
        
              # Initialize a config
        Severity: Minor
        Found in lib/algolia/config/insights_config.rb and 2 other locations - About 20 mins to fix
        lib/algolia/config/analytics_config.rb on lines 2..16
        lib/algolia/config/personalization_config.rb on lines 2..16

        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 27.

        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 3 locations. Consider refactoring.
        Open

                rescue AlgoliaError => e
                  raise e unless e.code == 404
                  retries_count    += 1
                  time_before_retry = retries_count * Defaults::WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY
                  sleep(time_before_retry.to_f / 1000)
        Severity: Minor
        Found in lib/algolia/responses/update_api_key_response.rb and 2 other locations - About 15 mins to fix
        lib/algolia/responses/add_api_key_response.rb on lines 25..32
        lib/algolia/responses/restore_api_key_response.rb on lines 23..30

        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 26.

        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 3 locations. Consider refactoring.
        Open

                rescue AlgoliaError => e
                  if e.code != 404
                    raise e
                  end
                  retries_count    += 1
        Severity: Minor
        Found in lib/algolia/responses/add_api_key_response.rb and 2 other locations - About 15 mins to fix
        lib/algolia/responses/restore_api_key_response.rb on lines 23..30
        lib/algolia/responses/update_api_key_response.rb on lines 28..33

        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 26.

        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 3 locations. Consider refactoring.
        Open

                rescue AlgoliaError => e
                  if e.code != 404
                    raise e
                  end
                  retries_count    += 1
        Severity: Minor
        Found in lib/algolia/responses/restore_api_key_response.rb and 2 other locations - About 15 mins to fix
        lib/algolia/responses/add_api_key_response.rb on lines 25..32
        lib/algolia/responses/update_api_key_response.rb on lines 28..33

        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 26.

        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