Skip to content

Indentation of method call without parenthesis seems wrong #255

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

Open
davidtaylorhq opened this issue Jan 16, 2023 · 0 comments
Open

Indentation of method call without parenthesis seems wrong #255

davidtaylorhq opened this issue Jan 16, 2023 · 0 comments

Comments

@davidtaylorhq
Copy link
Contributor

# Before
expect("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx").to eq("yyyyyyy"), "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

# After
expect("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx").to eq("yyyyyyy"),
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

The lack of indentation on the second line makes this quite hard to read.

Curiously, if .to is replaced with some other two-letter method name, then the second line is indented by 5 spaces. (Is .to special-cased somehow?). This works out better, but 5 spaces seems a little arbitrary:

# before
expect("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx").tp eq("yyyyyyy"), "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

#after
expect("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx").tp eq("yyyyyyy"),
     "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

Adding parenthesis to the method call makes things much cleaner:

# Before
expect("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx").to(eq("yyyyyyy"), "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz")

expect("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx").to(
  eq("yyyyyyy"),
  "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",
)

Perhaps syntax_tree should always add parenthesis when method arguments need to be wrapped across multiple lines?

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

No branches or pull requests

1 participant