Skip to content

Rectangle rule indents lambdas 8 extra columns #2

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
swankjesse opened this issue May 15, 2015 · 2 comments
Closed

Rectangle rule indents lambdas 8 extra columns #2

swankjesse opened this issue May 15, 2015 · 2 comments

Comments

@swankjesse
Copy link

Before: code in lambda is indented +2:

    transacter.executeWithRetries(session -> {
      boolean authenticated = appAuthenticator.isAuthenticated(session, appAuthorization);
      if (!authenticated) {
        logger.info("signOutApp failed for [appToken=%s]", appAuthorization.appToken);
        throw CashApiException.unauthorized();
      }
      appAuthenticator.revokeSession(session, appAuthorization.appToken, false);
    });

After: code in lambda is indented +10:

    transacter.executeWithRetries(
        session
            -> {
              boolean authenticated = appAuthenticator.isAuthenticated(session, appAuthorization);
              if (!authenticated) {
                logger.info("signOutApp failed for [appToken=%s]", appAuthorization.appToken);
                throw CashApiException.unauthorized();
              }
              appAuthenticator.revokeSession(session, appAuthorization.appToken, false);
            });

I think it's consistent with the rule, but this case seemed particularly harsh.

@cushon
Copy link
Collaborator

cushon commented May 15, 2015

I think that breaking before -> is a bug. Fixing that would make it a little better:

    transacter.executeWithRetries(
        session -> {
          boolean authenticated = appAuthenticator.isAuthenticated(session, appAuthorization);
          if (!authenticated) {
            logger.info("signOutApp failed for [appToken=%s]", appAuthorization.appToken);
            throw CashApiException.unauthorized();
          }
          appAuthenticator.revokeSession(session, appAuthorization.appToken, false);
        });

@kevinb9n
Copy link
Contributor

Roughly, I would say:

When a lambda is using in-line presentation, then -> is like a binary
operator.
When a lambda is using block presentation, then the (params) -> { part
ought to bind more tightly together than we see here.

On Fri, May 15, 2015 at 8:47 AM, Liam Miller-Cushon <
notifications@github.com> wrote:

I think that breaking before -> is a bug. Fixing that would make it a
little better:

transacter.executeWithRetries(
    session -> {
      boolean authenticated = appAuthenticator.isAuthenticated(session, appAuthorization);
      if (!authenticated) {
        logger.info("signOutApp failed for [appToken=%s]", appAuthorization.appToken);
        throw CashApiException.unauthorized();
      }
      appAuthenticator.revokeSession(session, appAuthorization.appToken, false);
    });


Reply to this email directly or view it on GitHub
#2 (comment)
.

Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb@google.com

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