From afc80f55da2f294c60d155f01f92daa11d37041f Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Mon, 6 Nov 2023 01:28:02 +0900 Subject: [PATCH] Require RuboCop AST 1.30.0+ Follow up https://github.com/rubocop/rubocop/pull/12305. --- changelog/change_require_rubocop_ast_1_30.md | 1 + lib/rubocop/cop/performance/inefficient_hash_search.rb | 2 +- .../cop/performance/redundant_equality_comparison_block.rb | 2 +- lib/rubocop/cop/performance/reverse_first.rb | 4 ++-- rubocop-performance.gemspec | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 changelog/change_require_rubocop_ast_1_30.md 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