bbatsov/ruby-style-guide — pull request #340 by gary (2014-07-22 16:40:35+00:00)
Title: Switch stance on line-based coding style

This change will help to minimize the number of changes to adjacent lines, which will allow for more productive use of tools like `git blame`.

By preferring a trailing comma on the end of the last item in of an `Array` or `Hash` literal, changes will be restricted to a single line because each future line will be syntactically complete. To be better explain, consider a Hash with 2 keys:

```ruby
{
foo: 'bar',
baz: 'qux'
}
```

In order to add another key/value pair to this Hash, we would have to change 2 lines:

```ruby
{
foo: 'bar',
baz: 'qux',
quux: 'corge'
}
```

Specifically, we must add a comma to the previous key/value pair and then add the key/value pair--changes on two lines.

With this proposed change in place, the above Hash would instead be declared like so:

```ruby
{
foo: 'bar',
baz: 'qux',
}
```

Which would simplify the effort needed to incorporate another key/value pair anywhere in the Hash. Now, to add the same key/value pair to the Hash, we only need to modify one line:

```ruby
{
foo: 'bar',
baz: 'quz',
quux: 'corge',
}
```

Further reading:

- http://mislav.uniqpath.com/2014/02/hidden-documentation/
- https://gist.github.com/isaacs/357981#comment-397