Showing 73 of 116 total issues
Method tar
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def tar(path)
string_io = StringIO.new('')
Gem::Package::TarWriter.new(string_io) do |tar|
Find.find(path) do |file|
# do not include the git files
- 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_common_request_params
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def add_common_request_params(params)
common_params = { connection_timeout: 610, write_timeout: 600, read_timeout: 600 }
# allow to follow redirects in the APIs
allowed_status_codes = params.key?(:expects) ? [*params[:expects]] : []
allowed_status_codes.concat([301, 302, 303, 307, 308]) unless params[:follow_redirects] == false
- 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 setup
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def setup
# perform the setup only once
return if @adapters
# Initialize the application (import adapters, load DAOs, ...)
- 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 handle_error
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def handle_error(error)
cf_error = error.body.is_a?(Hash) ? error.body[:code] : nil
case error.status
when 400
handle_400_error(error, cf_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 latest_release
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def latest_release(application_id, retrieved_dynos = nil)
dynos = web_dynos(application_id, retrieved_dynos)
if dynos.nil? || dynos.empty?
log.debug 'no dynos for build detection, fallback to latest release version'
# this approach might be wrong if the app is rolled-back to a previous release
- 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 runtimes_to_install
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def runtimes_to_install(application)
return [] unless application[:runtimes]
runtimes_to_install = []
application[:runtimes].each do |runtime_identifier|
# we do not need to install native buildpacks
- 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
for(var i=0; i < requiredScopes.length; i++) {
var s = requiredScopes[i];
if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
diff.push(s);
}
Method write_zip_entries
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def write_zip_entries(path, sub_path, io)
search_path = File.join(path, sub_path)
Find.find(path) do |file|
zip_file_path = file.sub(%r{^#{Regexp.escape search_path}\/?}, '')
next if @exclude_git && zip_file_path.start_with?('.git')
- 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
if(diff.length > 0){
o = v.parentNode.parentNode;
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
Avoid deeply nested control flow statements. Open
if (!loose) loose = next;
Method application_state
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def application_state(app_resource)
if app_resource[:entity][:state] == 'STARTED'
# 1: crashed
return Enums::ApplicationStates::CRASHED if app_resource[:entity][:package_state] == 'FAILED'
# 1: started
- 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
for(scope in auth.scopes) {
scopes.push({scope: scope, description: auth.scopes[scope], OAuthSchemeKey: key});
}
Method recent_log_messages
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def recent_log_messages(app_guid, filter = nil)
loggregator_recent_uri = "https://#{loggregator_endpoint}:443/recent?app=#{app_guid}"
# current log state before tailing, multipart message of protobuf objects
current_log_response = get(loggregator_recent_uri)
current_log_boundary = /boundary=(\w+)/.match(current_log_response.headers['Content-Type'])[1]
- 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
if(inner)
requiredScopes.push(inner);
Avoid deeply nested control flow statements. Open
for(i = 0; i < auth.scopes.length; i++) {
scopes.push(auth.scopes[i]);
}
Avoid deeply nested control flow statements. Open
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t];
var ep = dets.loginEndpoint.url;
url = dets.loginEndpoint.url + '?response_type=token';
window.swaggerUi.tokenName = dets.tokenName;
Avoid deeply nested control flow statements. Open
if (bull !== b && !(bull.length > 1 && b.length > 1)) {
src = cap.slice(i + 1).join('\n') + src;
i = l - 1;
}
Method log?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def log?(application_name_or_id, log_id)
app_guid = app_guid(application_name_or_id)
# test file existence
log_id = 'staging_task.log' if log_id.to_sym == Enums::ApplicationLogfileType::BUILD
# checks also if application is even valid
- 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 push_file_tail
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def push_file_tail(app_guid, log_id, stream, pushed_line_idx, headers_to_use)
Method execute_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def execute_request(method, default_expect, path, params, native_call = false)