lib/rubocop/cop/mixin/predicate_assertion_handleable.rb in rubocop-minitest-0.20.0 vs lib/rubocop/cop/mixin/predicate_assertion_handleable.rb in rubocop-minitest-0.20.1
- old
+ new
@@ -11,12 +11,13 @@
def on_send(node)
return unless (arguments = peel_redundant_parentheses_from(node.arguments))
first_argument = arguments.first
+ return unless first_argument
return if first_argument.block_type? || first_argument.numblock_type?
- return unless first_argument.respond_to?(:predicate_method?) && first_argument.predicate_method?
+ return unless predicate_method?(first_argument)
return unless first_argument.arguments.count.zero?
add_offense(node, message: offense_message(arguments)) do |corrector|
autocorrect(corrector, node, arguments)
end
@@ -34,9 +35,13 @@
def peel_redundant_parentheses_from(arguments)
return arguments unless arguments.first&.begin_type?
peel_redundant_parentheses_from(arguments.first.children)
+ end
+
+ def predicate_method?(first_argument)
+ first_argument.respond_to?(:predicate_method?) && first_argument.predicate_method?
end
def offense_message(arguments)
message_argument = arguments.last if arguments.first != arguments.last