这是indexloc提供的服务,不要输入任何密码
Skip to content

[Formatting issue] Questionable newlines on short arguments instead of calls #1731

@filiph

Description

@filiph

What input code did you provide to the formatter?

    buf.write((duration.inSeconds % Duration.secondsPerMinute)
        .toString()
        .padLeft(2, '0'));

What output did the formatter produce?

    buf.write(
      (duration.inSeconds % Duration.secondsPerMinute).toString().padLeft(
        2,
        '0',
      ),
    );

What output did you expect or want the formatter to produce?

Describe how you expected the formatter to format the code, ideally by showing what you had in mind as code.

    buf.write((duration.inSeconds % Duration.secondsPerMinute)
        .toString()
        .padLeft(2, '0'));

or maybe

    buf.write(
      (duration.inSeconds % Duration.secondsPerMinute)
        .toString()
        .padLeft(2, '0'),
    );

or maybe (if it fits)

    buf.write(
      (duration.inSeconds % Duration.secondsPerMinute).toString().padLeft(2, '0'),
    );

Anything else we should know?

I guess maybe the formatter should take into consideration the length of the arguments. If the arguments were longer, I guess the formatter's decision would make more sense, but when it's 2 and '0', it looks a bit silly.

Sidenote: I can't find it now, but I think I remember seeing something like:

  (
    _
  ) => ...

It was a closure with ignored argument, and the _ was on its own line. I think maybe that's the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions