fables-tales / rubyfmt

Ruby Autoformatter!
MIT License
1.07k stars 50 forks source link

Add support for endless method definitions #405

Closed reese closed 1 year ago

reese commented 1 year ago

Related to #399

On the tin -- endless method definitions are ~the same as regular definitions in Ripper, the only difference being that instead of an array of expressions (and the optional rescue/ensure/etc.), it returns only a single expression.

In terms of style, this PR does nothing special -- endless method definitions just render expressions the same as e.g. an assignment. Note that they don't increase the indentation level here, same as variable assignments (although that's not a strong opinion, happy to change that if we want), so multiline expressions do end up left-aligned. (My only reasoning for this is that it looks a little strange to indent it without anend somewhere 🤷)