elastic/elasticsearch-ruby

View on GitHub

Showing 83 of 233 total issues

Method perform_request has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

        def perform_request(method, path, params={}, body=nil, headers=nil, &block)
          raise NoMethodError, "Implement this method in your transport class" unless block_given?
          start = Time.now
          tries = 0

Severity: Minor
Found in elasticsearch-transport/lib/elasticsearch/transport/transport/base.rb - About 7 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 display_hits has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

        def display_hits(json, options={})
          return unless json['hits'] && json['hits']['hits']

          output = [] << ''
          hits = json['hits']['hits']
Severity: Minor
Found in elasticsearch-extensions/lib/elasticsearch/extensions/ansi/actions.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 initialize has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(arguments={}, &block)
        @options = arguments.each_with_object({}){ |(k,v), args| args[k.to_sym] = v }
        @arguments = @options
        @arguments[:logger] ||= @arguments[:log]   ? DEFAULT_LOGGER.call() : nil
        @arguments[:tracer] ||= @arguments[:trace] ? DEFAULT_TRACER.call() : nil
Severity: Minor
Found in elasticsearch-transport/lib/elasticsearch/transport/client.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 display_allocation_on_nodes has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

        def display_allocation_on_nodes(json, options={})
          return unless json['routing_nodes']

          output = [] << ''

Severity: Minor
Found in elasticsearch-extensions/lib/elasticsearch/extensions/ansi/actions.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

Class Results has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Results

      attr_reader :raw_results

      # String constant for unit of time elapsed.
Severity: Minor
Found in profile/benchmarking/results.rb - About 3 hrs to fix

    Class TaskGroup has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

            class TaskGroup
    
              attr_reader :exception
              attr_reader :response
              attr_reader :test
    Severity: Minor
    Found in api-spec-testing/test_file/task_group.rb - About 3 hrs to fix

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

            def prepare_arguments(args, test)
              symbolize_keys(args).tap do |args|
                if test
                  if args.is_a?(Hash)
                    args.each do |key, value|
      Severity: Minor
      Found in api-spec-testing/test_file/action.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 generate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

            def generate(*files)
              self.class.source_root File.expand_path('../', __FILE__)
      
              @input  = Pathname(options[:input])
              @output = Pathname(options[:output])
      Severity: Minor
      Found in elasticsearch-api/utils/thor/generate_source.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 perform_request has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def perform_request(method, path, params={}, body=nil, headers=nil, &block)
                raise NoMethodError, "Implement this method in your transport class" unless block_given?
                start = Time.now
                tries = 0
      
      
      Severity: Major
      Found in elasticsearch-transport/lib/elasticsearch/transport/transport/base.rb - About 2 hrs to fix

        Method generate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

              def generate
                self.class.source_root File.expand_path('../', __FILE__)
        
                @output = Pathname(options[:output])
        
        
        Severity: Minor
        Found in elasticsearch-api/utils/thor/generate_api.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 generate has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def generate(*files)
                self.class.source_root File.expand_path('../', __FILE__)
        
                @input  = Pathname(options[:input])
                @output = Pathname(options[:output])
        Severity: Major
        Found in elasticsearch-api/utils/thor/generate_source.rb - About 2 hrs to fix

          Method __report_unsupported_parameters has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

                def __report_unsupported_parameters(arguments, params=[])
                  messages = []
                  unsupported_params = params.select {|d| d.is_a?(Hash) ? arguments.include?(d.keys.first) : arguments.include?(d) }
          
                  unsupported_params.each do |param|
          Severity: Minor
          Found in elasticsearch-api/lib/elasticsearch/api/utils.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

          File simple.rb has 253 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'objspace'
          
          module Elasticsearch
            module Benchmarking
          
          
          Severity: Minor
          Found in profile/benchmarking/simple.rb - About 2 hrs to fix

            Method generate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def generate
                    self.class.source_root File.expand_path('../', __FILE__)
            
                    @output = Pathname(options[:output])
            
            
            Severity: Minor
            Found in elasticsearch-api/utils/thor/generate_api.rb - About 1 hr to fix

              Method perform_request has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                        def perform_request(method, path, params={}, body=nil, headers=nil)
                          super do |connection, url|
                            connection.connection.url = connection.full_url(path, params)
              
                            case method

              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 option_method has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                          def option_method(name, block=nil)
                            option_methods << name
                            if block
                              self.__send__ :define_method, name, &block
                            else
              Severity: Minor
              Found in elasticsearch-dsl/lib/elasticsearch/dsl/search/base_component.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 display_hits has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def display_hits(json, options={})
                        return unless json['hits'] && json['hits']['hits']
              
                        output = [] << ''
                        hits = json['hits']['hits']

                Method msearch has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                      def msearch(arguments={})
                        raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
                        method = HTTP_GET
                        path   = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '_msearch' )
                
                
                Severity: Minor
                Found in elasticsearch-api/lib/elasticsearch/api/actions/msearch.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 __parse_host has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                      def __parse_host(host)
                        host_parts = case host
                        when String
                          if host =~ /^[a-z]+\:\/\//
                            # Construct a new `URI::Generic` directly from the array returned by URI::split.
                Severity: Minor
                Found in elasticsearch-transport/lib/elasticsearch/transport/client.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_hash has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                        def to_hash
                          hash = {}
                          hash.update(query: @query.to_hash)   if @query
                          hash.update(filter: @filter.to_hash) if @filter
                          hash.update(post_filter: @post_filter.to_hash) if @post_filter
                Severity: Minor
                Found in elasticsearch-dsl/lib/elasticsearch/dsl/search.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

                Severity
                Category
                Status
                Source
                Language