Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double assignment is still needed to prevent an "unused variable" warning #1589

Merged
merged 1 commit into from Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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