Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#359 - No Hanging Indentation #725

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,6 @@ Translations of the guide are available in the following languages:
body: source.text)
end

# good
def send_mail(source)
Mailer.deliver(to: '[email protected]',
from: '[email protected]',
subject: 'Important message',
body: source.text)
end

# good (normal indent)
def send_mail(source)
Mailer.deliver(
Expand All @@ -643,6 +635,40 @@ Translations of the guide are available in the following languages:
end
```

* <a name="no-hanging-indent"></a>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe no-hanging-param-indent or something like this?

Use a new line for the argument list of a method at the end of a chain
if they are indented more than one level from the first method.
<sup>[[link](#no-hanging-indent)]</sup>

```ruby
# bad (hanging indent)
some_method.with.a_longer.chain(:parameter_1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be made clear with respect to:

  1. no method chain - e.g. some_method(a,
  2. short method chain - frankly it seems to the example you deleted looks fine, as it's not really a long method chain.

:parameter_2,
:parameter_3,
:parameter_4)

# good (newline indent)
some_method.with.a_longer.chain(
:parameter_1,
:parameter_2,
:parameter_3,
:parameter_4
)

# good (multiple methods with newline indent)
very_long_kumquats =
some_method
.with
.a_much_much_much_much_much
.longer
.chain(
:parameter_1,
:parameter_2,
:parameter_3,
:parameter_4
)
```

* <a name="align-multiline-arrays"></a>
Align the elements of array literals spanning multiple lines.
<sup>[[link](#align-multiline-arrays)]</sup>
Expand Down