grantr/rubberband

View on GitHub

Showing 16 of 16 total issues

Method request has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def request(method, operation, params={}, body=nil)
        begin
          uri = generate_uri(operation)
          #puts "request: #{@server} #{method} #{uri} #{params.inspect} #{body}"
          request = ElasticSearch::Thrift::RestRequest.new
Severity: Minor
Found in lib/elasticsearch/transport/thrift.rb - About 1 hr to fix

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

            def alias_index(operations, options={})
              if operations[:actions]
                alias_ops = operations
              else
                alias_ops = { :actions => [] }
    Severity: Minor
    Found in lib/elasticsearch/client/admin_index.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 search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def search(query, options={})
            index, type, options = extract_scope(options)
    
            options[:size] ||= (options[:per_page] || options[:limit]) if options[:per_page] || options[:limit]
            options[:from] ||= options[:size] * (options[:page].to_i-1) if options[:page] && options[:page].to_i > 1
    Severity: Minor
    Found in lib/elasticsearch/client/index.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 request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def request(method, operation, params={}, body=nil)
            begin
              uri = generate_uri(operation)
              #puts "request: #{@server} #{method} #{uri} #{params.inspect} #{body}"
              request = ElasticSearch::Thrift::RestRequest.new
    Severity: Minor
    Found in lib/elasticsearch/transport/thrift.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 extract_indices_and_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def extract_indices_and_options(args)
              options = args.last.is_a?(Hash) ? args.pop : {}
              indices = args.empty? ? [(default_index || :all)] : args.flatten
              indices.collect! { |i| PSEUDO_INDICES.include?(i) ? "_#{i}" : i }
              [indices, options]
    Severity: Minor
    Found in lib/elasticsearch/client/admin_index.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 index has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def index(index, type, id, document, options={})
    Severity: Minor
    Found in lib/elasticsearch/transport/base_protocol.rb - About 35 mins to fix

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

              def shutdown_nodes(*args)
                options = args.last.is_a?(Hash) ? args.pop : {}
                return false if args.empty?
                nodes = args.flatten
                nodes.collect! { |n| PSEUDO_NODES.include?(n) ? "_#{n}" : n }
      Severity: Minor
      Found in lib/elasticsearch/client/admin_cluster.rb and 1 other location - About 35 mins to fix
      lib/elasticsearch/client/admin_cluster.rb on lines 46..51

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

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

            def index(index, type, id, document, options={})
              body = encoder.is_encoded?(document) ? document : encoder.encode(document)
              if id.nil?
                response = request(:post, {:index => index, :type => type}, options, body)
              else
      Severity: Minor
      Found in lib/elasticsearch/transport/base_protocol.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 validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                def validate
                  raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field method is unset!') unless @method
                  raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field uri is unset!') unless @uri
                  unless @method.nil? || ElasticSearch::Thrift::Method::VALID_VALUES.include?(@method)
                    raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field method!')
      Severity: Minor
      Found in lib/elasticsearch/transport/thrift/elasticsearch_types.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

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

              def restart_nodes(*args)
                options = args.last.is_a?(Hash) ? args.pop : {}
                return false if args.empty?
                nodes = args.flatten
                nodes.collect! { |n| PSEUDO_NODES.include?(n) ? "_#{n}" : n }
      Severity: Minor
      Found in lib/elasticsearch/client/admin_cluster.rb and 1 other location - About 35 mins to fix
      lib/elasticsearch/client/admin_cluster.rb on lines 35..40

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

      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

              if query.is_a?(Hash)
                # Some http libraries cannot submit get requests with content, so if query is a hash, post it instead (assume a query hash is using the query dsl)
                response = request(:get, {:index => index, :type => type, :op => "_search"}, options, encoder.encode(query))
              else
                response = request(:get, {:index => index, :type => type, :op => "_search"}, options.merge(:q => query))
      Severity: Minor
      Found in lib/elasticsearch/transport/base_protocol.rb and 1 other location - About 30 mins to fix
      lib/elasticsearch/transport/base_protocol.rb on lines 76..80

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

      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

              if query.is_a?(Hash)
                # Some http libraries cannot submit get requests with content, so if query is a hash, post it instead (assume a query hash is using the query dsl)
                response = request(:post, {:index => index, :type => type, :op => "_count"}, options, encoder.encode(query))
              else
                response = request(:get, {:index => index, :type => type, :op => "_count"}, options.merge(:q => query))
      Severity: Minor
      Found in lib/elasticsearch/transport/base_protocol.rb and 1 other location - About 30 mins to fix
      lib/elasticsearch/transport/base_protocol.rb on lines 46..50

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

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

          def next_server
            if @retry_period
              rebuild_live_server_list! if Time.now > @last_rebuild + @retry_period
              raise NoServersAvailable, "No live servers in #{@servers.inspect} since #{@last_rebuild.inspect}." if @live_server_list.empty?
            elsif @live_server_list.empty?
      Severity: Minor
      Found in lib/elasticsearch/client/retrying_client.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 shutdown_nodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def shutdown_nodes(*args)
                options = args.last.is_a?(Hash) ? args.pop : {}
                return false if args.empty?
                nodes = args.flatten
                nodes.collect! { |n| PSEUDO_NODES.include?(n) ? "_#{n}" : n }
      Severity: Minor
      Found in lib/elasticsearch/client/admin_cluster.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 restart_nodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def restart_nodes(*args)
                options = args.last.is_a?(Hash) ? args.pop : {}
                return false if args.empty?
                nodes = args.flatten
                nodes.collect! { |n| PSEUDO_NODES.include?(n) ? "_#{n}" : n }
      Severity: Minor
      Found in lib/elasticsearch/client/admin_cluster.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 generate_uri has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def generate_uri(options)
              path = ""
              path << "/#{Array(options[:index]).collect { |i| escape(i.downcase) }.join(",")}" if options[:index] && !options[:index].empty?
              path << "/*" if options[:index] && options[:index].empty?
              path << "/#{Array(options[:type]).collect { |t| escape(t) }.join(",")}" if options[:type] && !options[:type].empty?
      Severity: Minor
      Found in lib/elasticsearch/transport/base_protocol.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