Method get_object
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
def get_object(bucket_name, object_name, options = {}, &block)
version_id = options.delete('versionId')
unless bucket_name
raise ArgumentError.new('bucket_name is required')
- 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 byte_ranges
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def byte_ranges(http_range, size)
# See <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35>
return nil unless http_range
ranges = []
http_range.split(/,\s*/).each do |range_spec|
- 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 get_object
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_object(bucket_name, object_name, options = {}, &block)
version_id = options.delete('versionId')
unless bucket_name
raise ArgumentError.new('bucket_name is required')
Method get_object
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_object(bucket_name, object_name, options = {}, &block)
unless bucket_name
raise ArgumentError.new('bucket_name is required')
end
unless object_name
Method get_object
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_object(bucket_name, object_name, options = {}, &block)
unless bucket_name
raise ArgumentError.new('bucket_name is required')
end
unless object_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
Avoid deeply nested control flow statements. Open
case key
when 'Cache-Control', 'Content-Disposition', 'Content-Encoding', 'Content-Length', 'Content-MD5', 'Content-Type', 'ETag', 'Expires', 'Last-Modified', /^x-amz-meta-/
response.headers[key] = value
end
Avoid deeply nested control flow statements. Open
unless ranges.nil? || ranges.empty?
response.status = 206
body = body[ranges.first]
end
Avoid deeply nested control flow statements. Open
while remaining > 0
chunk = data.read([remaining, Excon::CHUNK_SIZE].min)
block.call(chunk, remaining, total_bytes)
remaining -= Excon::CHUNK_SIZE
end