Showing 17 of 17 total issues
Class TestClient
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class TestClient
attr_reader :hash_key_attr, :data, :range_key_attr, :secondary_index
def initialize(hash_key_attr, range_key_attr = nil, secondary_index=nil)
Method handle_updates
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def handle_updates(args, hash_key_value, range_key_value, attribute_hash)
table = get_table(args[:table_name])
args[:attribute_updates].each do |k, v|
if v[:action] == 'ADD' && table[hash_key_value] # if record has been saved, otherwise use a simple setter for add
data = table[hash_key_value]
- 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 build_expression_attribute_values
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def build_expression_attribute_values(args)
expression_values = {':h' => args[:hash_key]}
if current_index_range_key(args)
range_key = current_index_range_key(args)
- 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 batch_write_item
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def batch_write_item(request_options)
request_options[:request_items].each do |table_name, requests|
table = get_table(table_name)
requests.each do |request_hash|
- 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 split
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def split(attribute_updates)
unprocessed_au = attribute_updates.map { |k, v| {k => v} }
updates = []
current_update_size = 0
current_update = {}
- 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 split
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def split(attribute_updates)
unprocessed_au = attribute_updates.map { |k, v| {k => v} }
updates = []
current_update_size = 0
current_update = {}
Method save!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def save!(options = {})
run_callbacks :save do
options[:validate] = true if options[:validate].nil?
unless @changes.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 index_of_start_key
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def index_of_start_key(args, records)
if args[:exclusive_start_key]
sec_index = secondary_index && secondary_index[args[:secondary_index_name]]
start_index = records.index do |r|
if sec_index
- 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 find
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def find(hash_value, range_value = nil)
fail ArgumentError, 'Hash key cannot be nil or empty.' if (hash_value.nil? || hash_value.blank?)
fail 'Range key cannot be blank.' if range_key && range_value.nil?
response = client.get_item(table_name: table_name, key: create_key_hash(hash_value, range_value))
- 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 attribute_updates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def attribute_updates
changes.reduce({}) do |updates, (key, value)|
# TODO: remove this ternary once aws-sdk accepts empty set pull request
current_value = value[1].is_a?(Set) && value[1].empty? ? nil : value[1]
updates[key] = { action: value[2] || 'PUT' }
- 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 sort_records
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def sort_records(records, index, args, start_val, end_val)
Method add_to
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_to(attribute, value)
complain_about(attribute) unless self.class.handles[attribute]
old_value = read_attribute(attribute)
add_value = self.class.attribute_callback(TypeHandler::SETTER_PROCS, self.class.handles[attribute], value, true)
if ADDABLE_TYPES.include? self.class.handles[attribute][:format]
- 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 validate_scan_options
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_scan_options(options)
if options[:total_segments] && !options[:segment]
raise ArgumentError, 'Must specify segment if specifying total_segments'
elsif options[:segment] && !options[:total_segments]
raise ArgumentError, 'Must specify total_segments if specifying segment'
- 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 dynamo_scan
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def dynamo_scan(options)
if options[:start_key] && !options[:start_key].is_a?(Hash)
if options[:index_name]
attr = secondary_index[options[:index_name]][:hash_key_name].to_s
start_key = { attr => options[:start_key] }
- 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 batch_get_item
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def batch_get_item(args = {})
responses = {}
args[:request_items].each do |table_name, get_request|
responses[table_name] = []
- 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 inspect_for_correct_keys?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def inspect_for_correct_keys?(tokens, hash_key_name, range_key_name)
missed_keys = []
missed_keys << hash_key_name unless tokens[0] == hash_key_name
missed_keys << range_key_name unless (tokens.length < 4 || tokens[4] == range_key_name)
raise missed_key_dynamodb_error(missed_keys) if missed_keys.length > 0
- 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 read_attribute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def read_attribute(name)
value = @attributes[name]
if (handle = self.class.handles[name.to_sym])
value = handle[:options][:default] if value.nil?
value = self.class.attribute_callback(TypeHandler::GETTER_PROCS, handle, value, false) unless value.nil?
- 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"