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

Formatting of empty types is not idempotent #12

Closed
PhilippWendler opened this issue Oct 3, 2015 · 3 comments
Closed

Formatting of empty types is not idempotent #12

PhilippWendler opened this issue Oct 3, 2015 · 3 comments

Comments

@PhilippWendler
Copy link

The code

public class Test {

}

is formatted by google-java-format to

public class Test {
}

and if it is run again on the result the output of the second run is

public class Test {}

I think this should be done in one step. It occurred originally for me on an annotation with no members.

@kevinb9n
Copy link
Contributor

kevinb9n commented Oct 3, 2015

Thanks! I think (from what I understand) this might be fixed in the next update.

@PhilippWendler
Copy link
Author

Actually, when think about it, I prefer the two-line version (with closing brace on separate line) for empty types. It makes the diff have less impact when a member gets added later.

The Google Java Style says the single-line variant is optional, so maybe google-java-format could output the two-line variant consistently for empty types, if you agree it is nicer?

@cushon
Copy link
Collaborator

cushon commented Oct 19, 2015

The non-idempotent formatting bug is fixed now.

I think the verdict is to stick with the one-line form, although in general the formatter does prioritize cleaner diffs over saving vertical lines.

@cushon cushon closed this as completed in 3328080 Oct 19, 2015
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