Skip to content

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

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 Jun 4, 2015 · 3 comments
Closed

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

DartBot opened this issue Jun 4, 2015 · 3 comments

Comments

@DartBot
Copy link

DartBot commented Jun 4, 2015

<img src="https://avatars.githubusercontent.com/u/1731736?v=3" align="left" width="96" height="96"hspace="10"> Issue by tonygentilcore
Originally opened as dart-lang/sdk#23334


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 Jun 4, 2015

<img src="https://avatars.githubusercontent.com/u/444270?v=3" align="left" width="48" height="48"hspace="10"> Comment by seaneagan


The formatter will not do this for you:

#45
#182

Hopefully the linter will though:

dart-lang/sdk#57151

@DartBot DartBot added the bug label Jun 4, 2015
@DartBot
Copy link
Author

DartBot commented Jun 4, 2015

<img src="https://avatars.githubusercontent.com/u/4865287?v=3" align="left" width="48" height="48"hspace="10"> Comment by lrhn


Added Area-Formatter, Triaged labels.

@munificent
Copy link
Member

@seaneagen is right.

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