printercu/elastics-rb

View on GitHub

Showing 10 of 10 total issues

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

    def request_with_auto_refresh(params)
      request_without_auto_refresh(params).tap do
        next unless AutoRefresh.enabled?
        next if SKIP_IDS.include?(params[:id].to_s.downcase)
        next unless METHODS.include?(params[:method].to_s.downcase)
Severity: Minor
Found in lib/elastics/auto_refresh.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 configure has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def configure(config, tag = :elastics)
      migrated = false
      error = nil
      config.around tag => true do |ex|
        if migrated
Severity: Minor
Found in lib/elastics/rspec.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 next_cluster_host has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def next_cluster_host
          if @resurrect_at
            time = Time.now.to_i
            resurrect_cluster(time) if @resurrect_at <= time
          end
Severity: Minor
Found in lib/elastics/client/cluster.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 http_request has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def http_request(method, path, query, body, params = nil, host = @host)
Severity: Minor
Found in lib/elastics/client.rb - About 45 mins to fix

    Method http_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def http_request(event)
              return unless logger.debug?
    
              payload = event.payload[:args]
              method, path, query, body, params = payload
    Severity: Minor
    Found in lib/elastics/instrumentation/active_support.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 request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def request(params = {})
          method = params[:method] || :get
          body = params[:body]
          body = body.to_json if body && !body.is_a?(String)
          res = http_request(method, request_path(params), params[:query], body, params)
    Severity: Minor
    Found in lib/elastics/client.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 models_to_reindex has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def models_to_reindex(options = {})
            indices = options[:indices].try!(:map, &:to_s)
            types = options[:types].try!(:map, &:to_s)
            models = Model.list.select do |model|
              next if indices && !indices.include?(model.elastics_index_base)
    Severity: Minor
    Found in lib/elastics/tasks/migrations.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 http_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def http_request(method, path, query, body, params = nil)
    Severity: Minor
    Found in lib/elastics/client/cluster.rb - About 35 mins to fix

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

              def reindex_elastics(options = {})
                scope = respond_to?(:reindex_scope) ? reindex_scope : all
                if after = options.delete(:updated_after)
                  if updated_at = arel_table[:updated_at]
                    scope = scope.where(updated_at.gt(after))
      Severity: Minor
      Found in lib/elastics/active_record/helper_methods.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 create_indices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def create_indices(options = {})
              version = options.fetch :version, :current
              each_filtered(indices, options[:indices]) do |index|
                versioned_index = versioned_index_name(index, version)
                exists = client.index_exists?(versioned_index)
      Severity: Minor
      Found in lib/elastics/tasks/indices.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