aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/url_helper.rb
diff options
context:
space:
mode:
authorYasuo Honda <yasuo.honda@gmail.com>2018-02-28 04:33:37 +0000
committerYasuo Honda <yasuo.honda@gmail.com>2018-09-29 07:18:44 +0000
commitaa3dcabd874a3e82e455e85a1c94a7abaac2900a (patch)
treef97dbc29ff6a2e32cc73e8025af41a8d7b576757 /actionview/lib/action_view/helpers/url_helper.rb
parent445a74e1a953c0b0bddf51b69865d43cce6ea859 (diff)
downloadrails-aa3dcabd874a3e82e455e85a1c94a7abaac2900a.tar.gz
rails-aa3dcabd874a3e82e455e85a1c94a7abaac2900a.tar.bz2
rails-aa3dcabd874a3e82e455e85a1c94a7abaac2900a.zip
Add `Style/RedundantFreeze` to remove redudant `.freeze`
Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
Diffstat (limited to 'actionview/lib/action_view/helpers/url_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/url_helper.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb
index 52bffaab84..948dd1551f 100644
--- a/actionview/lib/action_view/helpers/url_helper.rb
+++ b/actionview/lib/action_view/helpers/url_helper.rb
@@ -200,9 +200,9 @@ module ActionView
html_options = convert_options_to_data_attributes(options, html_options)
url = url_for(options)
- html_options["href".freeze] ||= url
+ html_options["href"] ||= url
- content_tag("a".freeze, name || url, html_options, &block)
+ content_tag("a", name || url, html_options, &block)
end
# Generates a form containing a single button that submits to the URL created
@@ -308,7 +308,7 @@ module ActionView
params = html_options.delete("params")
method = html_options.delete("method").to_s
- method_tag = BUTTON_TAG_METHOD_VERBS.include?(method) ? method_tag(method) : "".freeze.html_safe
+ method_tag = BUTTON_TAG_METHOD_VERBS.include?(method) ? method_tag(method) : "".html_safe
form_method = method == "get" ? "get" : "post"
form_options = html_options.delete("form") || {}
@@ -321,7 +321,7 @@ module ActionView
request_method = method.empty? ? "post" : method
token_tag(nil, form_options: { action: url, method: request_method })
else
- "".freeze
+ ""
end
html_options = convert_options_to_data_attributes(options, html_options)
@@ -487,12 +487,12 @@ module ActionView
option = html_options.delete(item).presence || next
"#{item.dasherize}=#{ERB::Util.url_encode(option)}"
}.compact
- extras = extras.empty? ? "".freeze : "?" + extras.join("&")
+ extras = extras.empty? ? "" : "?" + extras.join("&")
encoded_email_address = ERB::Util.url_encode(email_address).gsub("%40", "@")
html_options["href"] = "mailto:#{encoded_email_address}#{extras}"
- content_tag("a".freeze, name || email_address, html_options, &block)
+ content_tag("a", name || email_address, html_options, &block)
end
# True if the current request URI was generated by the given +options+.
@@ -575,21 +575,21 @@ module ActionView
def convert_options_to_data_attributes(options, html_options)
if html_options
html_options = html_options.stringify_keys
- html_options["data-remote"] = "true".freeze if link_to_remote_options?(options) || link_to_remote_options?(html_options)
+ html_options["data-remote"] = "true" if link_to_remote_options?(options) || link_to_remote_options?(html_options)
- method = html_options.delete("method".freeze)
+ method = html_options.delete("method")
add_method_to_attributes!(html_options, method) if method
html_options
else
- link_to_remote_options?(options) ? { "data-remote" => "true".freeze } : {}
+ link_to_remote_options?(options) ? { "data-remote" => "true" } : {}
end
end
def link_to_remote_options?(options)
if options.is_a?(Hash)
- options.delete("remote".freeze) || options.delete(:remote)
+ options.delete("remote") || options.delete(:remote)
end
end
@@ -622,7 +622,7 @@ module ActionView
token ||= form_authenticity_token(form_options: form_options)
tag(:input, type: "hidden", name: request_forgery_protection_token.to_s, value: token)
else
- "".freeze
+ ""
end
end