Method call
has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring. Open
def call(env)
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
client_settings = ClientSettings.new(env, @storage, start)
MiniProfiler.deauthorize_request if @config.authorization_mode == :allow_authorized
- 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
File mini_profiler.rb
has 517 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cgi'
require 'json'
require 'erb'
require 'mini_profiler/timer_struct'
Method call
has 194 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(env)
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
client_settings = ClientSettings.new(env, @storage, start)
MiniProfiler.deauthorize_request if @config.authorization_mode == :allow_authorized
Class MiniProfiler
has 42 methods (exceeds 20 allowed). Consider refactoring. Open
class MiniProfiler
include Actions
include Views
class << self
Method inject_profiler
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def inject_profiler(env, status, headers, body)
# mini profiler is meddling with stuff, we can not cache cause we will get incorrect data
# Rack::ETag has already inserted some nonesense in the chain
content_type = headers['Content-Type']
- 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 analyze_memory
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def analyze_memory
require 'objspace'
utf8 = "utf-8"
Method analyze_memory
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def analyze_memory
require 'objspace'
utf8 = "utf-8"
- 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 binds_to_params
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def binds_to_params(binds)
return if binds.nil? || config.max_sql_param_length == 0
# map ActiveRecord::Relation::QueryAttribute to [name, value]
params = binds.map { |c| c.kind_of?(Array) ? [c.first, c.last] : [c.name, c.value] }
if (skip = config.skip_sql_param_names)
- 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 take_snapshot
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def take_snapshot(env, start)
MiniProfiler.create_current(env, @config)
Thread.current[:mp_ongoing_snapshot] = true
results = @app.call(env)
status = results[0].to_i
Method take_snapshot
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def take_snapshot(env, start)
MiniProfiler.create_current(env, @config)
Thread.current[:mp_ongoing_snapshot] = true
results = @app.call(env)
status = results[0].to_i
- 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 inject
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def inject(fragment, script)
# find explicit or implicit body
index = fragment.rindex(/<\/body>/i) || fragment.rindex(/<\/html>/i)
if index
# if for whatever crazy reason we dont get a utf string,
- 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 rails_route_from_path
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def rails_route_from_path(path, method)
if defined?(Rails) && defined?(ActionController::RoutingError)
hash = Rails.application.routes.recognize_path(path, method: method)
if hash && hash[:controller] && hash[:action]
"#{hash[:controller]}##{hash[:action]}"
- 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 tool_disabled_message(client_settings) if !advanced_debugging_enabled?
Avoid too many return
statements within this method. Open
return serve_snapshot(env)
Avoid too many return
statements within this method. Open
return client_settings.handle_cookie(self.flamegraph(flamegraph, path, env))
Avoid too many return
statements within this method. Open
return client_settings.handle_cookie(
text_result(message, status: status, headers: headers)
)
Avoid too many return
statements within this method. Open
return client_settings.handle_cookie(help(client_settings, env))
Avoid too many return
statements within this method. Open
return client_settings.handle_cookie(serve_file(env, file_name: file_name))
Avoid too many return
statements within this method. Open
return serve_profile_gc(env, client_settings)
Avoid too many return
statements within this method. Open
return client_settings.handle_cookie(analyze_memory)
Avoid too many return
statements within this method. Open
return client_settings.handle_cookie(dump_exceptions exceptions)
Avoid too many return
statements within this method. Open
return serve_flamegraph(env)
Avoid too many return
statements within this method. Open
return client_settings.handle_cookie([status, headers, body])
Avoid too many return
statements within this method. Open
return tool_disabled_message(client_settings) if !advanced_debugging_enabled?
Avoid too many return
statements within this method. Open
return client_settings.handle_cookie([status, headers, body]) if skip_it
Avoid too many return
statements within this method. Open
return serve_profile_memory(env, client_settings)
Avoid too many return
statements within this method. Open
return client_settings.handle_cookie(dump_env env)
Avoid too many return
statements within this method. Open
return client_settings.handle_cookie(result) if result