Skip to content
This repository
Browse code

Mark unused variables and make some style fixes

It'd be a nice convention to mark the unused variables like this, now that Ruby 2 will issue no warnings for such vars being unused.
  • Loading branch information...
commit a779ea9d57b00bd3b59f5546603271c2d302247c 1 parent e2e9eed
Agis Anastasopoulos Agis- authored
4 actionpack/lib/action_dispatch/http/mime_type.rb
@@ -223,8 +223,8 @@ def unregister(symbol)
223 223 Mime.instance_eval { remove_const(symbol) }
224 224
225 225 SET.delete_if { |v| v.eql?(mime) }
226   - LOOKUP.delete_if { |k,v| v.eql?(mime) }
227   - EXTENSION_LOOKUP.delete_if { |k,v| v.eql?(mime) }
  226 + LOOKUP.delete_if { |_,v| v.eql?(mime) }
  227 + EXTENSION_LOOKUP.delete_if { |_,v| v.eql?(mime) }
228 228 end
229 229 end
230 230
2  actionpack/lib/action_dispatch/journey/formatter.rb
@@ -58,7 +58,7 @@ def extract_parameterized_parts(route, options, recall, parameterize = nil)
58 58 end
59 59 end
60 60
61   - parameterized_parts.keep_if { |_, v| v }
  61 + parameterized_parts.keep_if { |_, v| v }
62 62 parameterized_parts
63 63 end
64 64
2  actionpack/lib/action_dispatch/middleware/request_id.rb
@@ -18,7 +18,7 @@ def initialize(app)
18 18
19 19 def call(env)
20 20 env["action_dispatch.request_id"] = external_request_id(env) || internal_request_id
21   - @app.call(env).tap { |status, headers, body| headers["X-Request-Id"] = env["action_dispatch.request_id"] }
  21 + @app.call(env).tap { |_status, headers, _body| headers["X-Request-Id"] = env["action_dispatch.request_id"] }
22 22 end
23 23
24 24 private
2  actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
@@ -13,7 +13,7 @@
13 13 request_dump = clean_params.empty? ? 'None' : clean_params.inspect.gsub(',', ",\n")
14 14
15 15 def debug_hash(object)
16   - object.to_hash.sort_by { |k, v| k.to_s }.map { |k, v| "#{k}: #{v.inspect rescue $!.message}" }.join("\n")
  16 + object.to_hash.sort_by { |k, _| k.to_s }.map { |k, v| "#{k}: #{v.inspect rescue $!.message}" }.join("\n")
17 17 end unless self.class.method_defined?(:debug_hash)
18 18 %>
19 19
4 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -489,7 +489,7 @@ def mount(app, options = nil)
489 489 end
490 490
491 491 options = app
492   - app, path = options.find { |k, v| k.respond_to?(:call) }
  492 + app, path = options.find { |k, _| k.respond_to?(:call) }
493 493 options.delete(app) if app
494 494 end
495 495
@@ -1361,7 +1361,7 @@ def shallow?
1361 1361 def match(path, *rest)
1362 1362 if rest.empty? && Hash === path
1363 1363 options = path
1364   - path, to = options.find { |name, value| name.is_a?(String) }
  1364 + path, to = options.find { |name, _value| name.is_a?(String) }
1365 1365 options[:to] = to
1366 1366 options.delete(path)
1367 1367 paths = [path]
2  actionpack/lib/action_dispatch/routing/route_set.rb
@@ -665,7 +665,7 @@ def recognize_path(path, environment = {})
665 665 end
666 666
667 667 req = @request_class.new(env)
668   - @router.recognize(req) do |route, matches, params|
  668 + @router.recognize(req) do |route, _matches, params|
669 669 params.merge!(extras)
670 670 params.each do |key, value|
671 671 if value.is_a?(String)
4 actionpack/lib/action_dispatch/testing/assertions/routing.rb
@@ -81,7 +81,7 @@ def assert_generates(expected_path, options, defaults={}, extras = {}, message=n
81 81 # Load routes.rb if it hasn't been loaded.
82 82
83 83 generated_path, extra_keys = @routes.generate_extras(options, defaults)
84   - found_extras = options.reject {|k, v| ! extra_keys.include? k}
  84 + found_extras = options.reject { |k, _| ! extra_keys.include? k }
85 85
86 86 msg = message || sprintf("found extras <%s>, not <%s>", found_extras, extras)
87 87 assert_equal(extras, found_extras, msg)
@@ -120,7 +120,7 @@ def assert_routing(path, options, defaults={}, extras={}, message=nil)
120 120 options[:controller] = "/#{controller}"
121 121 end
122 122
123   - generate_options = options.dup.delete_if{ |k,v| defaults.key?(k) }
  123 + generate_options = options.dup.delete_if{ |k, _| defaults.key?(k) }
124 124 assert_generates(path.is_a?(Hash) ? path[:path] : path, generate_options, defaults, extras, message)
125 125 end
126 126
4 actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -377,8 +377,8 @@ def assert_select_encoded(element = nil, &block)
377 377 node.content.gsub(/<!\[CDATA\[(.*)(\]\]>)?/m) { Rack::Utils.escapeHTML($1) }
378 378 end
379 379
380   - selected = elements.map do |_element|
381   - text = _element.children.select{ |c| not c.tag? }.map{ |c| fix_content[c] }.join
  380 + selected = elements.map do |elem|
  381 + text = elem.children.select{ |c| not c.tag? }.map{ |c| fix_content[c] }.join
382 382 root = HTML::Document.new(CGI.unescapeHTML("<encoded>#{text}</encoded>")).root
383 383 css_select(root, "encoded:root", &block)[0]
384 384 end
2  actionpack/lib/action_dispatch/testing/test_process.rb
@@ -6,7 +6,7 @@ module ActionDispatch
6 6 module TestProcess
7 7 def assigns(key = nil)
8 8 assigns = {}.with_indifferent_access
9   - @controller.view_assigns.each {|k, v| assigns.regular_writer(k, v)}
  9 + @controller.view_assigns.each { |k, v| assigns.regular_writer(k, v) }
10 10 key.nil? ? assigns : assigns[key]
11 11 end
12 12

0 comments on commit a779ea9

Please sign in to comment.
Something went wrong with that request. Please try again.