File downloader.rb
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'fileutils'
require 'open3'
require 'uri'
require_relative './exceptions'
require_relative './source_file'
Class Downloader
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Downloader
include CartoDB::Importer2::QuotaCheckHelpers, Carto::UrlValidator, Carto::FilenameGenerator
def self.supported_extensions
@supported_extensions ||= CartoDB::Importer2::Unp::SUPPORTED_FORMATS
Method bound_request
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def bound_request(file)
request = http_client.request(@translated_url, typhoeus_options)
request.on_headers do |response|
@http_response_code = response.code
- 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 raise_error_for_response
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def raise_error_for_response(response)
if response.timed_out?
raise DownloadTimeoutError.new("TIMEOUT ERROR: Body:#{response.body}")
elsif response.headers['Error'] && response.headers['Error'] =~ /too many nodes/
raise TooManyNodesError.new(response.headers['Error'])
- 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 translate_url
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def translate_url(url)
translator = supported_translator(url)
raw_url = if translator
if translator.respond_to?(:rename_destination)
- 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 filename_from_headers
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def filename_from_headers
return nil unless headers
disposition = headers['Content-Disposition']
return false unless disposition
- 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 last_modified
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def last_modified
return @last_modified if @last_modified
return nil unless headers
header_last_modified = headers['Last-Modified']
- 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 run
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def run(_available_quota_in_bytes = nil)
if @translated_url.include?('://')
raise_if_over_storage_quota(requested_quota: content_length || 0,
available_quota: size_limit_in_bytes,
user_id: @user.id)
- 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"