STYLEGUIDE.md in rubocop-github-0.16.2 vs STYLEGUIDE.md in rubocop-github-0.17.0
- old
+ new
@@ -306,48 +306,47 @@
## Hashes
Use the Ruby 1.9 syntax for hash literals when all the keys are symbols:
``` ruby
-# good
-user = {
- login: "defunkt",
- name: "Chris Wanstrath"
-}
-
# bad
user = {
:login => "defunkt",
:name => "Chris Wanstrath"
}
+# good
+user = {
+ login: "defunkt",
+ name: "Chris Wanstrath"
+}
```
Use the 1.9 syntax when calling a method with Hash options arguments or named arguments:
``` ruby
-# good
-user = User.create(login: "jane")
-link_to("Account", controller: "users", action: "show", id: user)
-
# bad
user = User.create(:login => "jane")
link_to("Account", :controller => "users", :action => "show", :id => user)
+
+# good
+user = User.create(login: "jane")
+link_to("Account", controller: "users", action: "show", id: user)
```
If you have a hash with mixed key types, use the legacy hashrocket style to avoid mixing styles within the same hash:
``` ruby
-# good
+# bad
hsh = {
- :user_id => 55,
+ user_id: 55,
"followers-count" => 1000
}
-# bad
+# good
hsh = {
- user_id: 55,
+ :user_id => 55,
"followers-count" => 1000
}
```
## Keyword Arguments
@@ -369,10 +368,10 @@
def remove_member(user, skip_membership_check: false)
# ...
end
# Elsewhere, now with more clarity:
-remove_member user, skip_membership_check: true
+remove_member(user, skip_membership_check: true)
```
## Naming
* Use `snake_case` for methods and variables.