Also it's slightly awkward to read, as mentioned by others already.
You can't force everyone who edits your code to have linters and warnings turned on. Not everyone follows bests practices.
Re: awkwardness, it doesn't feel awkward at all to me; given that Erlang and Elixir use assignment for destructuring and pattern-matching, Yoda conditionals feel very natural to me in comparison.
For example, this is valid Elixir code:
foo = {1, 2}
bar = if {baz, 2} = foo do
525600
end
IO.inspect foo # prints {1,2}
IO.inspect bar # prints 525600
IO.inspect baz # prints 1It's OK if your tools absolutely can't diagnose accidental if(a = b), but it should be the last resort.
mString != null && mString.equals("test")
or "test".equals(mString)
They do the same, but the second one adds hidden `defensive programming` to prevent NPE in `equals`. Saves time AND code.Intended usage of if(a=b) should be written as if((a=b)). Don't know what tool you use at work or at home, but most static code analysers will point you that. Try SonarQube at least.
I feel as if that can rephrased "Don't do it because it is not done." A left-hand side constant is a convention that can have practical benefits in limited cases. Which at least should merit consideration.