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

Enable Layout/MultilineAssignmentLayout #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

schneidmaster
Copy link
Contributor

Enforces that multiline assignments begin on a new line.

# bad
foo = if expression
  'bar'
else
  'baz'
end

# good
foo =
  if expression
    'bar'
  else
    'baz'
  end

I am not strongly opinionated about this particular cop, but it does keep the lines clean and easy to follow. Also, in combination with the rest of our configuration, it makes it a lot easier to get a sane result out of autocorrect. Otherwise, sometimes this happens:

class SomeClass
  def some_method
    foo = if expression
      'bar'
          else
            'baz'
          end
  end
end

because it wants to line up the ifs and elses and it also wants to have new lines indented by 2 spaces past the previous line and those two things can be in conflict.

Verified

This commit was signed with the committer’s verified signature.
schneidmaster Zach Schneider
@stevenpetryk
Copy link
Contributor

👍 I find the new format way more readable.

@sbeckeriv
Copy link
Contributor

i dont fully follow the example i would expect it to format like this

class SomeClass
  def some_method
    foo = if expression
      'bar'
    else
      'baz'
    end
  end
end

i think the else end should line up with the assigned variable.

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.

None yet

3 participants