diff --git a/changelog/change_require_rubocop_ast_1_30.md b/changelog/change_require_rubocop_ast_1_30.md new file mode 100644 index 0000000000..e464067c42 --- /dev/null +++ b/changelog/change_require_rubocop_ast_1_30.md @@ -0,0 +1 @@ +* [#380](https://github.com/rubocop/rubocop-performance/pull/380): Require RuboCop AST 1.30.0+. ([@koic][]) diff --git a/lib/rubocop/cop/performance/inefficient_hash_search.rb b/lib/rubocop/cop/performance/inefficient_hash_search.rb index a297bb3c03..1a951c32b6 100644 --- a/lib/rubocop/cop/performance/inefficient_hash_search.rb +++ b/lib/rubocop/cop/performance/inefficient_hash_search.rb @@ -89,7 +89,7 @@ def use_long_method end def correct_argument(node) - node.arguments.first.source + node.first_argument.source end def correct_hash_expression(node) diff --git a/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb b/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb index daeb979bfd..b01887a887 100644 --- a/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb +++ b/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb @@ -63,7 +63,7 @@ def on_block(node) return unless TARGET_METHODS.include?(node.method_name) return unless one_block_argument?(node.arguments) - block_argument = node.arguments.first + block_argument = node.first_argument block_body = node.body return unless use_equality_comparison_block?(block_body) return if same_block_argument_and_is_a_argument?(block_body, block_argument) diff --git a/lib/rubocop/cop/performance/reverse_first.rb b/lib/rubocop/cop/performance/reverse_first.rb index 5b57301634..c3b48c3107 100644 --- a/lib/rubocop/cop/performance/reverse_first.rb +++ b/lib/rubocop/cop/performance/reverse_first.rb @@ -55,7 +55,7 @@ def build_message(node) def build_good_method(node) if node.arguments? - "last(#{node.arguments.first.source}).reverse" + "last(#{node.first_argument.source}).reverse" else 'last' end @@ -63,7 +63,7 @@ def build_good_method(node) def build_bad_method(node) if node.arguments? - "reverse.first(#{node.arguments.first.source})" + "reverse.first(#{node.first_argument.source})" else 'reverse.first' end diff --git a/rubocop-performance.gemspec b/rubocop-performance.gemspec index 68e82f8431..478b015df5 100644 --- a/rubocop-performance.gemspec +++ b/rubocop-performance.gemspec @@ -31,5 +31,5 @@ Gem::Specification.new do |s| } s.add_runtime_dependency('rubocop', '>= 1.7.0', '< 2.0') - s.add_runtime_dependency('rubocop-ast', '>= 0.4.0') + s.add_runtime_dependency('rubocop-ast', '>= 1.30.0', '< 2.0') end