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

Nested method call with parameters auto-corrected wrongly #1820

Closed
matthewrudy opened this issue Apr 22, 2015 · 2 comments
Closed

Nested method call with parameters auto-corrected wrongly #1820

matthewrudy opened this issue Apr 22, 2015 · 2 comments
Assignees
Labels

Comments

@matthewrudy
Copy link

Given the input

def example
  a(
    b: :c,
    d: e(
      f: g
    ), h: :i)
end

I get the message

example.rb:6:8: C: [Corrected] Align the elements of a hash literal if they span more than one line.
    ), h: :i)
       ^^^^^

and the correction

def example
  a(
    b: :c,
    d: e(
      f: g
    h: :i)
end

Notably, it breaks the nested function call, and causes a syntax error.

Clearly this is being parsed as a hash literal rather than function parameters
and it doesn't know about nested function calls.

I tried to dig around, but I'm not quite sure where to start.

@matthewrudy
Copy link
Author

Seems i can do the same with a hash

{ a: :b,
  c: {
    d: :e
  }, f: {
    g: :h
  }
}

becomes

{ a: :b,
  c: {
    d: :e
  f: {
    g: :h
  }
}

@jonas054 jonas054 self-assigned this Apr 22, 2015
@jonas054 jonas054 added the bug label Apr 22, 2015
@matthewrudy
Copy link
Author

That fix looks good @jonas054. Thanks.

bbatsov added a commit that referenced this issue Apr 23, 2015
[Fix #1820] Check only keys starting their lines in AlignHash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants