Pattern: Use of Yoda comparison
Issue: -
Yoda conditions decrease code comprehensibility and readability by switching operands around comparison operators forcing the reader to read the code in an unnatural way.
Rule provides the following settings:
alwaysVariableOnRight
(defaults tofalse
): moves variables always to right.
DisallowYodaComparison
looks for and fixes such comparisons not only in if
statements but in the whole code.
However, if you prefer Yoda conditions, you can use RequireYodaComparison
.