Skip to content

Commit

Permalink
Fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
nateberkopec committed Apr 5, 2023
1 parent f4ec2ee commit c69d1a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions lib/mini_profiler/profiler.rb
Expand Up @@ -349,15 +349,7 @@ def call(env)
env['HTTP_ACCEPT_ENCODING'] = 'identity' if config.suppress_encoding

if query_string =~ /pp=(async-)?flamegraph/ || env['HTTP_REFERER'] =~ /pp=async-flamegraph/
unless defined?(StackProf) && StackProf.respond_to?(:run)
message = "Please install the stackprof gem and require it: add gem 'stackprof' to your Gemfile"
status, headers, body = @app.call(env)
body.close if body.respond_to? :close

return client_settings.handle_cookie(
text_result(message, status: status, headers: headers)
)
else
if defined?(StackProf) && StackProf.respond_to?(:run)
# do not sully our profile with mini profiler timings
current.measure = false
match_data = query_string.match(/flamegraph_sample_rate=([\d\.]+)/)
Expand All @@ -384,6 +376,14 @@ def call(env)
) do
status, headers, body = @app.call(env)
end
else
message = "Please install the stackprof gem and require it: add gem 'stackprof' to your Gemfile"
status, headers, body = @app.call(env)
body.close if body.respond_to? :close

return client_settings.handle_cookie(
text_result(message, status: status, headers: headers)
)
end
elsif path == '/rack-mini-profiler/requests'
blank_page_html = <<~HTML
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/profiler_spec.rb
Expand Up @@ -208,7 +208,7 @@ def self.bar(baz, boo)

expect(response).to eq([
200,
{ "Content-Type" => "text/plain; charset=utf-8", "Set-Cookie"=>"__profilin=p%3Dt; path=/; HttpOnly; SameSite=Lax" },
{ "Content-Type" => "text/plain; charset=utf-8", "Set-Cookie" => "__profilin=p%3Dt; path=/; HttpOnly; SameSite=Lax" },
["Please install the stackprof gem and require it: add gem 'stackprof' to your Gemfile"],
])
end
Expand All @@ -221,7 +221,7 @@ def self.bar(baz, boo)

expect(response).to eq([
200,
{ "Content-Type" => "text/plain; charset=utf-8", "Set-Cookie"=>"__profilin=p%3Dt; path=/; HttpOnly; SameSite=Lax" },
{ "Content-Type" => "text/plain; charset=utf-8", "Set-Cookie" => "__profilin=p%3Dt; path=/; HttpOnly; SameSite=Lax" },
["Please install the memory_profiler gem and require it: add gem 'memory_profiler' to your Gemfile"],
])

Expand Down

0 comments on commit c69d1a8

Please sign in to comment.