Skip to content

Commit

Permalink
Enable InternalAffairs/CopEnabled cop
Browse files Browse the repository at this point in the history
Since #490 made RuboCop 1.72+ a runtime requirement, `cop_enabled?` can now be used.
  • Loading branch information
koic committed Feb 18, 2025
1 parent 73fecfd commit 197472c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
InternalAffairs/CopEnabled:
Exclude:
- 'lib/rubocop/cop/performance/inefficient_hash_search.rb'

# Offense count: 12
InternalAffairs/NodeDestructuring:
Exclude:
Expand Down
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 197472c

Please sign in to comment.