Skip to content

Short compound expressions in return statements format poorly (WONTFIX) #528

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

Closed
Hixie opened this issue Aug 24, 2016 · 3 comments
Closed

Comments

@Hixie
Copy link

Hixie commented Aug 24, 2016

This is similar to #525 but relates specifically to expressions that would fit on one line but are more readable when split across multiple lines.

This code:

    return oldWidget.runtimeType == newWidget.runtimeType
        && oldWidget.key == newWidget.key;

...turns into the less readable:

    return oldWidget.runtimeType == newWidget.runtimeType && oldWidget.key == newWidget.key;

...because the formatter decides it fits on one line given the provided line length.

Because the expressions are parallel, the code is more readable as originally written with the line break. The line break is significant, and either dartfmt should leave it there, or it should notice that the expression is more readable when split in this way.

@Hixie
Copy link
Author

Hixie commented Aug 24, 2016

Another example where removing the newline hurts:

    return _c1 * _r1 * math.pow(math.E, _r1 * time) +
           _c2 * _r2 * math.pow(math.E, _r2 * time);

The newline here is critical to a clear understanding of the code.

@Hixie
Copy link
Author

Hixie commented Aug 24, 2016

We could add redundant parens around the expressions here, that would reduce this to #532.

@munificent
Copy link
Member

This depends on doing vertical alignment (#508).

@Hixie Hixie changed the title Short compound expressions in return statements format poorly Short compound expressions in return statements format poorly (WONTFIX) Sep 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants