presidentbeef/brakeman — pull request #499 by presidentbeef (2014-05-30 09:08:48+00:00)
Title: Ignore branches when assigning via +=

When processing assignments with `+=` in branches, things quickly get out of control.

Simple code like this:
```ruby
x = something
x += this if cool
x += that if not_cool
x += the_other_thing if something
p x
```
becomes
```ruby
x = something
x = (something + this) if cool
x = ((something or (something + this)) + that) if not_cool
if something then
x = (((something or (something + this)) or ((something or (something + this)) + that)) + the_other_thing)
end
p((((something or (something + this)) or ((something or (something + this)) + that)) or (((something or (something + this)) or ((something or (something + this)) + that)) + the_other_thing)))
```
With this patch, these branches will now be ignored for `+=`. The result is code like
```ruby
x = something
x = (something + this) if cool
x = ((something + this) + that) if not_cool
x = (((something + this) + that) + the_other_thing) if something
p((((something + this) + that) + the_other_thing))
```
While this loses some of the semantics, the important thing is all the values are there. For all cases I can think of, that's all that really matters.

Also, this is WAY faster because there are way fewer values being copied, which is the main motivation for this change. Files that were taking longer than 15 minutes to process (I stopped caring after waiting that long) now take less than half a second.

Unfortunately, this had to be applied to numbers, too. But I really don't think there was any processing that would handle a bunch of ORed numbers properly anyway.