Skip to content

Single-line do ... end is not always replaced with braces #251

Open
@davidtaylorhq

Description

@davidtaylorhq

Normally, syntax_tree will convert single-line do...end into braces. For example:

- expect do blah end.to(eq(5))
+ expect { blah }.to(eq(5))

However, if the parenthesis are missing from to() (as they often are in rspec code), no attempt is made to use braces. The code remains as

expect do blah end.to eq(5)

Context: in Discourse we previously had a number of things like

expect do
  blah
end.to eq(5)

That reads ok.

After syntax_tree formatting this has been moved onto a single line, and maintained the do ... end

expect do blah end.to eq(5)

which is not ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions