Skip to content

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

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 9, 2023 · 1 comment
Open

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

davidtaylorhq opened this issue Jan 9, 2023 · 1 comment

Comments

@davidtaylorhq
Copy link
Contributor

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.

@kddnewton
Copy link
Member

Hmm yeah, I'll need to see why it's doing that. As you say, it should be using braces here.

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

2 participants