Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix assignments in if expressions for like the 5th time #297
The latest issue is this:
x = 1 if something x = 2 x = 3 # x should be 3 else x = 4 x = 5 # x should be 5 end x # x should be (1 or 3 or 5)
What Brakeman was actually doing:
x = 1 if something x = 2 x = 3 # x is (1 or 3) else x = 4 x = 5 # x is (1 or 3 or 5) end x # x is (1 or 3 or 5)
Oops! Besides being wrong, this causes a lot of unnecessary duplication of values. On top of that, the previous fix was really complicated and confusing, whereas this is a bit simpler.