From 20f12310d53b1a2da4cf926ebd3c49416cfac800 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Sun, 7 Jun 2020 03:03:43 -0400 Subject: [PATCH] Refactor cop; call to_a on COMPARISON_OPERATORS --- lib/rubocop/cop/style/redundant_conditional.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/rubocop/cop/style/redundant_conditional.rb b/lib/rubocop/cop/style/redundant_conditional.rb index 14efbbbdb9ed..e922a83b88dc 100644 --- a/lib/rubocop/cop/style/redundant_conditional.rb +++ b/lib/rubocop/cop/style/redundant_conditional.rb @@ -27,7 +27,8 @@ module Style class RedundantConditional < Cop include Alignment - COMPARISON_OPERATORS = RuboCop::AST::Node::COMPARISON_OPERATORS + operators = RuboCop::AST::Node::COMPARISON_OPERATORS.to_a + COMPARISON_OPERATOR_MATCHER = "{:#{operators.join(' :')}}" MSG = 'This conditional expression can just be replaced ' \ 'by `%s`.' @@ -54,11 +55,11 @@ def message(node) end def_node_matcher :redundant_condition?, <<~RUBY - (if (send _ {:#{COMPARISON_OPERATORS.join(' :')}} _) true false) + (if (send _ #{COMPARISON_OPERATOR_MATCHER} _) true false) RUBY def_node_matcher :redundant_condition_inverted?, <<~RUBY - (if (send _ {:#{COMPARISON_OPERATORS.join(' :')}} _) false true) + (if (send _ #{COMPARISON_OPERATOR_MATCHER} _) false true) RUBY def offense?(node)