Skip to content

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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