diff --git a/lib/rubocop/cop/performance/inefficient_hash_search.rb b/lib/rubocop/cop/performance/inefficient_hash_search.rb index 99e4e2c0f..778db82af 100644 --- a/lib/rubocop/cop/performance/inefficient_hash_search.rb +++ b/lib/rubocop/cop/performance/inefficient_hash_search.rb @@ -84,8 +84,7 @@ def current_method(node) end def use_long_method - preferred_config = config.for_all_cops['Style/PreferredHashMethods'] - preferred_config && preferred_config['EnforcedStyle'] == 'long' && preferred_config['Enabled'] + config.for_enabled_cop('Style/PreferredHashMethods')['EnforcedStyle'] == 'long' end def correct_argument(node) diff --git a/spec/rubocop/cop/performance/inefficient_hash_search_spec.rb b/spec/rubocop/cop/performance/inefficient_hash_search_spec.rb index d7d282bc5..ee68ae6f0 100644 --- a/spec/rubocop/cop/performance/inefficient_hash_search_spec.rb +++ b/spec/rubocop/cop/performance/inefficient_hash_search_spec.rb @@ -138,28 +138,24 @@ def my_include?(key) end context 'when config specifies long hash methods but is not enabled' do - let(:config) do - RuboCop::Config.new( - 'AllCops' => { - 'Style/PreferredHashMethods' => { - 'EnforcedStyle' => 'long', 'Enabled' => false - } + let(:other_cops) do + { + 'Style/PreferredHashMethods' => { + 'EnforcedStyle' => 'long', 'Enabled' => false } - ) + } end it_behaves_like 'correct behavior', :short end context 'when config enforces long hash methods' do - let(:config) do - RuboCop::Config.new( - 'AllCops' => { - 'Style/PreferredHashMethods' => { - 'EnforcedStyle' => 'long', 'Enabled' => true - } + let(:other_cops) do + { + 'Style/PreferredHashMethods' => { + 'EnforcedStyle' => 'long', 'Enabled' => true } - ) + } end it_behaves_like 'correct behavior', :long