Skip to content

comments are sometimes placed at the end of lines, making formatting non-idempotent #807

@froydnj

Description

@froydnj

I'm seeing this behavior on Stripe's codebase, but I haven't managed to reduce a testcase yet. The testcase looks something like:

foo(
  read_from_cache_func: -> (limestone_result, local_cache) {
    cached_connections = applications
      .map do |application|
        local_cache.authorized_connection_cache.get_thing_by_the_things(
          account_granting: account,
          application: application.token
        )
      end
      .compact
    # for now assume cache miss if any connection application lookup returns nil
    return cached_connections.size == applications.size
  },
  command_name: "fake_command_name_with_bees"
)

and rubyfmt will take the comment and place it at the end of the return line...but if you format it again, it will correctly place it in the location it is above.

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