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

Wrong indentation on if-then with comments #1009

Open
radumereuta opened this issue Dec 12, 2023 · 2 comments
Open

Wrong indentation on if-then with comments #1009

radumereuta opened this issue Dec 12, 2023 · 2 comments

Comments

@radumereuta
Copy link

Comments at the end of this if makes the then block to not get indented.

                            if (prd.source()
                                .isPresent()) // exclude generated productions like casts
                            prd = null;

image
Line 331. IntelliJ reports this as well.
I think the problem comes from the if condition that got split into two lines. If I move the comment to a separate line, then indentation works as expected.

@cushon
Copy link
Collaborator

cushon commented Dec 12, 2023

The style guide requires braces for if statements: https://google.github.io/styleguide/javaguide.html#s4.1.1-braces-always-used (#938 is slightly related)

So I agree this isn't a good formatting and we'd probably prefer something like the following, but this is also low priority because it's already not following the style guide:

  if (prd.source()
      .isPresent()) // exclude generated productions like casts
    prd = null;

@sabi0
Copy link

sabi0 commented Jan 28, 2024

I see this also with a condition on a single line:
image

I.e. the line break in the condition is likely not the cause.

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