Skip to content

Commit

Permalink
Double assignment is still needed to prevent an "unused variable" war…
Browse files Browse the repository at this point in the history
…ning

That warning is still raised on latest Ruby.
  • Loading branch information
kamipo authored and ioquatix committed Feb 10, 2020
1 parent 2db0ddf commit 3d7a634
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/rack/show_exceptions.rb
Expand Up @@ -63,9 +63,13 @@ def dump_exception(exception)
def pretty(env, exception)
req = Rack::Request.new(env)

path = (req.script_name + req.path_info).squeeze("/")
# This double assignment is to prevent an "unused variable" warning.
# Yes, it is dumb, but I don't like Ruby yelling at me.
path = path = (req.script_name + req.path_info).squeeze("/")

frames = exception.backtrace.map { |line|
# This double assignment is to prevent an "unused variable" warning.
# Yes, it is dumb, but I don't like Ruby yelling at me.
frames = frames = exception.backtrace.map { |line|
frame = OpenStruct.new
if line =~ /(.*?):(\d+)(:in `(.*)')?/
frame.filename = $1
Expand Down
8 changes: 6 additions & 2 deletions lib/rack/show_status.rb
Expand Up @@ -23,11 +23,15 @@ def call(env)

# client or server error, or explicit message
if (status.to_i >= 400 && empty) || env[RACK_SHOWSTATUS_DETAIL]
req = Rack::Request.new(env)
# This double assignment is to prevent an "unused variable" warning.
# Yes, it is dumb, but I don't like Ruby yelling at me.
req = req = Rack::Request.new(env)

message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s

detail = env[RACK_SHOWSTATUS_DETAIL] || message
# This double assignment is to prevent an "unused variable" warning.
# Yes, it is dumb, but I don't like Ruby yelling at me.
detail = detail = env[RACK_SHOWSTATUS_DETAIL] || message

body = @template.result(binding)
size = body.bytesize
Expand Down

0 comments on commit 3d7a634

Please sign in to comment.