Skip to content

Commit

Permalink
Merge remote-tracking branch 'bbatsov/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
0x01f7 committed Mar 5, 2017
2 parents c375117 + 8b6944d commit 6ceb522
Showing 1 changed file with 104 additions and 3 deletions.
107 changes: 104 additions & 3 deletions README.md
Expand Up @@ -83,6 +83,7 @@ Translations of the guide are available in the following languages:
* [Naming](#naming)
* [Comments](#comments)
* [Comment Annotations](#comment-annotations)
* [Magic Comments](#magic-comments)
* [Classes & Modules](#classes--modules)
* [Exceptions](#exceptions)
* [Collections](#collections)
Expand Down Expand Up @@ -401,6 +402,88 @@ Translations of the guide are available in the following languages:
end
```

* <a name="two-or-more-empty-lines"></a>
Don't use several empty lines in a row.
<sup>[[link](#two-or-more-empty-lines)]</sup>

```Ruby
# bad - It has two empty lines.
some_method


some_method

# good
some_method

some_method
```

* <a name="empty-lines-around-access-modifier"></a>
Use empty lines around access modifiers.
<sup>[[link](#empty-lines-around-access-modifier)]</sup>

```Ruby
# bad
class Foo
attr_reader :foo
def foo
# do something...
end
end

# good
class Foo
attr_reader :foo

def foo
# do something...
end
end
```

* <a name="empty-lines-around-bodies"></a>
Don't use empty lines around method, class, module, block bodies.
<sup>[[link](#empty-lines-around-bodies)]</sup>

```Ruby
# bad
class Foo

def foo

begin

do_something do

something

end

rescue

something

end

end

end

# good
class Foo
def foo
begin
do_something do
something
end
rescue
something
end
end
end
```

* <a name="no-trailing-params-comma"></a>
Avoid comma after the last parameter in a method call, especially when the
parameters are not on separate lines.
Expand Down Expand Up @@ -1028,7 +1111,7 @@ Translations of the guide are available in the following languages:
ok = got_needed_arguments and arguments_are_valid

# control flow
document.save or fail(RuntimError, "Failed to save document!")
document.save or fail(RuntimeError, "Failed to save document!")

# good
# boolean expression
Expand Down Expand Up @@ -2470,6 +2553,24 @@ no parameters.
end
```

* <a name="mixin-grouping"></a>
Split multiple mixins into separate statements.
<sup>[[link](#mixin-grouping)]</sup>

```Ruby
# bad
class Person
include Foo, Bar
end

# good
class Person
# multiple mixins go in separate statements
include Foo
include Bar
end
```

* <a name="file-classes"></a>
Don't nest multi-line classes within classes. Try to have such nested
classes each in their own file in a folder named like the containing class.
Expand Down Expand Up @@ -2934,7 +3035,7 @@ no parameters.
leading `self` or own name followed by a `.` when calling other such methods.
This is often seen in "service classes" or other similar concepts where a
class is treated as though it were a function. This convention tends to reduce
repetitive boilerpate in such classes.
repetitive boilerplate in such classes.
<sup>[[link](#class-and-self)]</sup>

```Ruby
Expand Down Expand Up @@ -3868,7 +3969,7 @@ resource cleanup when possible.
```

* <a name="percent-q"></a>
Avoid %() or the equivlant %q() unless you have a string with both `'` and
Avoid %() or the equivalent %q() unless you have a string with both `'` and
`"` in it. Regular string literals are more readable and should be preferred
unless a lot of characters would have to be escaped in them.
<sup>[[link](#percent-q)]</sup>
Expand Down

0 comments on commit 6ceb522

Please sign in to comment.