Skip to content

Indentation of method call without parenthesis seems wrong #255

@davidtaylorhq

Description

@davidtaylorhq
# 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions