Skip to content
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

dartfmt doesn't like 'if' flow control statements without blocks (FIXED) #448

Closed
Hixie opened this issue Oct 23, 2015 · 0 comments
Closed
Assignees

Comments

@Hixie
Copy link

Hixie commented Oct 23, 2015

The following code is easy to read: you have three clear conditions (t=0, t=1, and other), and in each case you can clearly see that it sets value.

      if (t == 0.0)
        value = begin;
      else if (t == 1.0)
        value = end;
      else
        value = lerp(t);

The formatter turns it into:

      if (t == 0.0) value = begin;
      else if (t == 1.0) value = end;
      else value = lerp(t);

...which isn't as readable.

A similar case:

    if (direction == AnimationDirection.forward || reverseCurve == null)
      return curve;

Formatter says:

    if (direction == AnimationDirection.forward ||
        reverseCurve == null) return curve;

...which is nowhere near as readable.

Here's a case where it's better to go over the 80 char limit than try to wrap (see #450):

      if (outputSize.width / outputSize.height > sourceSize.width / sourceSize.height)
        destinationSize = new Size(sourceSize.width * outputSize.height / sourceSize.height, outputSize.height);
      else
        destinationSize = new Size(outputSize.width, sourceSize.height * outputSize.width / sourceSize.width);

Currently the formatter turns that into:

      if (outputSize.width / outputSize.height >
          sourceSize.width / sourceSize.height) destinationSize = new Size(
          sourceSize.width * outputSize.height / sourceSize.height,
          outputSize.height);
      else destinationSize = new Size(outputSize.width,
          sourceSize.height * outputSize.width / sourceSize.width);
@munificent munificent self-assigned this Nov 3, 2015
@Hixie Hixie changed the title dartfmt doesn't like 'if' flow control statements without blocks dartfmt doesn't like 'if' flow control statements without blocks (FIXED) Aug 24, 2016
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

2 participants