Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require RuboCop AST 1.30.0+ #274

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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