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
Yoda conditions should not be reported where both values are treated as constants.
I think that $0 can be assumed to be constant, and modifying it reported as a separate cop.
Expected behavior
In a reasonable program $0 is not going to be changed and both $0 and __FILE__ can be treated as read-only. So Yoda condition report should not be triggered for them.
Actual behavior
C: Style/YodaCondition: Reverse the order of the operands __FILE__ == $0.
if __FILE__ == $0
Fixesrubocop#7569.
This PR makes `Style/YodaCondition` cop accept `__FILE__ == $0`
I think that both operands `__FILE__ == $0` can be assumed to be
read-only, as mentioned in rubocop#7569. If users try to assign `__FILE__`,
an error will occur. Also, it is not usually assigned to `$0` by users.
Therefore, this PR will make `Style/YodaCondition` cop accept both
`__FILE__` and `$0` on the left side.
Also, this PR will change only an idiom `__FILE__ == $0`.
Fixes#7569.
This PR makes `Style/YodaCondition` cop accept `__FILE__ == $0`
I think that both operands `__FILE__ == $0` can be assumed to be
read-only, as mentioned in #7569. If users try to assign `__FILE__`,
an error will occur. Also, it is not usually assigned to `$0` by users.
Therefore, this PR will make `Style/YodaCondition` cop accept both
`__FILE__` and `$0` on the left side.
Also, this PR will change only an idiom `__FILE__ == $0`.
Yoda conditions should not be reported where both values are treated as constants.
I think that $0 can be assumed to be constant, and modifying it reported as a separate cop.
Expected behavior
In a reasonable program
$0
is not going to be changed and both$0
and__FILE__
can be treated as read-only. So Yoda condition report should not be triggered for them.Actual behavior
Steps to reproduce the problem
RuboCop version
it was after
The text was updated successfully, but these errors were encountered: