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 0000000..3111b78 --- /dev/null +++ b/changelog/change_require_rubocop_ast_1_30.md @@ -0,0 +1 @@ +* [#274](https://github.com/rubocop/rubocop-minitest/pull/274): Require RuboCop AST 1.30.0+. ([@koic][]) diff --git a/lib/rubocop/cop/minitest/assert_empty.rb b/lib/rubocop/cop/minitest/assert_empty.rb index d30828b..90b5914 100644 --- a/lib/rubocop/cop/minitest/assert_empty.rb +++ b/lib/rubocop/cop/minitest/assert_empty.rb @@ -22,8 +22,8 @@ class AssertEmpty < Base remove_method :on_send def on_send(node) return unless node.method?(:assert) - return unless node.arguments.first.respond_to?(:method?) && node.arguments.first.method?(:empty?) - return unless node.arguments.first.arguments.empty? + return unless node.first_argument.respond_to?(:method?) && node.first_argument.method?(:empty?) + return unless node.first_argument.arguments.empty? add_offense(node, message: offense_message(node.arguments)) do |corrector| autocorrect(corrector, node, node.arguments) diff --git a/lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb b/lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb index 061fe2e..d6f0297 100644 --- a/lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb +++ b/lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb @@ -30,7 +30,7 @@ def on_send(node) return if node.parent.resbody_type? return if accept_previous_line?(previous_line_node, assertion_method) - previous_line_node = previous_line_node.arguments.last if use_heredoc_argument?(previous_line_node) + previous_line_node = previous_line_node.last_argument if use_heredoc_argument?(previous_line_node) return if use_assertion_method_at_last_of_block?(previous_line_node) return unless no_empty_line?(previous_line_node, assertion_method) @@ -57,7 +57,7 @@ def accept_previous_line?(previous_line_node, node) end def use_heredoc_argument?(node) - node.respond_to?(:arguments) && heredoc?(node.arguments.last) + node.respond_to?(:arguments) && heredoc?(node.last_argument) end def use_assertion_method_at_last_of_block?(node) diff --git a/lib/rubocop/cop/minitest/refute_empty.rb b/lib/rubocop/cop/minitest/refute_empty.rb index eb4bd22..1f864ad 100644 --- a/lib/rubocop/cop/minitest/refute_empty.rb +++ b/lib/rubocop/cop/minitest/refute_empty.rb @@ -22,8 +22,8 @@ class RefuteEmpty < Base remove_method :on_send def on_send(node) return unless node.method?(:refute) - return unless node.arguments.first.respond_to?(:method?) && node.arguments.first.method?(:empty?) - return unless node.arguments.first.arguments.empty? + return unless node.first_argument.respond_to?(:method?) && node.first_argument.method?(:empty?) + return unless node.first_argument.arguments.empty? add_offense(node, message: offense_message(node.arguments)) do |corrector| autocorrect(corrector, node, node.arguments) diff --git a/lib/rubocop/cop/mixin/argument_range_helper.rb b/lib/rubocop/cop/mixin/argument_range_helper.rb index 9593ace..e31e0d2 100644 --- a/lib/rubocop/cop/mixin/argument_range_helper.rb +++ b/lib/rubocop/cop/mixin/argument_range_helper.rb @@ -18,7 +18,7 @@ def first_and_second_arguments_range(node) def all_arguments_range(node) first_argument = node.first_argument - last_argument = node.arguments.last + last_argument = node.last_argument range_between(first_argument.source_range.begin_pos, last_argument.source_range.end_pos) end diff --git a/rubocop-minitest.gemspec b/rubocop-minitest.gemspec index ba925cb..c4642c5 100644 --- a/rubocop-minitest.gemspec +++ b/rubocop-minitest.gemspec @@ -33,4 +33,5 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_runtime_dependency 'rubocop', '>= 1.39', '< 2.0' + spec.add_runtime_dependency 'rubocop-ast', '>= 1.30.0', '< 2.0' end