Skip to content

Indenting too much #506

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
noel-yap opened this issue Jul 14, 2020 · 4 comments
Closed

Indenting too much #506

noel-yap opened this issue Jul 14, 2020 · 4 comments

Comments

@noel-yap
Copy link

The following code is indented too much after Array.of:

                  final Array<Integer> myArray =
                      Array.of(
                              …);

And since it's nowhere near the 100 character line limit, ideally it would be:

                  final Array<Integer> myArray = Array.of(
                      …);
@tbroyer
Copy link
Contributor

tbroyer commented Jul 14, 2020

Isn't it the Rectangle Rule at work?

@noel-yap
Copy link
Author

I wasn't aware of that rule. Thanks for point me to it.

I'm thinking this what I had posted should be considered to be an exception to the rule. The following may fall under the same exception:

…
    .map(arg -> {
      return …;
    })

is, IMO, more readable than:

…
    .map(
        arg -> {
          return …;
        })

considering it's very similar to:

void map(int arg) {
  …
}

I'm wondering if the root issue is the preference towards exposing program structure over exposing the more meaningful parts of the program. For example, the body of the lambda passed into map provides more semantics to what's happening in the program than do the argument names. I would say the same holds true for the arguments to Array.of versus the Array.of itself.

@tbroyer
Copy link
Contributor

tbroyer commented Jul 15, 2020

See #19 about lambdas

@cushon
Copy link
Collaborator

cushon commented Aug 21, 2020

@tbroyer covered it, the formatter prioritizes breaking at higher syntactic levels (i.e. the rectangle rule) over conserving vertical space or minimizing lines or indentation.

@cushon cushon closed this as completed Aug 21, 2020
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