You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
!foo.nil? ? 1 : 2
# => Use parentheses for ternary expressions with complex conditions. (convention:Style/TernaryParentheses)
(!foo.nil?) ? 1 : 2
# => Don't use parentheses around an unary operation. (convention:Style/RedundantParentheses)
not nil is considered as a complex condition by Style/TernaryParentheses (EnforcedStyle: require_parentheses_when_complex) ; however, since it is a unary operation, adding parenthesis violates Style/RedundantParentheses which leads to infinite loop in the auto-correct mechanism.
Expected behavior
TernaryParentheses and RedundantParentheses can agree if not nil is complex or not.
Actual behavior
They don't agree.
Steps to reproduce the problem
Running rubocop --safe-auto-correct on above snippet with the setting below leads to infinite loop
not nil
is considered as a complex condition byStyle/TernaryParentheses (EnforcedStyle: require_parentheses_when_complex)
; however, since it is a unary operation, adding parenthesis violatesStyle/RedundantParentheses
which leads to infinite loop in the auto-correct mechanism.Expected behavior
TernaryParentheses
andRedundantParentheses
can agree ifnot nil
is complex or not.Actual behavior
They don't agree.
Steps to reproduce the problem
Running
rubocop --safe-auto-correct
on above snippet with the setting below leads to infinite loopRuboCop version
The text was updated successfully, but these errors were encountered: