Showing 12 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
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 => [] }
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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]
- Read upRead up
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={})
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!')
- Read upRead up
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 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
- Read upRead up
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 }
- Read upRead up
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?
- Read upRead up
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 }
- Read upRead up
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_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?
- Read upRead up
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"