lib/rubocop/cop/mixin/predicate_assertion_handleable.rb in rubocop-minitest-0.33.0 vs lib/rubocop/cop/mixin/predicate_assertion_handleable.rb in rubocop-minitest-0.34.0

- old
+ new

@@ -7,21 +7,17 @@ # @api private module PredicateAssertionHandleable MSG = 'Prefer using `%<assertion_type>s_predicate(%<new_arguments>s)`.' def on_send(node) - return unless (arguments = peel_redundant_parentheses_from(node.arguments)) + return unless node.first_argument + return if node.first_argument.block_type? || node.first_argument.numblock_type? + return unless predicate_method?(node.first_argument) + return unless node.first_argument.arguments.count.zero? - first_argument = arguments.first - - return unless first_argument - return if first_argument.block_type? || first_argument.numblock_type? - 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) + add_offense(node, message: offense_message(node.arguments)) do |corrector| + autocorrect(corrector, node, node.arguments) end end def autocorrect(corrector, node, arguments) corrector.replace(node.loc.selector, "#{assertion_type}_predicate") @@ -30,15 +26,9 @@ corrector.replace(node.first_argument, new_arguments) end private - - 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