From c69d1a8db8a15462eee133dc3223216cb9488297 Mon Sep 17 00:00:00 2001 From: Nate Berkopec Date: Wed, 5 Apr 2023 15:10:18 +0900 Subject: [PATCH] Fix rubocop --- lib/mini_profiler/profiler.rb | 18 +++++++++--------- spec/lib/profiler_spec.rb | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/mini_profiler/profiler.rb b/lib/mini_profiler/profiler.rb index 17dc8cdb..9b762122 100644 --- a/lib/mini_profiler/profiler.rb +++ b/lib/mini_profiler/profiler.rb @@ -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\.]+)/) @@ -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 diff --git a/spec/lib/profiler_spec.rb b/spec/lib/profiler_spec.rb index 11953f05..4abec11e 100644 --- a/spec/lib/profiler_spec.rb +++ b/spec/lib/profiler_spec.rb @@ -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 @@ -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"], ])