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

Use "indented" style for MultilineMethodCallIndentation #65

Merged
merged 1 commit into from
May 14, 2020

Conversation

wfleming
Copy link
Contributor

The current (default) value for this check wants chained assignments to
look like:

foo =
  Foo.
  bar.
  baz

That is not a style I think anybody on our team habitually writes. What
I think we tend to do (and which matches the indented style) is:

foo = Foo.
  bar.
  baz

Since AFAIK this is already the most common de-facto style we use, we
should probably set that in the styleguide.

The current (default) value for this check wants chained assignments to
look like:

```
foo =
  Foo.
  bar.
  baz
```

That is not a style I think anybody on our team habitually writes. What
I think we tend to do (and which matches the `indented` style) is:

```
foo = Foo.
  bar.
  baz
```

Since AFAIK this is already the most common de-facto style we use, we
should probably set that in the styleguide.
@wfleming wfleming requested a review from a team May 14, 2020 15:08
Copy link

@kurko kurko left a comment

Choose a reason for hiding this comment

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

I don't have strong feelings about either one. LGTM.

I would hope to someday live in a world where the dot is leading not trailing for the reasons thoroughly expressed in standardrb/standard#75

@wfleming
Copy link
Contributor Author

I would hope to someday live in a world where the dot is leading not trailing for the reasons thoroughly expressed in standardrb/standard#75

@kurko I tend to agree, but because that's a really broad change across the existing code I've been putting if off until we set up an auto-formatter for Ruby, which is a perpetual "hack week?" project.

@wfleming wfleming merged commit ef7bebc into master May 14, 2020
@wfleming wfleming deleted the will/multiline-method-call-style-change branch May 14, 2020 15:32
@bzanchet
Copy link

I guess this change had an unintended consequence in the way we indent queries within scopes. The current format matches the indentation on the first example:

  scope :syncable, -> {
    joins(vcs_owner: { vcs_owner_connections: :organization }).
    distinct.
    where.not(status: SYNCINC_STATUSES).
    where("sync_finished_at is null or sync_finished_at < ?", AUTO_SYNC_FREQUENCY.ago).
    merge(Organization.processable).
    order("sync_finished_at NULLS FIRST")
  }

and now rubocop is expecting that same code to look like this:

  scope :syncable, -> {
    joins(vcs_owner: { vcs_owner_connections: :organization }).
      distinct.
      where.not(status: SYNCINC_STATUSES).
      where("sync_finished_at is null or sync_finished_at < ?", AUTO_SYNC_FREQUENCY.ago).
      merge(Organization.processable).
      order("sync_finished_at NULLS FIRST")
  }

while I agree the new rule is better for calling methods, it looks kind of awkward on scopes. Anyway, just FYI.

Ref: https://codeclimate.com/repos/59f12f7da7c8dc02c00011be/pull/11119

hat tip to @filipesperandio who connected the dots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants