Skip to content

Formatter should understand single line if-blocks without curlies #23334

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
DartBot opened this issue Apr 28, 2015 · 3 comments
Closed

Formatter should understand single line if-blocks without curlies #23334

DartBot opened this issue Apr 28, 2015 · 3 comments

Comments

@DartBot
Copy link

DartBot commented Apr 28, 2015

This issue was originally filed by [email protected]


Run the formatter with an 80 col limit on a single line if-block whose condition fits within 80 cols, but predicate does not. For example:
if (foo = "1234567890123456789012345678901234567890") bar = "12345678901234567890";

Notice it formats to:
if (foo = "1234567890123456789012345678901234567890") bar =
    "12345678901234567890";

I'd expect it to produce:
if (foo = "1234567890123456789012345678901234567890")
  bar = "12345678901234567890";

Or better yet, add the curlies as specified by https://www.dartlang.org/articles/style-guide/#do-use-curly-braces-for-all-flow-control-structures , thus producing:
if (foo = "1234567890123456789012345678901234567890") {
  bar = "12345678901234567890";
}

Note that the formatter does the right thing if the curlies are already present.

@DartBot
Copy link
Author

DartBot commented Apr 28, 2015

This comment was originally written by @seaneagan


The formatter will not do this for you:

dart-lang/dart_style#45
dart-lang/dart_style#182

Hopefully the linter will though:

#57151

@lrhn
Copy link
Member

lrhn commented Apr 28, 2015

Added Area-Formatter, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jun 4, 2015

This issue has been moved to dart-lang/dart_style#260.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants