Skip to content

Commit

Permalink
Cleanups since master is 2.2+
Browse files Browse the repository at this point in the history
- Use safe navigation operator
- Cleanup old "unused variable" comments and hack, this doesn't seem to warn on 2.3 onwards
  • Loading branch information
vipulnsward authored and ioquatix committed Feb 10, 2020
1 parent 6e83f62 commit 838ce3a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/rack/auth/abstract/request.rb
Expand Up @@ -25,7 +25,7 @@ def parts
end

def scheme
@scheme ||= parts.first && parts.first.downcase
@scheme ||= parts.first&.downcase
end

def params
Expand Down
8 changes: 2 additions & 6 deletions lib/rack/show_exceptions.rb
Expand Up @@ -63,13 +63,9 @@ def dump_exception(exception)
def pretty(env, exception)
req = Rack::Request.new(env)

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

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

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

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

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

body = @template.result(binding)
size = body.bytesize
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/utils.rb
Expand Up @@ -152,7 +152,7 @@ def best_q_match(q_value_header, available_mimes)
end.compact.sort_by do |match, quality|
(match.split('/', 2).count('*') * -10) + quality
end.last
matches && matches.first
matches&.first
end

ESCAPE_HTML = {
Expand Down

0 comments on commit 838ce3a

Please sign in to comment.