diff options
author | Bart de Water <bartdewater@gmail.com> | 2018-07-28 17:37:17 -0400 |
---|---|---|
committer | Bart de Water <bartdewater@gmail.com> | 2018-07-28 17:37:17 -0400 |
commit | eb5fea40a404e829f00552859ae1b206728d99d7 (patch) | |
tree | 3abe3c813b8e64c5bb009902166953a616786232 /actionview | |
parent | 8741052ba25722283ea057f6f022f16b1931ce3e (diff) | |
download | rails-eb5fea40a404e829f00552859ae1b206728d99d7.tar.gz rails-eb5fea40a404e829f00552859ae1b206728d99d7.tar.bz2 rails-eb5fea40a404e829f00552859ae1b206728d99d7.zip |
Enable Start/EndWith and RegexpMatch cops
In cases where the MatchData object is not used, this provides a speed-up:
https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/Rakefile | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/tags/color_field.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/text_helper.rb | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/actionview/Rakefile b/actionview/Rakefile index bdfd96c141..7851a2b6bf 100644 --- a/actionview/Rakefile +++ b/actionview/Rakefile @@ -107,7 +107,7 @@ namespace :assets do end print "[verify] #{file} is a UMD module " - if pathname.read =~ /module\.exports.*define\.amd/m + if /module\.exports.*define\.amd/m.match?(pathname.read) puts "[OK]" else $stderr.puts "[FAIL]" diff --git a/actionview/lib/action_view/helpers/tags/color_field.rb b/actionview/lib/action_view/helpers/tags/color_field.rb index c5f0bb6bbb..39ab1285c3 100644 --- a/actionview/lib/action_view/helpers/tags/color_field.rb +++ b/actionview/lib/action_view/helpers/tags/color_field.rb @@ -15,7 +15,7 @@ module ActionView def validate_color_string(string) regex = /#[0-9a-fA-F]{6}/ - if regex.match(string) + if regex.match?(string) string.downcase else "#000000" diff --git a/actionview/lib/action_view/helpers/text_helper.rb b/actionview/lib/action_view/helpers/text_helper.rb index 34138de00e..77a1c1fed9 100644 --- a/actionview/lib/action_view/helpers/text_helper.rb +++ b/actionview/lib/action_view/helpers/text_helper.rb @@ -188,7 +188,7 @@ module ActionView unless separator.empty? text.split(separator).each do |value| - if value.match(regex) + if value.match?(regex) phrase = value break end |