Skip to content

Unexpected formatting of block using curly-brace notation #461

@damolina-stripe

Description

@damolina-stripe
  • Ruby version: 3.1
  • Rubyfmt git sha: (if unsure, redownload the latest version and run against that) Stripe's

Input file

    def foo(e)
      e.to_s.each_line(chomp: true) { 
        |l| X }
    end

In my repro, X was a long namespaced-method call so I was looking to learn whether rubyfmt would recommend to keep as a single line or else.

Rubyfmt's output

    def foo(e)
      e.to_s.each_line(chomp: true) { |
          l
        | X }
    end

This breaks because

Unexpected formatting, breaking variable declaration across multiple lines seems wrong

  1. Not to break the declaration of |l|
  2. Probably, leave as is, make a single line, or ?
    def foo(e)
      e.to_s.each_line(chomp: true) {  |l| X }
    end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions