lib/rubocop/cop/style/ternary_parentheses.rb in rubocop-1.33.0 vs lib/rubocop/cop/style/ternary_parentheses.rb in rubocop-1.34.0

- old
+ new

@@ -69,11 +69,11 @@ def on_if(node) condition = node.condition return if only_closing_parenthesis_is_last_line?(condition) return if condition_as_parenthesized_one_line_pattern_matching?(condition) - return unless node.ternary? && !infinite_loop? && offense?(node) + return unless node.ternary? && offense?(node) message = message(node) add_offense(node.source_range, message: message) do |corrector| autocorrect(corrector, node) @@ -164,23 +164,11 @@ def require_parentheses_when_complex? style == :require_parentheses_when_complex end - def redundant_parentheses_enabled? - @config.for_cop('Style/RedundantParentheses').fetch('Enabled') - end - def parenthesized?(node) node.begin_type? - end - - # When this cop is configured to enforce parentheses and the - # `RedundantParentheses` cop is enabled, it will cause an infinite loop - # as they compete to add and remove the parentheses respectively. - def infinite_loop? - (require_parentheses? || require_parentheses_when_complex?) && - redundant_parentheses_enabled? end def unsafe_autocorrect?(condition) condition.children.any? do |child| unparenthesized_method_call?(child) || below_ternary_precedence?(child)