Skip to content

Commit

Permalink
Fix InternalAffairs/CopEnabled offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
dvandersluis committed Dec 13, 2024
1 parent 9248192 commit c34c434
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
3 changes: 1 addition & 2 deletions lib/rubocop/cop/performance/inefficient_hash_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 10 additions & 14 deletions spec/rubocop/cop/performance/inefficient_hash_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c34c434

Please sign in to comment.