From d1ffe59ab5fd6e811833c127d43b32e87b5d7131 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Jul 2019 12:56:39 +0900 Subject: 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 --- activesupport/lib/active_support/core_ext/name_error.rb | 2 +- activesupport/lib/active_support/option_merger.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib') 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) -- cgit v1.2.3