Skip to content

Commit

Permalink
[Fix rubocop#223] Cover use of {} in argument hash
Browse files Browse the repository at this point in the history
Explicitly cover whether {} should be used around options hashes being
passed to methods
  • Loading branch information
meagar authored and Matthew Eagar committed Sep 11, 2013
1 parent 65b172e commit bb48cf3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,29 @@ Never use `::` for regular method invocation.
bowling.score.should == 0
```
* Omit the outer braces around an implicit options hash.
```Ruby
# bad
user.set({ name: 'John', age: 45, permissions: { read: true } })
# good
User.set(name: 'John', age: 45, permissions: { read: true })
```
* Omit both the outer braces and parentheses for methods that are
part of an internal DSL.
```Ruby
class Person < ActiveRecord::Base
# bad
validates(:name, { presence: true, length: { within: 1..10 } })
# good
validates :name, presence: true, length: { within: 1..10 }
end
```
* Omit parentheses for method calls with no arguments.
```Ruby
Expand Down

0 comments on commit bb48cf3

Please sign in to comment.