elastic/elasticsearch-ruby

View on GitHub

Showing 233 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

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

            module DSL
              module Search
                module Queries
          
                  # A query which wraps another query or filter and returns a constant score for matching documents
          elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/filtered.rb on lines 19..87

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

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

            module DSL
              module Search
                module Queries
          
                  # A query which allows to combine a query with a filter
          elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/constant_score.rb on lines 19..76

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

          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

          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

                Severity
                Category
                Status
                Source
                Language