File user_agent.rb
has 463 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'net/http'
require 'net/https'
require 'net/ftp'
class UserAgent
Method get_http
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def self.get_http(uri, options)
proxy = options['proxy'] || Setting.get('proxy')
proxy_no = options['proxy_no'] || Setting.get('proxy_no') || ''
proxy_no = proxy_no.split(',').map(&:strip) || []
- 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 process
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.process(request, response, uri, count, params, options) # rubocop:disable Metrics/ParameterLists
log(uri.to_s, request, response, options)
if !response
return Result.new(
Method log
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.log(url, request, response, options)
return if !options[:log]
# request
request_data = {
Method ftp
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.ftp(uri, options)
host = uri.host
filename = File.basename(uri.path)
remote_dir = File.dirname(uri.path)
Method get_http
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_http(uri, options)
proxy = options['proxy'] || Setting.get('proxy')
proxy_no = options['proxy_no'] || Setting.get('proxy_no') || ''
proxy_no = proxy_no.split(',').map(&:strip) || []
Method ftp
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.ftp(uri, options)
host = uri.host
filename = File.basename(uri.path)
remote_dir = File.dirname(uri.path)
- 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 process
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.process(request, response, uri, count, params, options) # rubocop:disable Metrics/ParameterLists
Method set_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.set_params(request, params, options)
if options[:json]
if !request.is_a?(Net::HTTP::Get) # GET requests pass params in query, see 'parse_uri'.
request.add_field('Content-Type', 'application/json; charset=utf-8')
if params.present?
- 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 process
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.process(request, response, uri, count, params, options) # rubocop:disable Metrics/ParameterLists
log(uri.to_s, request, response, options)
if !response
return Result.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
Avoid too many return
statements within this method. Open
return get(url, params, options, count - 1)
Avoid too many return
statements within this method. Open
return Result.new(
data: data,
body: response.body,
content_type: response['Content-Type'],
success: true,
Method log
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.log(url, request, response, options)
return if !options[:log]
# request
request_data = {
- 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 handled_open_timeout
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.handled_open_timeout(tries)
tries ||= 1
tries.times do |index|
yield
- 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"