Skip to content

Commit

Permalink
Require RuboCop AST 1.30.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Nov 5, 2023
1 parent e085786 commit 760a4fd
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog/change_require_rubocop_ast_1_30.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#274](https://github.com/rubocop/rubocop-minitest/pull/274): Require RuboCop AST 1.30.0+. ([@koic][])
4 changes: 2 additions & 2 deletions lib/rubocop/cop/minitest/assert_empty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/minitest/refute_empty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/argument_range_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions rubocop-minitest.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 760a4fd

Please sign in to comment.