Skip to content

Commit 82ea509

Browse files
committed
Suppress RuboCop's warning and offense
This PR suppresses the following RuboCop's warning and offense: ```console $ bundle exec rake (snip) Warning: Using `Naming/PredicateName` configuration in /Users/koic/src/github.com/rubocop/rubocop-performance/.rubocop.yml for `Naming/PredicatePrefix`. (snip) Offenses: lib/rubocop/cop/performance/inefficient_hash_search.rb:86:13: C: Naming/PredicateMethod: Predicate method names should end with ?. def use_long_method ^^^^^^^^^^^^^^^ 122 files inspected, 1 offense detected ```
1 parent d8cddb4 commit 82ea509

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Naming/InclusiveLanguage:
4141
Suggestions:
4242
- offense
4343

44-
Naming/PredicateName:
44+
Naming/PredicatePrefix:
4545
# Method define macros for dynamically generated method.
4646
MethodDefinitionMacros:
4747
- define_method

lib/rubocop/cop/performance/inefficient_hash_search.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ def replacement(node)
7474

7575
def correct_method(node)
7676
case current_method(node)
77-
when :keys then use_long_method ? 'has_key?' : 'key?'
78-
when :values then use_long_method ? 'has_value?' : 'value?'
77+
when :keys then use_long_method? ? 'has_key?' : 'key?'
78+
when :values then use_long_method? ? 'has_value?' : 'value?'
7979
end
8080
end
8181

8282
def current_method(node)
8383
node.receiver.method_name
8484
end
8585

86-
def use_long_method
86+
def use_long_method?
8787
config.for_enabled_cop('Style/PreferredHashMethods')['EnforcedStyle'] == 'long'
8888
end
8989

0 commit comments

Comments
 (0)