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

Need empty line before first member definition of a class #476

Closed
jjqq2013 opened this issue May 9, 2020 · 4 comments
Closed

Need empty line before first member definition of a class #476

jjqq2013 opened this issue May 9, 2020 · 4 comments

Comments

@jjqq2013
Copy link

jjqq2013 commented May 9, 2020

Thanks for your great work. I works well except some inconsistent output,

The output of following two java code are supposed to be same, but actually not, the both output the same as input.

public class Keys {
  private static class Identities0 {
    public static Identity<Long> IDENTITY_BILLING_OFFERINGS1 = Internal.create();
    public static Identity<Long> IDENTITY_BILLING_OFFERINGS2 = Internal.create();
  }
}
public class Keys {

  private static class Identities0 {

    public static Identity<Long> IDENTITY_BILLING_OFFERINGS1 = Internal.create();
    public static Identity<Long> IDENTITY_BILLING_OFFERINGS2 = Internal.create();
  }
}

I've tested this with version 1.8 and 1.7.

@tbroyer
Copy link
Contributor

tbroyer commented May 9, 2020

The Google Java Style says:

A blank line before the first member or initializer, or after the last member or initializer of the class, is neither encouraged nor discouraged.

(Source: https://google.github.io/styleguide/javaguide.html#s4.6.1-vertical-whitespace)

so it looks like google-java-format works as expected here, or at least it's not wrong.

@kevinb9n
Copy link
Contributor

kevinb9n commented May 9, 2020

We often still have the formatter standardize on a single choice anyway, but in this case we decided not to. There are big long hairy signatures for which it really helps to use a blank line after; whereas the second snippet above shows why a policy of always using the blank line is sad.

@jjqq2013
Copy link
Author

Thank you all for the comments. How do you consider the consistency? Essentially same java source files, generated difference output, though trivial?

@kuchaguangjie
Copy link

kuchaguangjie commented Sep 9, 2024

It's ugly & not neat to have that 2 empty lines.

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

5 participants