diff options
author | Akira Matsuda <ronnie@dio.jp> | 2019-07-27 12:56:39 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2019-07-27 13:06:49 +0900 |
commit | d1ffe59ab5fd6e811833c127d43b32e87b5d7131 (patch) | |
tree | c866689e6b51b1f7eac9e49212d2938d56f6ecb2 /activesupport | |
parent | e9651deea4145f62224af56af027bfbb3e45e4cd (diff) | |
download | rails-d1ffe59ab5fd6e811833c127d43b32e87b5d7131.tar.gz rails-d1ffe59ab5fd6e811833c127d43b32e87b5d7131.tar.bz2 rails-d1ffe59ab5fd6e811833c127d43b32e87b5d7131.zip |
Use match? where we don't need MatchData
We're already running Performance/RegexpMatch cop, but it seems like the cop is not always =~ justice
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/name_error.rb | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/option_merger.rb | 2 | ||||
-rw-r--r-- | activesupport/test/message_encryptor_test.rb | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/name_error.rb b/activesupport/lib/active_support/core_ext/name_error.rb index 6d37cd9dfd..c51aec0e03 100644 --- a/activesupport/lib/active_support/core_ext/name_error.rb +++ b/activesupport/lib/active_support/core_ext/name_error.rb @@ -15,7 +15,7 @@ class NameError # We should use original_message message instead. message = respond_to?(:original_message) ? original_message : self.message - if /undefined local variable or method/ !~ message + unless /undefined local variable or method/.match?(message) $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message end end diff --git a/activesupport/lib/active_support/option_merger.rb b/activesupport/lib/active_support/option_merger.rb index ab9ca727f6..8e54b11be6 100644 --- a/activesupport/lib/active_support/option_merger.rb +++ b/activesupport/lib/active_support/option_merger.rb @@ -5,7 +5,7 @@ require "active_support/core_ext/hash/deep_merge" module ActiveSupport class OptionMerger #:nodoc: instance_methods.each do |method| - undef_method(method) if method !~ /^(__|instance_eval|class|object_id)/ + undef_method(method) unless method.match?(/^(__|instance_eval|class|object_id)/) end def initialize(context, options) diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb index 097aa8b5f8..f807497709 100644 --- a/activesupport/test/message_encryptor_test.rb +++ b/activesupport/test/message_encryptor_test.rb @@ -174,7 +174,7 @@ class MessageEncryptorTest < ActiveSupport::TestCase def test_on_rotation_can_be_passed_at_the_constructor_level older_message = ActiveSupport::MessageEncryptor.new(secrets[:older], "older sign").encrypt_and_sign(encoded: "message") - rotated = false + rotated = rotated = false # double assigning to suppress "assigned but unused variable" warning encryptor = ActiveSupport::MessageEncryptor.new(@secret, on_rotation: proc { rotated = true }) encryptor.rotate secrets[:older], "older sign" @@ -188,7 +188,7 @@ class MessageEncryptorTest < ActiveSupport::TestCase def test_on_rotation_option_takes_precedence_over_the_one_given_in_constructor older_message = ActiveSupport::MessageEncryptor.new(secrets[:older], "older sign").encrypt_and_sign(encoded: "message") - rotated = false + rotated = rotated = false # double assigning to suppress "assigned but unused variable" warning encryptor = ActiveSupport::MessageEncryptor.new(@secret, on_rotation: proc { rotated = true }) encryptor.rotate secrets[:older], "older sign" |