File connection.rb
has 551 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'terminal-table'
require 'securerandom'
require 'monitor'
require 'thread_safe'
require 'rest-client'
Class Connection
has 38 methods (exceeds 20 allowed). Consider refactoring. Open
class Connection
include MonitorMixin
HTTPS_PROTOCOL = 'https://'
HTTP_PROTOCOL = 'http://'
Method process_response
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def process_response(options = {}, &block)
retries = options[:tries] || Helpers::GD_MAX_RETRY
process = options[:process]
dont_reauth = options[:dont_reauth]
options = options.reject { |k, _| [:process, :dont_reauth].include?(k) }
- 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 connect
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def connect(username, password, options = {})
server = options[:server] || Helpers::AuthHelper.read_server
options = DEFAULT_LOGIN_PAYLOAD.merge(options)
headers = options[:headers] || {}
- 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 retryable
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def retryable(options = {}, &_block)
opts = { :tries => 12, :on => RETRYABLE_ERRORS }.merge(options)
retry_exception = opts[:on]
retries = opts[:tries]
- 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 download
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def download(what, where, options = {})
# handle the path (directory) given in what
ilast_slash = what.rindex('/')
if ilast_slash.nil?
what_dir = ''
- 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 connect
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def connect(username, password, options = {})
server = options[:server] || Helpers::AuthHelper.read_server
options = DEFAULT_LOGIN_PAYLOAD.merge(options)
headers = options[:headers] || {}
Method download
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def download(what, where, options = {})
# handle the path (directory) given in what
ilast_slash = what.rindex('/')
if ilast_slash.nil?
what_dir = ''
Method process_response
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_response(options = {}, &block)
retries = options[:tries] || Helpers::GD_MAX_RETRY
process = options[:process]
dont_reauth = options[:dont_reauth]
options = options.reject { |k, _| [:process, :dont_reauth].include?(k) }
Method stats_table
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def stats_table(values = stats)
sorted = values.sort_by { |_k, v| v[:avg] }
Terminal::Table.new :headings => %w(title avg min max total calls) do |t|
overall = {
:avg => 0,
Method add_stat_record
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_stat_record(method, path, delta, time_stamp, request_id)
synchronize do
orig_title = "#{method.to_s.upcase} #{path}"
title = "#{method.to_s.upcase} #{path}"
Method retryable
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def retryable(options = {}, &_block)
opts = { :tries => 12, :on => RETRYABLE_ERRORS }.merge(options)
retry_exception = opts[:on]
retries = opts[:tries]
Method add_stat_record
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_stat_record(method, path, delta, time_stamp, request_id)
synchronize do
orig_title = "#{method.to_s.upcase} #{path}"
title = "#{method.to_s.upcase} #{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 add_stat_record
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_stat_record(method, path, delta, time_stamp, request_id)
Method request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def request(method, uri, data, options = {}, &user_block)
Method profile
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def profile(method, path, request_id, stats_on, &block)
Method format_error
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def format_error(e, params = {})
return e unless e.respond_to?(:response)
error = MultiJson.load(e.response)
message = GoodData::Helpers.interpolate_error_message(error)
if error && error['error'] && error['error']['errorClass'] == 'com.gooddata.security.authorization.AuthorizationFailedException'
- 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 stats_table
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def stats_table(values = stats)
sorted = values.sort_by { |_k, v| v[:avg] }
Terminal::Table.new :headings => %w(title avg min max total calls) do |t|
overall = {
:avg => 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 enrich_error_message
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def enrich_error_message(exception)
begin
return exception unless exception.response
response = JSON.parse(exception.response.body, symbolize_names: true)
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def request(method, uri, data, options = {}, &user_block)
request_id = options[:request_id] || generate_request_id
log_info(options.merge(request_id: request_id))
stats_on = options[:stats_on]
- 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 disconnect
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def disconnect
# TODO: Wrap somehow
url = @auth['state']
begin
- 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"