Skip to content

Commit d080ec3

Browse files
committed
Use RuboCop::AST::Node#any_def_type? method
Follow-up to rubocop/rubocop-ast#377 This PR suppresses the following new offenses: ```console $ bundle exec rubocop -a (snip) Offenses: lib/rubocop/cop/performance/block_given_with_explicit_block.rb:39:41: C: [Correctable] InternalAffairs/NodeTypeGroup: Use :any_def instead of individually listing group types. def_node = node.each_ancestor(:def, :defs).first ^^^^^^^^^^^ lib/rubocop/cop/performance/regexp_match.rb:242:28: C: [Correctable] InternalAffairs/NodeTypeGroup: Use :any_def instead of individually listing group types. ancestor.type?(:def, :defs, :class, :module) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 122 files inspected, 2 offenses detected, 2 offenses autocorrectable ```
1 parent 4580ea6 commit d080ec3

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/rubocop/cop/performance/block_given_with_explicit_block.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BlockGivenWithExplicitBlock < Base
3636
def_node_matcher :reassigns_block_arg?, '`(lvasgn %1 ...)'
3737

3838
def on_send(node)
39-
def_node = node.each_ancestor(:def, :defs).first
39+
def_node = node.each_ancestor(:any_def).first
4040
return unless def_node
4141

4242
block_arg = def_node.arguments.find(&:blockarg_type?)

lib/rubocop/cop/performance/regexp_match.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def scope_body(node)
239239

240240
def scope_root(node)
241241
node.each_ancestor.find do |ancestor|
242-
ancestor.type?(:def, :defs, :class, :module)
242+
ancestor.type?(:any_def, :class, :module)
243243
end
244244
end
245245

rubocop-performance.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ Gem::Specification.new do |s|
3333

3434
s.add_dependency('lint_roller', '~> 1.1')
3535
s.add_dependency('rubocop', '>= 1.75.0', '< 2.0')
36-
s.add_dependency('rubocop-ast', '>= 1.38.0', '< 2.0')
36+
s.add_dependency('rubocop-ast', '>= 1.44.0', '< 2.0')
3737
end

0 commit comments

Comments
 (0)