Skip to content

Rectangle rule indents lambdas 8 extra columns #2

Closed

Description

@swankjesse

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.

Activity

  1. cushon commented on May 15, 2015

    @cushon
    Collaborator

    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);
            });
    
  2. kevinb9n commented on May 15, 2015

    @kevinb9n
    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

  3. added a commit that references this issue on Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions